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
RebuildDBs (used by 'peer node rebuild-dbs') first takes the exclusive ledger file lock before dropping and rebuilding state/index databases. If the lock is already held by another concurrent ledger command, the operation fails with this message. The file lock serializes all mutating peer node admin commands (pause/resume/reset/rollback/rebuild).
Source
Thrown at core/ledger/kvledger/rebuild_dbs.go:24
package kvledger
import (
"github.com/hyperledger/fabric/common/ledger/blkstorage"
"github.com/hyperledger/fabric/common/ledger/util/leveldbhelper"
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb"
"github.com/pkg/errors"
)
// 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
}
}View on GitHub (pinned to 2736b63f8f)
Solutions
- Stop the running peer / wait for the in-flight command to complete, then run rebuild-dbs again.
- Kill any lingering 'peer node' process that holds the lock.
- If a prior command crashed, verify no process holds <peer fs path>/fileLock (lsof), remove the stale lock file, and retry.
- Automate: always run admin commands serially against one peer data directory.
Defensive patterns
Strategy: retry
Validate before calling
// ensure peer is not running before rebuild-dbs
func peerIsRunning(pidFile string) bool {
data, err := os.ReadFile(pidFile)
if err != nil {
return false
}
pid, err := strconv.Atoi(strings.TrimSpace(string(data)))
if err != nil {
return false
}
return unix.Kill(pid, 0) == nil
} Try / catch
if err := ledger.RebuildDBs(config); err != nil {
if strings.Contains(err.Error(), "another peer node command is executing") {
// back off and retry once the peer is stopped
time.Sleep(retryInterval)
return retryRebuild()
}
return err
} Prevention
- Stop the peer container/process before rebuild-dbs
- Run admin commands from a single orchestration step, never concurrently
- Remove stale fileLock files only after confirming no live process holds them
- Document a strict ops runbook ordering for ledger maintenance commands
When it happens
Trigger: Running 'peer node rebuild-dbs' concurrently with any other peer node command (start, reset, rollback, pause/resume) that holds the fileLock file.
Common situations: Rebuild attempted while the peer process is still running; orchestration scripts launching rebuild and rollback together; a stale lock file left by a previously killed command.
Related errors
- as another peer node command is executing, wait for that com
- as another peer node command is executing, wait for that com
- as another peer node command is executing, wait for that com
- as another peer node command is executing, wait for that com
- as another peer node command is executing, wait for that com
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/04085126cd380cf4.
Report an issue: GitHub.