-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Estimate replica lag when seconds behind from mysqld is unknown #9308
Conversation
c9663b1
to
c099f84
Compare
This prevents us from serving queries from the replica that may be beyond the defined -unhealthy_threshold for the tablet. Signed-off-by: Matt Lord <mattalord@gmail.com>
2a5ff82
to
36f3055
Compare
Signed-off-by: Matt Lord <mattalord@gmail.com>
36f3055
to
ef39eb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me.
I thought @aquarapid wanted us to add more error checking though..
39e29b0
to
8790643
Compare
This gives us the most accurate estimate possible -- and seconds_behind_master is already fuzzy anyway -- of the replica lag when the replica cannot talk to its source and is constantly retrying and in a state where Slave_IO_Running == Connecting which we consider to be equivalent to running (see parseReplicationStatus() in flavor.go) as reconnects happen regularly anyway e.g. due to slave_net_timeout. Signed-off-by: Matt Lord <mattalord@gmail.com>
8790643
to
c5143d8
Compare
b374c25
to
bcbe0b4
Compare
Signed-off-by: Matt Lord <mattalord@gmail.com>
bcbe0b4
to
31560fd
Compare
@deepthi, while I don't think that this PR as a stand-alone change warrants doc updates... after having gone through this I feel like we could probably use a new docs page on "Using Vitess for Read Scale Out" that documents how to do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have a heartbeat mechanism running in tablets. It's still not always-on, though I've advocated for it to be, and perhaps this is a good opportunity to revive that discussion.
We use the heartbeat value in the throttler service and in vreplication. I think we should explore reusing it here, too.
@shlomi-noach We did not add another mechanism here. Are you talking about something other than what I’m using in the PR? It’s the existing tablet healthcheck. If there’s another one then I’m not aware of it. Can you share details about what you’re referring to? |
@mattlord I misunderstood and thought there was a new functionality here. I think we might still want to first consult with our heartbeat mechanism. I don't know whether this PR should change right now, but I think ideally all our lag calculations should use the heartbeat, Examples:
Anyway, I think this digresses from the PR. LGTM and perhaps keep the discussion going 🙏 |
Hi @shlomi-noach ! (Please poke holes in anything that may be wrong.) Today we have the vttablet healthcheck stream that vtgates subscribe to which helps the gateway determine if the tablet should be serving queries or not. That is exposed to users via:
(vtgate exposes resulting info in The replication lag portion of that — at least the polling which we rely on for estimates when we don't get a value from mysqld — is enabled by default via We also have the heartbeat mechanism that IS NOT enabled by default but can be controlled via We then have a throttler interface that is NOT enabled by default but can be enabled in vttablet via
As a matter of principle, I would agree that we should consolidate these things to have a single shared mechanism for determining the key properties of a tablet: liveness, responsiveness & load (ability to handle more work in the immediate future), and consistency. Perhaps this is something we can discuss over dinner. I do, however, think it's orthogonal to this PR as this PR is a bug fix that is simply correcting behavior related to the healthcheck. Thanks! |
@mattlord agreed that this PR should proceed and no need to address hearbeat/throttler right now.
Agreed that this looks like quite a lot of configuration - though |
// replicationLagSeconds varies till 7200 so setting safe limit | ||
assert.True(t, replicationLagSeconds < 10000, "replica should not be behind primary") | ||
} else { | ||
assert.True(t, (!serving || replicationLagSeconds >= uint32(tabletUnhealthyThreshold.Seconds())), "Tablet should not be in serving and healthy state") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To help explain this assertion, as far as the healthcheck is concerned the tablet can be SERVING while unhealthy with regards to replica lag. For example:
vitess@fb5036c15bc9:/vt/local$ curl -s localhost:15101/debug/status_details
[
{
"Key": "Current State",
"Class": "healthy",
"Value": "REPLICA: Serving"
},
{
"Key": "Replication Lag",
"Class": "unhealthy",
"Value": "25s"
}
]
We have discussed this in the past, and I still think it is desirable to at least make the heartbeat the default. |
Description
When mysqld tells us that
seconds_behind_master
is unknown (NULL
) — or we get back any other value that cannot be converted to a uint — let's estimate the replication lag seconds value (seconds_behind_master
itself is fuzzy) in vttablet's healthcheck stats using the last seen value and the time elapsed since. This gives us the most accurate estimate possible of the replica lag when the replica cannot talk to its source and is constantly retrying and in a state whereSlave_IO_Running
==Connecting
, which we consider to be equivalent to running as reconnects happen regularly anyway e.g. due toslave_net_timeout
, and allows us to correctly support the defined-unhealthy_threshold
behavior for the replica tablet — preventing us from serving queries from a replica that may have very stale data.With these changes, the results of the test here seem to be expected and correct:
Related Issue(s)
Checklist