{"record":{"id":"0cb74dfec1b79985","repo":"hyperledger/fabric","slug":"as-another-peer-node-command-is-executing-wait-fo-0cb74d","errorCode":null,"errorMessage":"as another peer node command is executing, wait for that command to complete its execution or terminate it before retrying","messagePattern":"as another peer node command is executing, wait for that command to complete its execution or terminate it before retrying","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/ledger/kvledger/rollback.go","lineNumber":20,"sourceCode":"Copyright IBM Corp. All Rights Reserved.\n\nSPDX-License-Identifier: Apache-2.0\n*/\n\npackage kvledger\n\nimport (\n\t\"github.com/hyperledger/fabric/common/ledger/blkstorage\"\n\t\"github.com/hyperledger/fabric/common/ledger/util/leveldbhelper\"\n\t\"github.com/pkg/errors\"\n)\n\n// RollbackKVLedger rollbacks a ledger to a specified block number\nfunc RollbackKVLedger(rootFSPath, ledgerID string, blockNum uint64) error {\n\tfileLockPath := fileLockPath(rootFSPath)\n\tfileLock := leveldbhelper.NewFileLock(fileLockPath)\n\tif err := fileLock.Lock(); err != nil {\n\t\treturn errors.Wrap(err, \"as another peer node command is executing,\"+\n\t\t\t\" wait for that command to complete its execution or terminate it before retrying\")\n\t}\n\tdefer fileLock.Unlock()\n\n\tblockstorePath := BlockStorePath(rootFSPath)\n\tledgerIDs, err := blkstorage.GetLedgersBootstrappedFromSnapshot(blockstorePath)\n\tif err != nil {\n\t\treturn errors.WithMessage(err, \"error while checking if any ledger has been bootstrapped from snapshot\")\n\t}\n\tif len(ledgerIDs) > 0 {\n\t\treturn errors.Errorf(\"cannot rollback any channel because the peer contains channel(s) %s that were bootstrapped from snapshot\", ledgerIDs)\n\t}\n\n\tif err := blkstorage.ValidateRollbackParams(blockstorePath, ledgerID, blockNum); err != nil {\n\t\treturn err\n\t}\n\n\tlogger.Infof(\"Dropping databases\")","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/kvledger/rollback.go#L2-L38","documentation":"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.","triggerScenarios":"Running 'peer node rollback' while the peer is running or another admin command holds fileLock in the peer's fileSystemPath.","commonSituations":"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.","solutions":["Stop the peer, then rerun 'peer node rollback'.","Wait for or terminate the currently running peer node command holding the lock.","After a crash, verify the lock is unheld (lsof on fileLock), remove the stale fileLock file, and retry.","Run ledger admin commands strictly one at a time per data directory."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := ledger.RollbackKVLedger(rootFSPath, ledgerID, blockNum); err != nil {\n\tif strings.Contains(err.Error(), \"another peer node command is executing\") {\n\t\t// ensure the peer is fully stopped, then retry rollback\n\t\treturn errStopPeerAndRetry\n\t}\n\treturn err\n}","preventionTips":["Fully stop the peer (verify process exit) before rollback","Run rollback alone — never concurrently with reset/rebuild","In incident runbooks, add explicit lock-acquisition retries with backoff","Clear stale fileLock only after lsof confirms no holder"],"tags":["hyperledger-fabric","file-lock","concurrency"],"backgroundTag":"file-lock-contention","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}