{"record":{"id":"7ea4e3955269a50f","repo":"hyperledger/fabric","slug":"config-history-for-ledger-s-exists-incremental","errorCode":null,"errorMessage":"config history for ledger [%s] exists. Incremental import is not supported. Remove the existing ledger data before retry","messagePattern":"config history for ledger \\[(.+?)\\] exists\\. Incremental import is not supported\\. Remove the existing ledger data before retry","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/ledger/confighistory/mgr.go","lineNumber":131,"sourceCode":"// ledgerID from the snapshot files present in the dir\nfunc (m *Mgr) ImportFromSnapshot(ledgerID string, dir string) error {\n\texist, _, err := fileutil.FileExists(filepath.Join(dir, snapshotDataFileName))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !exist {\n\t\t// when the ledger being bootstrapped never had a private data collection for\n\t\t// any chaincode, the snapshot files associated with the confighistory store\n\t\t// will not be present in the snapshot directory. Hence, we can return early\n\t\treturn nil\n\t}\n\tdb := m.dbProvider.getDB(ledgerID)\n\tempty, err := db.IsEmpty()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !empty {\n\t\treturn errors.New(fmt.Sprintf(\n\t\t\t\"config history for ledger [%s] exists. Incremental import is not supported. \"+\n\t\t\t\t\"Remove the existing ledger data before retry\",\n\t\t\tledgerID,\n\t\t))\n\t}\n\n\tconfigMetadata, err := snapshot.OpenFile(filepath.Join(dir, snapshotMetadataFileName), snapshotFileFormat)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer configMetadata.Close()\n\n\tnumCollectionConfigs, err := configMetadata.DecodeUVarInt()\n\tif err != nil {\n\t\treturn err\n\t}\n\tcollectionConfigData, err := snapshot.OpenFile(filepath.Join(dir, snapshotDataFileName), snapshotFileFormat)\n\tif err != nil {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/confighistory/mgr.go#L113-L149","documentation":"ImportFromSnapshot refuses to import snapshot collection-config history into a ledger whose config history DB already contains data. Incremental imports are unsupported by design to keep snapshot-derived history consistent.","triggerScenarios":"ImportFromSnapshot (via CreateFromSnapshot) is invoked for a ledgerID whose confighistory LevelDB directory is non-empty — e.g. re-running snapshot import against an existing ledger, or a ledger that ran normally and then had a snapshot import attempted.","commonSituations":"Operator retries a failed snapshot restore without clearing ledger data; pointing a snapshot import at a live/pre-existing ledgerID; running the import twice (idempotency mistake).","solutions":["Remove the existing ledger data directory for that ledgerID (e.g. ledgersData/ledgerProvider under the peer's filesystem path) before re-importing","Restore the full ledger from the snapshot (snapshot import is a one-shot operation on a fresh ledger)","Verify the ledgerID — you may be accidentally importing into an existing ledger rather than a new one","Ensure automation doesn't re-run the import step after a successful first pass"],"exampleFix":"# before\npeer node rebuild-dbs   # ledger data still present, import fails\n# after\nrm -rf /var/hyperledger/production/ledgersData/ledgerProvider/<ledgerID>  # or wipe ledger dir\npeer node rebuild-dbs && re-run snapshot import on the empty ledger","handlingStrategy":"validation","validationCode":"db := dbProvider.getDB(ledgerID)\nempty, err := db.IsEmpty()\nif err != nil { return err }\nif !empty {\n    return fmt.Errorf(\"ledger %s already has config history; skip import or wipe data\", ledgerID)\n}\nreturn mgr.ImportFromSnapshot(ledgerID, newHashFunc, dir)","typeGuard":"func canImportSnapshot(dbProvider *dbProvider, ledgerID string) bool {\n    empty, err := dbProvider.getDB(ledgerID).IsEmpty()\n    return err == nil && empty\n}","tryCatchPattern":"err := mgr.ImportFromSnapshot(ledgerID, hashFunc, dir)\nif err != nil && strings.Contains(err.Error(), \"Incremental import is not supported\") {\n    // wipe the ledger's config history dir, then retry once on the empty ledger\n}","preventionTips":["Run snapshot import only on a freshly created ledger","Make import steps idempotent in automation (check IsEmpty first)","Double-check ledgerID before importing to avoid hitting a live ledger","Document that incremental import is unsupported for config history"],"tags":["fabric","ledger","snapshot","config-history"],"backgroundTag":"snapshot-import-conflict","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}