fix(etcdutl): initialize FlockTimeout to 10s so hash doesn't block forever#21658
fix(etcdutl): initialize FlockTimeout to 10s so hash doesn't block forever#21658SAY-5 wants to merge 1 commit into
Conversation
…rever etcdutl's FlockTimeout package-level variable defaulted to Go's zero value (0), which bbolt treats as 'block indefinitely'. The --timeout flag default in ctl.go init() is 10s, but code paths that reach FlockTimeout without flag parsing — direct library use, some test harnesses, or commands invoked before the flag is wired — keep the zero value and make 'etcdutl hash' (and every other consumer of FlockTimeout) block forever on a db file that's in use by an active etcd process. Initialize FlockTimeout to 10s at the package level so the default never degrades. ctl.go's DurationVar continues to override it as before; tests and library callers now get the same sane default. Refs etcd-io/etcd issue 20276. Signed-off-by: SAY-5 <say.apm35@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: SAY-5 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @SAY-5. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| // Initialized to the ctl.go --timeout flag default so commands invoked | ||
| // through code paths that skip flag parsing (tests, library use) don't | ||
| // block forever on a locked db file. Issue 20276. | ||
| var FlockTimeout = 10 * time.Second |
Refs #20276.
Problem
etcdutl's package-levelFlockTimeoutdefaulted to Go's zero value, whichbbolttreats as "block indefinitely". The--timeoutflag default inctl.goinit()is10 * time.Second, but code paths that reachFlockTimeoutwithout flag parsing (direct library use, some test harnesses, or commands invoked before the flag is wired up) keep the zero value and makeetcdutl hash,listBucket,defrag, andhashkvall block forever on a db file in use by an active etcd.Fix
Initialize
FlockTimeoutto10 * time.Secondat the package level so the default never degrades.ctl.go'sDurationVarcontinues to override it as before; tests and library callers now get the same sane default.Test
go test ./etcdutl/...passes locally.