{"record":{"id":"ed6951a30c3f578e","repo":"dgraph-io/badger","slug":"manifest-invalid-table-d-exists","errorCode":null,"errorMessage":"MANIFEST invalid, table %d exists","messagePattern":"MANIFEST invalid, table (.+?) exists","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"manifest.go","lineNumber":433,"sourceCode":"\n\t\tvar changeSet pb.ManifestChangeSet\n\t\tif err := proto.Unmarshal(buf, &changeSet); err != nil {\n\t\t\treturn Manifest{}, 0, err\n\t\t}\n\n\t\tif err := applyChangeSet(&build, &changeSet, opt); err != nil {\n\t\t\treturn Manifest{}, 0, err\n\t\t}\n\t}\n\n\treturn build, offset, nil\n}\n\nfunc applyManifestChange(build *Manifest, tc *pb.ManifestChange, opt Options) error {\n\tswitch tc.Op {\n\tcase pb.ManifestChange_CREATE:\n\t\tif _, ok := build.Tables[tc.Id]; ok {\n\t\t\treturn fmt.Errorf(\"MANIFEST invalid, table %d exists\", tc.Id)\n\t\t}\n\t\tbuild.Tables[tc.Id] = TableManifest{\n\t\t\tLevel:       uint8(tc.Level),\n\t\t\tKeyID:       tc.KeyId,\n\t\t\tCompression: options.CompressionType(tc.Compression),\n\t\t}\n\t\tfor len(build.Levels) <= int(tc.Level) {\n\t\t\tbuild.Levels = append(build.Levels, levelManifest{make(map[uint64]struct{})})\n\t\t}\n\t\tbuild.Levels[tc.Level].Tables[tc.Id] = struct{}{}\n\t\tbuild.Creations++\n\tcase pb.ManifestChange_DELETE:\n\t\ttm, ok := build.Tables[tc.Id]\n\t\tif !ok {\n\t\t\topt.Warningf(\"MANIFEST delete: table %d has already been removed\", tc.Id)\n\t\t\tfor _, level := range build.Levels {\n\t\t\t\tdelete(level.Tables, tc.Id)\n\t\t\t}","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/manifest.go#L415-L451","documentation":"Returned by applyManifestChange while replaying or applying a ManifestChange of op CREATE: the table ID being created already exists in the in-memory Tables map. A valid MANIFEST never creates the same table ID twice, so encountering a duplicate CREATE means the change log is internally inconsistent — either file corruption or a replay of stale changes — and Badger aborts opening rather than build a corrupt LSM view.","triggerScenarios":"Thrown at manifest.go:433 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the MANIFEST (and the database directory) from a known-good backup","If the duplicate entry is in a trailing corrupt block, truncate the MANIFEST at the previous valid change set per the troubleshooting guide","Verify disk health, as duplicated change records typically stem from corruption or torn writes","Otherwise drop the directory and rebuild the database from an export/backup"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2a001d466f6b71a917319a1db41f99860e16e269","analyzedAt":"2026-09-05T13:00:02.264Z","contentChangedAt":"2026-09-05T13:00:02.264Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}