etcd-io/etcd

lease comparison in txn bug

Open

#20773 opened on Oct 8, 2025

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Go (51,701 stars) (10,352 forks)batch import
help wantedstage/triagedtype/bug

Description

Bug report criteria

What happened?

When I try to execute a lease comparison in a transaction (txn), etcdctl returns the error "panic: bad value" in goroutine.

What did you expect to happen?

Initially, the database is empty. I put the key value {foo2: bar2} in the database, so I expected (replace <hostname> with your hostname):

$ etcdctl --endpoints=<hostname>:2379 txn <<<'lease("foo1") > "0"

get foo1

get foo2

'
FAILURE

foo2
bar2

How can we reproduce it (as minimally and precisely as possible)?

I started database with command (replace <hostname> with your hostname):

$ etcd --listen-client-urls http://<hostname>:2379 --advertise-client-urls http://<hostname>:2379 --log-level 'debug'

In fact, you don't even need to run the database, because there is an error on the client. Then I run:

$ etcdctl --endpoints=<hostname>:2379 txn <<<'lease("foo1") > "0"

get foo1

get foo2

'

Anything else we need to know?

I found a similar issue https://github.com/etcd-io/etcd/issues/14845 from three years ago, but it was closed, because an unsupported version was used in the bug report.

Etcd version (please run commands below)

$ etcd --version
etcd Version: 3.7.0-alpha.0
Git SHA: 438ed9693
Go Version: go1.25.1
Go OS/Arch: linux/amd64

$ etcdctl version
etcdctl version: 3.7.0-alpha.0
API version: 3.7

Etcd configuration (command line flags or environment variables)

No response

Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)

No response

Relevant log output

$ etcdctl --endpoints=<hostname>:2379 txn <<<'lease("foo1") > "0"               

get foo1

get foo2

'
panic: bad value

goroutine 1 [running]:
go.etcd.io/etcd/client/v3.mustInt64(...)
        go.etcd.io/etcd/client/v3/compare.go:132
go.etcd.io/etcd/client/v3.mustInt64orLeaseID(...)
        go.etcd.io/etcd/client/v3/compare.go:141
go.etcd.io/etcd/client/v3.Compare({0x1, 0x4, {0x0, 0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0, 0x0}, ...}, ...)
        go.etcd.io/etcd/client/v3/compare.go:66 +0x36c
go.etcd.io/etcd/etcdctl/v3/ctlv3/command.ParseCompare({0xc000154828, 0x13})
        go.etcd.io/etcd/etcdctl/v3/ctlv3/command/txn_command.go:225 +0x507
go.etcd.io/etcd/etcdctl/v3/ctlv3/command.readCompares(0xc000111c18)
        go.etcd.io/etcd/etcdctl/v3/ctlv3/command/txn_command.go:112 +0xc5
go.etcd.io/etcd/etcdctl/v3/ctlv3/command.txnCommandFunc(0xc0001ed808, {0xc0002f2dd0?, 0x4?, 0xd964e7?})
        go.etcd.io/etcd/etcdctl/v3/ctlv3/command/txn_command.go:79 +0x1e8
github.com/spf13/cobra.(*Command).execute(0xc0001ed808, {0xc0002f2db0, 0x1, 0x1})
        github.com/spf13/cobra@v1.10.1/command.go:1019 +0xae7
github.com/spf13/cobra.(*Command).ExecuteC(0x153bbc0)
        github.com/spf13/cobra@v1.10.1/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.10.1/command.go:1071
go.etcd.io/etcd/etcdctl/v3/ctlv3.Start(...)
        go.etcd.io/etcd/etcdctl/v3/ctlv3/ctl.go:121
go.etcd.io/etcd/etcdctl/v3/ctlv3.MustStart()
        go.etcd.io/etcd/etcdctl/v3/ctlv3/ctl.go:125 +0x1a
main.main()
        go.etcd.io/etcd/etcdctl/v3/main.go:23 +0xf

Contributor guide