疯狂报错:7709 leaderelection

环境信息:
K3s 版本: v1.34.2+k3s1

节点 CPU 架构、操作系统和版本:: x86-64、Ubuntu 24.04.3 LTS

集群配置:

3 servers
问题描述:

日志一直刷:7709 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io “k3s”: the object has been modified; please apply your changes to the latest version and try again, falling back to slow path

复现步骤:

  • 安装 K3s 的命令:
    第一台server
    INSTALL_K3S_SKIP_DOWNLOAD=true
    K3S_TOKEN=domino
    INSTALL_K3S_EXEC=“server
    –node-name k3s-server01
    –node-ip=192.168.0.111
    –system-default-registry 192.168.0.108:80
    –cluster-init
    –tls-san=192.168.0.111
    –tls-san=192.168.0.112
    –tls-san=192.168.0.113
    –tls-san=192.168.0.200
    –tls-san=domino.local
    –flannel-iface=ens33”
    ./install.sh

第二台server:
INSTALL_K3S_SKIP_DOWNLOAD=true
K3S_TOKEN=domino
INSTALL_K3S_EXEC=“server
–node-name k3s-server02
–node-ip=192.168.0.112
–system-default-registry 192.168.0.108:80
–server https://192.168.0.111:6443
–tls-san=192.168.0.111
–tls-san=192.168.0.112
–tls-san=192.168.0.113
–tls-san=192.168.0.200
–tls-san=domino.local
–flannel-iface=ens33”
./install.sh

第三台server:
INSTALL_K3S_SKIP_DOWNLOAD=true
K3S_TOKEN=domino
INSTALL_K3S_EXEC=“server
–node-name k3s-server03
–node-ip=192.168.0.113
–system-default-registry 192.168.0.108:80
–server https://192.168.0.111:6443
–tls-san=192.168.0.111
–tls-san=192.168.0.112
–tls-san=192.168.0.113
–tls-san=192.168.0.200
–tls-san=domino.local
–flannel-iface=ens33”
./install.sh

预期结果:

实际结果:

从第二台server启动开始后台就开始一直打印:7709 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io “k3s”: the object has been modified; please apply your changes to the latest version and try again, falling back to slow path

附加上下文/日志:

日志
Jan 31 16:59:16 umore k3s[7709]: E0131 16:59:16.212540    7709 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io "k3s": the object has been modified; please apply your changes to the latest version and try again, falling back to slow path
Jan 31 16:59:16 umore k3s[7709]: E0131 16:59:16.548456    7709 leaderelection.go:484] Failed to update lock: Operation cannot be fulfilled on leases.coordination.k8s.io "k3s": the object has been modified; please apply your changes to the latest version and try again
Jan 31 16:59:16 umore k3s[7709]: time="2026-01-31T16:59:16Z" level=info msg="Slow SQL (started: 2026-01-31 16:59:15.580117023 +0000 UTC m=+1715.357961927) (total time: 1.112248089s):  SELECT ( SELECT MAX(rkv.id) AS id FROM kine AS rkv), ( SELECT MAX(crkv.prev_revision) AS prev_revision FROM kine AS crkv WHERE crkv.name = 'compact_rev_key'), kv.id AS theid, kv.name AS thename, kv.created, kv.deleted, kv.create_revision, kv.prev_revision, kv.lease, kv.value, kv.old_value FROM kine AS kv WHERE kv.name LIKE ? AND kv.id > ? ORDER BY kv.id ASC LIMIT 500" duration=1.112248089s
Jan 31 16:59:18 umore k3s[7709]: E0131 16:59:18.211161    7709 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io "k3s": the object has been modified; please apply your changes to the latest version and try again, falling back to slow path
Jan 31 16:59:20 umore k3s[7709]: E0131 16:59:20.329938    7709 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io "k3s": the object has been modified; please apply your changes to the latest version and try again, falling back to slow path
Jan 31 16:59:22 umore k3s[7709]: E0131 16:59:22.450342    7709 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io "k3s": the object has been modified; please apply your changes to the latest version and try again, falling back to slow path
Jan 31 16:59:23 umore k3s[7709]: E0131 16:59:23.695830    7709 controller.go:195] "Failed to update lease" err="Operation cannot be fulfilled on leases.coordination.k8s.io \"apiserver-vvjfwqxhbe4brkx7cdpjl6qire\": the object has been modified; please apply your changes to the latest version and try again"
Jan 31 16:59:24 umore k3s[7709]: E0131 16:59:24.566092    7709 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io "k3s": the object has been modified; please apply your changes to the latest version and try again, falling back to slow path


感觉跟数据库应该关系,我一开始没指定数据库,应该用的是etcd也有类似的错误。在我将 k3s-server02 和 k3s-server03 加入集群之前,k3s-server01 是否已经作为单节点集群在运行,并且日志是正常的。
k3s-server01 在 k3s-server02 加入后开始报错。
重启三个节点的k3s服务了,依然报错:Jan 31 15:07:06 umore k3s[16954]: E0131 15:07:06.824922 16954 controller.go:195] “Failed to update lease” err=“Operation cannot be fulfilled on leases.coordination.k8s.io "apiserver-vvjfwqxhbe4brkx7cdpjl6qire": the object has been modified; please apply your changes to the latest version and try again”
Jan 31 15:07:07 umore k3s[16954]: E0131 15:07:07.010773 16954 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io “k3s”: the object has been modified; please apply your changes to the latest version and try again, falling back to slow path
Jan 31 15:07:07 umore k3s[16954]: E0131 15:07:07.012948 16954 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io “k3s-etcd”: the object has been modified; please apply your changes to the latest version and try again, falling back to slow path
Jan 31 15:07:09 umore k3s[16954]: E0131 15:07:09.033731 16954 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io “k3s”: the object has been modified; please apply your changes to the latest version and try again, falling back to slow path
Jan 31 15:07:09 umore k3s[16954]: E0131 15:07:09.042566 16954 leaderelection.go:441] Failed to update lock optimistically: Operation cannot be fulfilled on leases.coordination.k8s.io “k3s-etcd”: the object has been modified; please apply your changes to the latest version and try again, falling back to slow path