Files
seaweedfs/weed/wdclient
Chris LuandClaude Opus 5.5 39f568f614 wdclient: use a master only after it answers as the leader (#13415)
* wdclient: use a master only after it answers as the leader

Since the announce gate was added, every client marked a master as
current as soon as its KeepConnected stream opened, before the master
answered. When that master is a follower, its answer only names the
leader, but calls made in the meantime go to the follower, and
leader-only ones (lock, volume.list, collection.*, ...) fail with
"raft.Server: Not current leader". A weed shell fed a script runs its
first command right in that window.

Keep the early hand-out for clients behind an announce gate (a starting
filer), and let other clients wait for the first answer as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* wdclient: start the follower check only after it got the registration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* wdclient: hand out a master early only while the announce gate is closed

A filer that already announced and reconnects after a failover kept the
early hand-out, so calls waiting in GetMaster went to a follower that
had not answered yet and failed with "Not current leader".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* wdclient: stop handing out a master once it redirects to the leader

A filer that reached a follower behind its announce gate kept that
follower as the current master after the redirect, until the leader
answered, so leader-only calls in that window failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* wdclient: keep the redirecting master when canceled before the leader answers

Clearing the current master on a redirect left it empty if the client
was canceled before the hinted leader answered, so a later GetMaster
without a deadline blocked forever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 23:50:46 -08:00
..