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

ResetAllKVLedgers (used by 'peer node reset') acquires the shared ledger file lock before resetting all channels to their genesis blocks. If another ledger-mutating command holds the lock, acquisition fails and reset aborts with this message. The lock prevents concurrent reset/rollback/rebuild/pause operations from corrupting shared ledger data.

Source

Thrown at core/ledger/kvledger/reset.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"
)

// 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
	}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Stop the peer process before running 'peer node reset'.
  2. Wait for or kill the other in-flight peer node command, then retry.
  3. If a previous command crashed, confirm the lock is unheld (lsof) and delete the stale fileLock file in the peer's fileSystemPath.
  4. Ensure only one peer uses this data directory at a time.

Example fix

// before
peer node start &
peer node reset   # fails: another peer node command is executing
// after: stop peer first
# stop peer container/process
peer node reset
peer node start
Defensive patterns

Strategy: retry

Try / catch

if err := ledger.ResetAllKVLedgers(rootFSPath); err != nil {
	if strings.Contains(err.Error(), "another peer node command is executing") {
		// peer still running or another admin command active; stop peer, then retry
		return errWaitAndRetry
	}
	return err
}

Prevention

When it happens

Trigger: Running 'peer node reset' while the peer is running or another admin command (rollback, rebuild-dbs, pause/resume) holds fileLock.

Common situations: Reset executed without stopping the peer first; automation scripts issuing reset and rollback in parallel; stale fileLock file after a crashed command.

Related errors


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