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

wrap memdb methods to return Copy instead of any #23682

Open
tgross opened this issue Jul 24, 2024 · 0 comments
Open

wrap memdb methods to return Copy instead of any #23682

tgross opened this issue Jul 24, 2024 · 0 comments

Comments

@tgross
Copy link
Member

tgross commented Jul 24, 2024

The Nomad state store architecture guide describes an important constraint on state store methods:

Every object you read from the state store must be copied before it can be mutated, because mutating the object modifies it outside the raft workflow. The result can be servers having inconsistent state, transactions breaking, or even server panics.

Unfortunately this is hard to statically enforce reliably except over "short distances" in the code. This kind of problem is called "taint analysis". We've done hack projects like #16257 to try to detect these bugs, but the results are currently still very buggy. So we're forced to rely on thorough code review, and even that sometimes fails and we get bugs like #23673

This bug has two parts:

  1. The struct was missing the Copy method
  2. And therefore we didn't call the Copy method

@Juanadelacuesta has suggested in an internal discussion that we could wrap state store methods such that they return Copy interface (Copier? Copyable?) rather than any. That would at least prevent problem 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant