{"record":{"id":"8cc8664a2bba80d9","repo":"hyperledger/fabric","slug":"as-another-peer-node-command-is-executing-wait-fo-8cc866","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/pause_resume.go","lineNumber":36,"sourceCode":"\t\treturn err\n\t}\n\tlogger.Infof(\"The channel [%s] has been successfully paused\", ledgerID)\n\treturn nil\n}\n\n// ResumeChannel updates the channel status to active in ledgerProviders\nfunc ResumeChannel(rootFSPath, ledgerID string) error {\n\tif err := pauseOrResumeChannel(rootFSPath, ledgerID, msgs.Status_ACTIVE); err != nil {\n\t\treturn err\n\t}\n\tlogger.Infof(\"The channel [%s] has been successfully resumed\", ledgerID)\n\treturn nil\n}\n\nfunc pauseOrResumeChannel(rootFSPath, ledgerID string, status msgs.Status) error {\n\tfileLock := leveldbhelper.NewFileLock(fileLockPath(rootFSPath))\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\tidStore, err := openIDStore(LedgerProviderPath(rootFSPath))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer idStore.db.Close()\n\treturn idStore.updateLedgerStatus(ledgerID, status)\n}\n","sourceCodeStart":18,"sourceCodeEnd":48,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/kvledger/pause_resume.go#L18-L48","documentation":"pauseOrResumeChannel (used by 'peer node pause-channel' and 'resume-channel') acquires an exclusive file lock (fileLock under the peer's fileLockPath) before mutating ledger state. If the lock is already held — by a concurrent pause/resume/reset/rollback/rebuild command or by a stale lock from a crashed process — the lock acquisition fails and the command aborts with this message.","triggerScenarios":"Running 'peer node pause-channel' or 'peer node resume-channel' while another ledger-mutating peer command holds the file lock in <peer fs path>/fileLock.","commonSituations":"Running two peer node admin commands in parallel (e.g. in parallel CI steps or scripts); a previous command crashed without releasing the lock leaving a stale lock file; two peers mistakenly configured with the same fileSystemPath.","solutions":["Wait for the currently executing peer node command to finish, then retry your command.","Find and terminate the other peer node command process (ps/pgrep for 'peer node').","If the process crashed, confirm nothing holds the lock (lsof on the fileLock file), then delete the stale fileLock file under the peer's fileSystemPath and retry.","Ensure only one peer process is configured to use this data directory."],"exampleFix":"// before: parallel commands conflict\npeer node pause-channel mychannel &\npeer node resume-channel mychannel   # fails with lock error\n// after: serialize them\npeer node pause-channel mychannel\npeer node resume-channel mychannel","handlingStrategy":"retry","validationCode":"// before running pause/resume, verify no other peer command holds the lock\nfunc lockIsFree(rootFSPath string) bool {\n\tf, err := os.OpenFile(filepath.Join(rootFSPath, \"fileLock\"), os.O_RDWR, 0o600)\n\tif err != nil {\n\t\treturn false\n\t}\n\tdefer f.Close()\n\treturn unix.Flock(int(f.Fd()), unix.LOCK_EX|unix.LOCK_NB) == nil\n}","typeGuard":null,"tryCatchPattern":"err := pauseOrResumeChannelWithRetry(rootFSPath, ledgerID, status)\nif err != nil && strings.Contains(err.Error(), \"another peer node command is executing\") {\n\t// wait and retry; do NOT delete the lock while a process may be alive\n\treturn fmt.Errorf(\"retry after the running peer node command completes: %w\", err)\n}","preventionTips":["Serialize all peer node admin commands in scripts (no parallel runs)","Always stop the peer before running pause/resume/reset/rollback/rebuild","Clean up crashed command processes before retrying","Never point two peers at the same fileSystemPath"],"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"}