hyperledger/fabric · error

cannot reset channels because the peer contains channel(s) %

Error message

cannot reset channels because the peer contains channel(s) %s that were bootstrapped from snapshot

What it means

ResetAllKVLedgers refuses to reset the peer when any ledger was bootstrapped from a snapshot. Reset restores channels to their genesis block, but snapshot-bootstrapped channels have no genesis block locally, so resetting would destroy them irrecoverably. The error lists the offending channel IDs.

Source

Thrown at core/ledger/kvledger/reset.go:31

)

// ResetAllKVLedgers resets all ledger to the genesis block.
func ResetAllKVLedgers(rootFSPath string) error {
	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 err
	}
	if len(ledgerIDs) > 0 {
		return errors.Errorf("cannot reset channels because the peer contains channel(s) %s that were bootstrapped from snapshot", ledgerIDs)
	}

	logger.Info("Resetting all channel ledgers to genesis block")
	logger.Infof("Ledger data folder from config = [%s]", rootFSPath)
	if err := dropDBs(rootFSPath); err != nil {
		return err
	}
	if err := resetBlockStorage(rootFSPath); err != nil {
		return err
	}
	logger.Info("All channel ledgers have been successfully reset to the genesis block")
	return nil
}

// LoadPreResetHeight returns the prereset height for the specified ledgers.
func LoadPreResetHeight(rootFSPath string, ledgerIDs []string) (map[string]uint64, error) {
	blockstorePath := BlockStorePath(rootFSPath)
	logger.Infof("Loading prereset height from path [%s]", blockstorePath)

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Do not reset this peer; snapshot-joined channels cannot be restored afterward.
  2. If you truly need to remove a snapshot-joined channel, rejoin from a newer snapshot afterward — never rely on reset.
  3. Remove only genesis-bootstrapped channels' data or use a different peer for resettable test data.
  4. Back up the entire ledgersData directory before attempting any destructive command.
Defensive patterns

Strategy: validation

Validate before calling

// pre-check before reset
ids, err := blkstorage.GetLedgersBootstrappedFromSnapshot(blkstorage.BlockStorePath(rootFSPath))
if err != nil {
	return err
}
if len(ids) > 0 {
	return fmt.Errorf("reset not allowed; snapshot-bootstrapped channels present: %v", ids)
}

Try / catch

if err := ledger.ResetAllKVLedgers(rootFSPath); err != nil {
	if strings.Contains(err.Error(), "bootstrapped from snapshot") {
		// do not force; plan rejoin-from-snapshot for those channels
		return fmt.Errorf("use snapshot rejoin instead of reset: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Running 'peer node reset' on a peer with channels joined via snapshot (detected by blkstorage.GetLedgersBootstrappedFromSnapshot returning a non-empty list).

Common situations: Trying to reclaim disk space or clear test data on a peer that was joined to a production channel via snapshot; blanket reset scripts applied across heterogeneous peers.

Related errors


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