{"record":{"id":"a8e4ce2c698ad47a","repo":"hyperledger/fabric","slug":"as-another-peer-node-command-is-executing-wait-fo-a8e4ce","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/reset.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// ResetAllKVLedgers resets all ledger to the genesis block.\nfunc ResetAllKVLedgers(rootFSPath string) 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 err\n\t}\n\tif len(ledgerIDs) > 0 {\n\t\treturn errors.Errorf(\"cannot reset channels because the peer contains channel(s) %s that were bootstrapped from snapshot\", ledgerIDs)\n\t}\n\n\tlogger.Info(\"Resetting all channel ledgers to genesis block\")\n\tlogger.Infof(\"Ledger data folder from config = [%s]\", rootFSPath)\n\tif err := dropDBs(rootFSPath); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/kvledger/reset.go#L2-L38","documentation":"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.","triggerScenarios":"Running 'peer node reset' while the peer is running or another admin command (rollback, rebuild-dbs, pause/resume) holds fileLock.","commonSituations":"Reset executed without stopping the peer first; automation scripts issuing reset and rollback in parallel; stale fileLock file after a crashed command.","solutions":["Stop the peer process before running 'peer node reset'.","Wait for or kill the other in-flight peer node command, then retry.","If a previous command crashed, confirm the lock is unheld (lsof) and delete the stale fileLock file in the peer's fileSystemPath.","Ensure only one peer uses this data directory at a time."],"exampleFix":"// before\npeer node start &\npeer node reset   # fails: another peer node command is executing\n// after: stop peer first\n# stop peer container/process\npeer node reset\npeer node start","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := ledger.ResetAllKVLedgers(rootFSPath); err != nil {\n\tif strings.Contains(err.Error(), \"another peer node command is executing\") {\n\t\t// peer still running or another admin command active; stop peer, then retry\n\t\treturn errWaitAndRetry\n\t}\n\treturn err\n}","preventionTips":["Always stop the peer before 'peer node reset'","Run reset commands serially; never combine with rollback/rebuild in parallel","Delete stale fileLock files only when no peer process exists","Backup ledgersData before reset — reset destroys all channel data to genesis"],"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"}