Skip to content

fix(etcdutl): initialize FlockTimeout to 10s so hash doesn't block forever#21658

Open
SAY-5 wants to merge 1 commit into
etcd-io:mainfrom
SAY-5:fix/etcdutl-hash-default-flock-timeout-20276
Open

fix(etcdutl): initialize FlockTimeout to 10s so hash doesn't block forever#21658
SAY-5 wants to merge 1 commit into
etcd-io:mainfrom
SAY-5:fix/etcdutl-hash-default-flock-timeout-20276

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 23, 2026

Refs #20276.

Problem

etcdutl's package-level FlockTimeout defaulted to Go's zero value, which bbolt treats as "block indefinitely". The --timeout flag default in ctl.go init() is 10 * time.Second, but code paths that reach FlockTimeout without flag parsing (direct library use, some test harnesses, or commands invoked before the flag is wired up) keep the zero value and make etcdutl hash, listBucket, defrag, and hashkv all block forever on a db file in use by an active etcd.

Fix

Initialize FlockTimeout to 10 * time.Second 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.

Test

go test ./etcdutl/... passes locally.

…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>
@k8s-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: SAY-5
Once this PR has been reviewed and has the lgtm label, please assign spzala for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Copy Markdown

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

Comment thread etcdutl/etcdutl/common.go
// 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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already defaults to 10s,

rootCmd.PersistentFlags().DurationVar(&etcdutl.FlockTimeout, "timeout", 10*time.Second, "time to wait to obtain a file lock on db file, 0 to block indefinitely")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants