{"record":{"id":"f4b68dcb45d19923","repo":"apache/pulsar","slug":"invalid-data-found","errorCode":null,"errorMessage":"Invalid data found","messagePattern":"Invalid data found","errorType":"exception","errorClass":"ReplicationException.CompatibilityException","httpStatus":null,"severity":"critical","filePath":"pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/PulsarLedgerUnderreplicationManager.java","lineNumber":208,"sourceCode":"                } catch (ExecutionException | InterruptedException e) {\n                    if (!(e.getCause() instanceof MetadataStoreException.BadVersionException)) {\n                        throw new RuntimeException(e);\n                    }\n                }\n            } else {\n                byte[] layoutData = store.get(layoutPath).join().get().getValue();\n\n                LedgerRereplicationLayoutFormat layout = new LedgerRereplicationLayoutFormat();\n\n                try {\n                    layout.parseFromTextFormat(layoutData);\n                    if (!layout.getType().equals(LAYOUT)\n                            || layout.getVersion() != LAYOUT_VERSION) {\n                        throw new ReplicationException.CompatibilityException(\n                                \"Incompatible layout found (\" + LAYOUT + \":\" + LAYOUT_VERSION + \")\");\n                    }\n                } catch (RuntimeException pe) {\n                    throw new ReplicationException.CompatibilityException(\n                            \"Invalid data found\", pe);\n                }\n                break;\n            }\n        }\n    }\n\n    private long getLedgerId(String path) throws NumberFormatException {\n        Matcher m = ID_EXTRACTION_PATTERN.matcher(path);\n        if (m.find()) {\n            return Long.parseLong(m.group(1));\n        } else {\n            throw new NumberFormatException(\"Couldn't find ledgerid in path\");\n        }\n    }\n\n    private static String getParentPath(String base, long ledgerId) {\n        String subdir1 = String.format(\"%04x\", ledgerId >> 48 & 0xffff);","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/PulsarLedgerUnderreplicationManager.java#L190-L226","documentation":"When the stored LAYOUT znode data cannot be parsed as LedgerRereplicationLayoutFormat (parseFromTextFormat throws a RuntimeException), checkLayout wraps it in ReplicationException.CompatibilityException with message \"Invalid data found\". It means the layout znode contains corrupted or foreign data.","triggerScenarios":"Reading a LAYOUT znode whose bytes are not valid layout text — truncated writes, data written by an incompatible tool, manual znode edits, or corruption in the metadata store.","commonSituations":"Partial/failed writes during crashes; someone hand-edited znodes; migrating data between stores with encoding differences; metadata store corruption after disk issues.","solutions":["Dump the LAYOUT znode content and check whether it matches the expected LedgerRereplicationLayoutFormat text form.","Restore the znode from a healthy backup/snapshot of the metadata store.","On a fresh/test cluster only, delete and let the manager re-create the layout znode.","Check metadata store health for underlying corruption and repair per the store's tooling."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"try {\n    new LedgerRereplicationLayoutFormat().parseFromTextFormat(store.get(layoutPath).join().get().getValue());\n} catch (RuntimeException pe) {\n    // layout znode is corrupt: restore from backup before starting the broker\n}","typeGuard":null,"tryCatchPattern":"try {\n    urManager.checkLayout();\n} catch (ReplicationException.CompatibilityException e) {\n    // e.getCause() holds the parse failure; restore or recreate the layout znode\n}","preventionTips":["Never hand-edit metadata znodes; use supported tooling.","Keep regular metadata store snapshots for recovery.","After unclean shutdowns, verify layout znode integrity before restart."],"tags":["bookkeeper","underreplication","corrupt-data","layout"],"backgroundTag":"invalid-layout-data","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}