{"record":{"id":"8775e7bd1d7f1cbe","repo":"hyperledger/fabric","slug":"cannot-rebuild-databases-because-the-peer-contains","errorCode":null,"errorMessage":"cannot rebuild databases because the peer contains channel(s) %s that were bootstrapped from snapshot","messagePattern":"cannot rebuild databases because the peer contains channel\\(s\\) (.+?) that were bootstrapped from snapshot","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/ledger/kvledger/rebuild_dbs.go","lineNumber":35,"sourceCode":"// RebuildDBs drops existing ledger databases.\n// Dropped database will be rebuilt upon server restart\nfunc RebuildDBs(config *ledger.Config) error {\n\trootFSPath := config.RootFSPath\n\tfileLockPath := fileLockPath(rootFSPath)\n\tfileLock := leveldbhelper.NewFileLock(fileLockPath)\n\tif err := fileLock.Lock(); err != nil {\n\t\treturn errors.Wrap(err, \"as another peer node command is executing,\"+\n\t\t\t\" wait for that command to complete its execution or terminate it before retrying\")\n\t}\n\tdefer fileLock.Unlock()\n\n\tblockstorePath := BlockStorePath(rootFSPath)\n\tledgerIDs, err := blkstorage.GetLedgersBootstrappedFromSnapshot(blockstorePath)\n\tif err != nil {\n\t\treturn errors.WithMessage(err, \"error while checking if any ledger has been bootstrapped from snapshot\")\n\t}\n\tif len(ledgerIDs) > 0 {\n\t\treturn errors.Errorf(\"cannot rebuild databases because the peer contains channel(s) %s that were bootstrapped from snapshot\", ledgerIDs)\n\t}\n\n\tif config.StateDBConfig.StateDatabase == ledger.CouchDB {\n\t\tif err := statecouchdb.DropApplicationDBs(config.StateDBConfig.CouchDB); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := dropDBs(rootFSPath); err != nil {\n\t\treturn err\n\t}\n\treturn blkstorage.DeleteBlockStoreIndex(blockstorePath)\n}\n","sourceCodeStart":17,"sourceCodeEnd":48,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/kvledger/rebuild_dbs.go#L17-L48","documentation":"RebuildDBs refuses to rebuild databases when the peer's block store contains any ledger bootstrapped from a snapshot. Snapshot-bootstrapped ledgers have no genesis block to rebuild from, so dropping and reconstructing the databases would permanently break those channels, hence the hard error listing the offending ledger IDs.","triggerScenarios":"Running 'peer node rebuild-dbs' on a peer that joined channel(s) via 'peer node snapshot' join (bootstrap-from-snapshot), detected via blkstorage.GetLedgersBootstrappedFromSnapshot.","commonSituations":"Operator follows standard rebuild-dbs documentation without realizing the peer hosts snapshot-joined channels; mixed peers where some channels came from genesis and others from snapshots.","solutions":["Do not run rebuild-dbs on this peer; snapshot-bootstrapped channels cannot be rebuilt this way.","If a specific channel is healthy, no action is needed — rebuild-dbs is only for corrupted DBs.","For a corrupted snapshot-joined channel, rejoin the channel from a newer snapshot instead of rebuilding.","If some channels are genesis-bootstrapped, consider moving snapshot channels to a different peer, or removing those channels before rebuilding."],"exampleFix":"// before\npeer node rebuild-dbs\n// Error: cannot rebuild databases because the peer contains channel(s) [mychannel] that were bootstrapped from snapshot\n// after: rejoin from a fresh snapshot instead\npeer node channel join --snapshot-file /var/snapshots/latest.snapshot","handlingStrategy":"validation","validationCode":"// pre-check: does this peer host snapshot-bootstrapped channels?\nfunc peerHasSnapshotLedgers(blockstorePath string) ([]string, error) {\n\treturn blkstorage.GetLedgersBootstrappedFromSnapshot(blockstorePath)\n}\n// if len(ids) > 0 -> rebuild-dbs is not allowed; rejoin from snapshot instead","typeGuard":null,"tryCatchPattern":"if err := ledger.RebuildDBs(config); err != nil {\n\tif strings.Contains(err.Error(), \"bootstrapped from snapshot\") {\n\t\treturn fmt.Errorf(\"rebuild-dbs unsupported: rejoin affected channels from a newer snapshot: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Track which channels on each peer were joined from snapshots","Never run blanket rebuild-dbs across peers with snapshot-joined channels","Keep recent snapshots available so a damaged snapshot channel can be rejoined","Separate snapshot-joined production channels from disposable test peers"],"tags":["hyperledger-fabric","snapshot","rebuild-dbs","unsupported-operation"],"backgroundTag":"snapshot-bootstrap-unsupported","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"}