-
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
liveness: allow registering callbacks after start #107265
Commits on Jul 24, 2023
-
kvserver: avoid implicit nils in TestReplicaLeaseCounters
The two removed fields are nil. This made a test failure during the refactors in this PR more annoying. If we're going to set up a half-inited NodeLiveness, let's at least be honest about it.
Configuration menu - View commit details
-
Copy full SHA for 7c2b6ea - Browse repository at this point
Copy the full SHA 7c2b6eaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 708435a - Browse repository at this point
Copy the full SHA 708435aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7d32c4f - Browse repository at this point
Copy the full SHA 7d32c4fView commit details -
liveness: rename storage -> storageImpl
We'll give this a proper interface soon.
Configuration menu - View commit details
-
Copy full SHA for 31b9ec4 - Browse repository at this point
Copy the full SHA 31b9ec4View commit details -
liveness: export storage methods
So that it can implement a public interface.
Configuration menu - View commit details
-
Copy full SHA for beb2c9b - Browse repository at this point
Copy the full SHA beb2c9bView commit details -
Configuration menu - View commit details
-
Copy full SHA for ea7cc94 - Browse repository at this point
Copy the full SHA ea7cc94View commit details -
liveness: export LivenessUpdate
It's needed to implement the liveness storage (once it exists).
Configuration menu - View commit details
-
Copy full SHA for 52792fc - Browse repository at this point
Copy the full SHA 52792fcView commit details -
We still want a Storage to be passed into NewNodeLiveness as opposed to a `*kv.DB`, but so far, so good.
Configuration menu - View commit details
-
Copy full SHA for ef8410e - Browse repository at this point
Copy the full SHA ef8410eView commit details -
liveness: finish adopting Storage
Now Liveness is constructed using a `Storage` as opposed to a `*kv.DB`.
Configuration menu - View commit details
-
Copy full SHA for f865176 - Browse repository at this point
Copy the full SHA f865176View commit details -
liveness: allow registering callbacks after start
I discovered[^1] a deadlock scenario when multiple nodes in the cluster restart with additional stores that need to be bootstrapped. In that case, liveness must be running when the StoreIDs are allocated, but it is not. Trying to address this problem, I realized that when an auxiliary Store is bootstrapped, it will create a new replicateQueue, which will register a new callback into NodeLiveness. But if liveness must be started at this point to fix cockroachdb#106706, we'll run into the assertion that checks that we don't register callbacks on a started node liveness. Something's got to give: we will allow registering callbacks at any given point in time, and they'll get an initial set of notifications synchronously. I audited the few users of RegisterCallback and this seems OK with all of them. [^1]: cockroachdb#106706 (comment) Epic: None Release note: None
Configuration menu - View commit details
-
Copy full SHA for f7e72f9 - Browse repository at this point
Copy the full SHA f7e72f9View commit details -
liveness: only call onSelfHeartbeat on self
I think there was a bug here. This method was previously invoked in `updateLiveness`, but that method is the general workhorse for updating anyone's liveness. In particular, it is called by `IncrementEpoch`. So we were invoking `onSelfHeartbeat` when we would increment other nodes' epochs. This doesn't seem great. Additionally, the code was trying to avoid invoking this callback before liveness was officially "started". Heartbeating yourself before liveness is started is unfortunately a thing due to the tangled start-up initialization sequence; we may see heartbeats triggered by lease requests. Avoid both complications by invoking `onSelfCallback` from the actual main heartbeat loop, whose only job is to heartbeat the own liveness record. I tried to adopt `TestNodeHeartbeatCallback` to give better coverage, but it's a yak shave. A deterministic node liveness (i.e. a way to invoke the main heartbeat loop manually) would make this a lot simpler. I filed an issue to that effect: cockroachdb#107452
Configuration menu - View commit details
-
Copy full SHA for 3bf63a6 - Browse repository at this point
Copy the full SHA 3bf63a6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4bf5865 - Browse repository at this point
Copy the full SHA 4bf5865View commit details -
liveness: add test for IsLiveCallback invocation
This tests that regardless of when a callback is registered, it gets called.
Configuration menu - View commit details
-
Copy full SHA for d767731 - Browse repository at this point
Copy the full SHA d767731View commit details