-
Notifications
You must be signed in to change notification settings - Fork 644
Avoid races in system_tests changing config by making the changes atomic #3829
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
base: master
Are you sure you want to change the base?
Conversation
❌ 2 Tests Failed:
View the top 2 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
builder.nodeConfig.BatchPoster.MaxDelay = 0 | ||
builder.L2.ConsensusConfigFetcher.Set(builder.nodeConfig) |
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.
given that Set
always occurs in this pattern: (1) change config (2) set config, we might actually change the fetcher API from Set()
to Update(func (*T))
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.
for some reason git didnt post my reply to your comment! my bad.
Regarding Update instead of Set I think Set makes more sense like suggested in the ticket https://linear.app/offchain-labs/issue/NIT-3815/system-tests-avoid-races-for-tests-changing-config because what does Update even mean? does it mean we call func on the existing config var stored in the atomic pointer? realize that we arent using mutexs here (to make the process of changing configs fast and efficient we use atomic.Pointer) so changing that config basically means introducing race again.
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.
nah, the intention was to perform field reassignments on some temp copy and then use atomic.Pointer as we currently do
my motivation was to wrap the 2-instruction pattern within the fetcher API, but maybe it doesn't make that much sense here; waiving
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 maintain my suggestion about wrapping the pattern with Update
instead of Set
; wdyt @gligneul ?
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.
given that @gligneul agrees, I would convert my suggestion with change request - please convert this pattern:
config.field = value
actual_config.Set(config)
with
actual_config.Update(func (config) {
config.field = value
})
it should make us a bit safer
I dont know if you read my response here #3829 (comment), |
Previously system_tests used
NodeBuilder
'snodeConfig
andexecConfig
to create consensus and execution nodes directly, meaning if the test wanted to change any config fields- it would end up changing behavior of the nodes already started as well, sometimes unintentionally! As theNodeBuilder
's configs are to be used for building multiple nodes with different configurations.To facilitate this we introduce
commonConfigFetcher
that can take in both consensus and execution config- clone the config and store the new config atomically in its localatomic.Pointer
filed and return aConfigFetcher
interface implemented by both kinds of nodes. And tests planning to changing the config fields after the node has started should use respective configfetchers of consensus and execution nodes available in theTestClient
object to make changes and useSet()
method to update the configs atomically.Resolves NIT-3815