hyperledger/fabric · error

cannot rebuild databases because the peer contains channel(s

Error message

cannot rebuild databases because the peer contains channel(s) %s that were bootstrapped from snapshot

What it means

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.

Source

Thrown at core/ledger/kvledger/rebuild_dbs.go:35

// RebuildDBs drops existing ledger databases.
// Dropped database will be rebuilt upon server restart
func RebuildDBs(config *ledger.Config) error {
	rootFSPath := config.RootFSPath
	fileLockPath := fileLockPath(rootFSPath)
	fileLock := leveldbhelper.NewFileLock(fileLockPath)
	if err := fileLock.Lock(); err != nil {
		return errors.Wrap(err, "as another peer node command is executing,"+
			" wait for that command to complete its execution or terminate it before retrying")
	}
	defer fileLock.Unlock()

	blockstorePath := BlockStorePath(rootFSPath)
	ledgerIDs, err := blkstorage.GetLedgersBootstrappedFromSnapshot(blockstorePath)
	if err != nil {
		return errors.WithMessage(err, "error while checking if any ledger has been bootstrapped from snapshot")
	}
	if len(ledgerIDs) > 0 {
		return errors.Errorf("cannot rebuild databases because the peer contains channel(s) %s that were bootstrapped from snapshot", ledgerIDs)
	}

	if config.StateDBConfig.StateDatabase == ledger.CouchDB {
		if err := statecouchdb.DropApplicationDBs(config.StateDBConfig.CouchDB); err != nil {
			return err
		}
	}
	if err := dropDBs(rootFSPath); err != nil {
		return err
	}
	return blkstorage.DeleteBlockStoreIndex(blockstorePath)
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Do not run rebuild-dbs on this peer; snapshot-bootstrapped channels cannot be rebuilt this way.
  2. If a specific channel is healthy, no action is needed — rebuild-dbs is only for corrupted DBs.
  3. For a corrupted snapshot-joined channel, rejoin the channel from a newer snapshot instead of rebuilding.
  4. If some channels are genesis-bootstrapped, consider moving snapshot channels to a different peer, or removing those channels before rebuilding.

Example fix

// before
peer node rebuild-dbs
// Error: cannot rebuild databases because the peer contains channel(s) [mychannel] that were bootstrapped from snapshot
// after: rejoin from a fresh snapshot instead
peer node channel join --snapshot-file /var/snapshots/latest.snapshot
Defensive patterns

Strategy: validation

Validate before calling

// pre-check: does this peer host snapshot-bootstrapped channels?
func peerHasSnapshotLedgers(blockstorePath string) ([]string, error) {
	return blkstorage.GetLedgersBootstrappedFromSnapshot(blockstorePath)
}
// if len(ids) > 0 -> rebuild-dbs is not allowed; rejoin from snapshot instead

Try / catch

if err := ledger.RebuildDBs(config); err != nil {
	if strings.Contains(err.Error(), "bootstrapped from snapshot") {
		return fmt.Errorf("rebuild-dbs unsupported: rejoin affected channels from a newer snapshot: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Running 'peer node rebuild-dbs' on a peer that joined channel(s) via 'peer node snapshot' join (bootstrap-from-snapshot), detected via blkstorage.GetLedgersBootstrappedFromSnapshot.

Common situations: 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.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/8775e7bd1d7f1cbe. Report an issue: GitHub.