hyperledger/fabric · error

as another peer node command is executing, wait for that com

Error message

as another peer node command is executing, wait for that command to complete its execution or terminate it before retrying

What it means

RollbackKVLedger (used by 'peer node rollback') takes the exclusive ledger file lock before rolling a channel's ledger back to a target block number. If another ledger command holds the lock, the rollback aborts with this message. This serializes rollback with reset/rebuild/pause/resume operations.

Source

Thrown at core/ledger/kvledger/rollback.go:20

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package kvledger

import (
	"github.com/hyperledger/fabric/common/ledger/blkstorage"
	"github.com/hyperledger/fabric/common/ledger/util/leveldbhelper"
	"github.com/pkg/errors"
)

// RollbackKVLedger rollbacks a ledger to a specified block number
func RollbackKVLedger(rootFSPath, ledgerID string, blockNum uint64) 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 errors.WithMessage(err, "error while checking if any ledger has been bootstrapped from snapshot")
	}
	if len(ledgerIDs) > 0 {
		return errors.Errorf("cannot rollback any channel because the peer contains channel(s) %s that were bootstrapped from snapshot", ledgerIDs)
	}

	if err := blkstorage.ValidateRollbackParams(blockstorePath, ledgerID, blockNum); err != nil {
		return err
	}

	logger.Infof("Dropping databases")

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Stop the peer, then rerun 'peer node rollback'.
  2. Wait for or terminate the currently running peer node command holding the lock.
  3. After a crash, verify the lock is unheld (lsof on fileLock), remove the stale fileLock file, and retry.
  4. Run ledger admin commands strictly one at a time per data directory.
Defensive patterns

Strategy: retry

Try / catch

if err := ledger.RollbackKVLedger(rootFSPath, ledgerID, blockNum); err != nil {
	if strings.Contains(err.Error(), "another peer node command is executing") {
		// ensure the peer is fully stopped, then retry rollback
		return errStopPeerAndRetry
	}
	return err
}

Prevention

When it happens

Trigger: Running 'peer node rollback' while the peer is running or another admin command holds fileLock in the peer's fileSystemPath.

Common situations: Rolling back a channel during a fork/incident while the peer hasn't been fully stopped; incident-response scripts issuing multiple ledger commands concurrently; stale lock file from a killed command.

Related errors


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