-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Assert getRepositoryData only on master node #67780
Assert getRepositoryData only on master node #67780
Conversation
A trap for the uninitiated: only the master should be calling `getRepositoryData()`, but today this isn't checked anywhere so there's a risk that we inadvertently introduce some code that gets the repository data on other nodes too. This commit introduces an assertion to catch that.
Pinging @elastic/es-distributed (Team:Distributed) |
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 the idea, but I'm not sure we can do it this easily
// consistency guarantees there, but electedness is too ephemeral to assert. We can say for sure that this node should be | ||
// master-eligible, which is almost as strong since all other snapshot-related activity happens on data nodes whether they be | ||
// master-eligible or not. | ||
assert clusterService.localNode().isMasterNode() : "should only load repository data on master nodes"; |
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.
I thought about adding it like this, but I'm a little afraid we could see some tripped assertions in tests here. It's conceivable (albeit very improbable) that we failed over to another master just before calling this method isn't it? (I could definitely see SnapshotResiliencyTests
trip this pretty easily)
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.
That's why we assert we're master-eligible and not the elected master.
The code comment echoes what you said, and justifies why this is almost as strong as the real thing.
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.
LGTM 🤦 I should learn to read better sorry!
A trap for the uninitiated: only the master should be calling `getRepositoryData()`, but today this isn't checked anywhere so there's a risk that we inadvertently introduce some code that gets the repository data on other nodes too. This commit introduces an assertion to catch that.
A trap for the uninitiated: only the master should be calling `getRepositoryData()`, but today this isn't checked anywhere so there's a risk that we inadvertently introduce some code that gets the repository data on other nodes too. This commit introduces an assertion to catch that. Second attempt at elastic#67780 which was reverted due to test failures.
A trap for the uninitiated: only the master should be calling `getRepositoryData()`, but today this isn't checked anywhere so there's a risk that we inadvertently introduce some code that gets the repository data on other nodes too. This commit introduces an assertion to catch that. Second attempt at #67780 which was reverted due to test failures.
A trap for the uninitiated: only the master should be calling `getRepositoryData()`, but today this isn't checked anywhere so there's a risk that we inadvertently introduce some code that gets the repository data on other nodes too. This commit introduces an assertion to catch that. Second attempt at #67780 which was reverted due to test failures.
A trap for the uninitiated: only the master should be calling
getRepositoryData()
, but today this isn't checked anywhere so there'sa risk that we inadvertently introduce some code that gets the
repository data on other nodes too. This commit introduces an assertion
to catch that.