-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server,kv: IsLive() does not check the Draining flag #45123
Comments
Confusing naming aside, a liveness record should be considered live even if it is draining. Take a look at this code: cockroach/pkg/storage/replica_range_lease.go Lines 346 to 352 in 6bf028c
We are allowed to increment the liveness record's epoch (i.e. kick it out) when it is non-live. This is essentially a hostile take-over reserved for cases in which the old leaseholder becomes unavailable. Doing this before the liveness is actually expired would do little more than disrupt the cluster by making sure nobody can serve requests until the lease is expired. Taking a step back, the problem is that many consumers of node liveness expect it to provide "liveness" in a more holistic sense, which it currently does not do. I think what we need to do here is to make everyone consume an API that deals in this enum: cockroach/pkg/storage/storagepb/liveness.pb.go Lines 32 to 47 in 1d76206
currently used in this randomly placed method cockroach/pkg/storage/store_pool.go Lines 134 to 153 in 1d76206
and also picked up in some http endpoints via Lines 1263 to 1273 in f1362c4
We should stop passing There could be a state Thanks for reminding me of the work to do here. The interfaces here are quite lacking, I hope my explanations make some sense. |
Beware of that enum. Call site after call site was using it wrong because there's too many states and different people care about different subsets, plus different timeout thresholds. I've corrected a few and in fact worked to reduce reliance on it in favor of more raw usage of the Liveness struct. |
@andreimatei can you give me some examples (not urgent)? You seem to have come to the opposite of my conclusion so we must have something to learn from each other. |
Well, just look at the diagram I put on It's been my experience that different people care about different things. For some draining makes a different, for other draining is irrelevant. Similarly, decomissioning might be relevant or not. Then there's the For examples of someone getting it wrong, see the commit msg on #43825 and #43873. And I feel like I've massaged others too. |
Also see for a fix I've made specifically to the call site that prompted this conversation, which was getting decommissioning wrong. #43889 |
66632: *: check node decommissioned/draining state for DistSQL/consistency r=tbg,knz a=erikgrinaker The DistSQL planner and consistency queue did not take the nodes' decommissioned or draining states into account, which in particular could cause spurious errors when interacting with decommissioned nodes. This patch adds convenience methods for checking node availability and draining states, and avoids scheduling DistSQL flows on unavailable nodes and consistency checks on unavailable/draining nodes. Touches #66586, touches #45123. Release note (bug fix): Avoid interacting with decommissioned nodes during DistSQL planning and consistency checking. /cc @cockroachdb/kv Co-authored-by: Erik Grinaker <[email protected]>
This issue may be moot now that #105572 is merged I think. |
The method
(*NodeLiveness).IsLive(nodeID)
does not check theDraining
flag.So it's possible for this to return "true" while a node is in the process of shutting down.
(Found this when looking at the
/health
RPC, which saysisHealthy := IsLive() && !Draining
)The
IsLive()
method is used in only the following two places (besides/health
):(q *consistencyQueue) shouldQueue()
(p *pendingLeaseRequest) requestLeaseAsync()
If my reading of the code is correct, this means that a node currently in the process of quitting (and thus getting read of its leases) can accept to start scanning ranges for consistency, and request leases for some leaderless range.
The latter in particular is probably undesirable: if the quitting node currently does not have a lease, and gets it and then does not release it on time when it finishes shutting down, some clients may experience a blip in latency.
It sounds to me like the
IsLive()
method should combine theDraining
flag in any case.cc @tbg can you check this? If yes I can issue the PR.
Jira issue: CRDB-5177
The text was updated successfully, but these errors were encountered: