Skip to content
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

client/metadata: fix crasher caused by AllowStale = false #16549

Merged
merged 4 commits into from
Mar 20, 2023

Conversation

schmichael
Copy link
Member

@schmichael schmichael commented Mar 17, 2023

Fixes #16517

Given a 3 Server cluster with at least 1 Client connected to Follower 1:

If a NodeMeta.{Apply,Read} for the Client request is received by Follower 1 with AllowStale = false the Follower will forward the request to the Leader.

The Leader, not being connected to the target Client, will forward the RPC to Follower 1.

Follower 1, seeing AllowStale=false, will forward the request to the Leader.

The Leader, not being connected to... well hoppefully you get the picture: an infinite loop occurs.

Manually testing looks good, but automated testing is still WIP.

Update: I'm pretty pleased with how the manual test turned out! It's pretty big but reliably exercises the bug without the patch. With the fix the test runs in <400ms locally which isn't bad for running 7 agents and waiting for each one to become ready!

If you're feeling brave (or like watching the world burn), you can exercise the bug by commenting out one of the AllowStale = true lines and running the test with go test -v -run NodeMeta in the nomad/ directory.

I highly recommend doing that in a container or VM so you don't mess up your machine. I used:

docker run --memory 4000m --oom-score-adj 500 --mount type=bind,source="$(pwd)",target=/nomad -ti golang:1.20.2
apt update
apt install iproute2  # required by clients
cd /nomad
go install -buildvcs=false # keep go/git from complaining
cd /nomad/nomad
go test -v -run NodeMeta

# takes 120s for my machine to fail the test, but leader elections start happening far sooner

Fixes #16517

Given a 3 Server cluster with at least 1 Client connected to Follower 1:

If a NodeMeta.{Apply,Read} for the Client request is received by
Follower 1 with `AllowStale = false` the Follower will forward the
request to the Leader.

The Leader, not being connected to the target Client, will forward the
RPC to Follower 1.

Follower 1, seeing AllowStale=false, will forward the request to the
Leader.

The Leader, not being connected to... well hoppefully you get the
picture: an infinite loop occurs.
Copy link
Contributor

@lgfa29 lgfa29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor question, but I don't think it's actually a problem 👍

Comment on lines -151 to -153
//
// BREAKING: This method will have the following signature in 1.6.0
// func (a *Allocations) Restart(allocID string, taskName string, allTasks bool, w *WriteOptions) (*WriteMeta, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mystery solved I guess 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't believe how many hints we were given that this would happen. I know I even hit it in the e2e cluster at least once but couldn't reproduce it and just assumed it was some terrible thing I had done to my e2e cluster.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chesterton's Fence!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had never heard of that before and love it!

nomad/structs/node.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.5.x backport to 1.5.x release line theme/crash
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updating Node Metadata causes cluster failure
3 participants