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

Address potential Persistent Settings Getters race. #3095

Merged
merged 1 commit into from
May 9, 2024

Conversation

briantting
Copy link
Contributor

@briantting briantting commented Apr 26, 2024

While Getters and SetterHelpers both use locks to prevent race
conditions, Setters do not. Given that Setters run SetterHelpers through
posted tasks, it is possible for Getters to run in-between Setters and
SetterHelpers causing a race condition. To resolve this, effectively add
Getters into the PostTask Queue by calling WaitForFence. Also refactor
GetValues calls so that they are run by Setters rather than Getters to
limit the number of deep copies made.

Now that Getters and Setters no longer race, massively clean up the
tests by removing the unwieldly and now unneeded closures.

b/305057554

@briantting
Copy link
Contributor Author

Copy link
Member

@jellefoks jellefoks left a comment

Choose a reason for hiding this comment

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

Nice!

@gbournou gbournou removed their request for review May 1, 2024 17:40
@aee-google
Copy link
Contributor

@briantting, I took another look at PersistentSettings. I think part of the problem is most of the methods are not respecting the blocking argument. I had an idea on cleaning up PersistentSettings. Is it okay if I push a change to the PR? I'm attaching the diff.

PersistentSettings.txt

@briantting
Copy link
Contributor Author

@briantting, I took another look at PersistentSettings. I think part of the problem is most of the methods are not respecting the blocking argument. I had an idea on cleaning up PersistentSettings. Is it okay if I push a change to the PR? I'm attaching the diff.

PersistentSettings.txt

I don't think we want the blocking argument at all, we don't want anything to wait on disk writes. That was a quirk that was added purely so we could run tests and should no longer be needed with this refactor.

@aee-google
Copy link
Contributor

@briantting I've gotten rid of the blocking arguments.

PersistentSettings.txt

aee-google added a commit to aee-google/cobalt that referenced this pull request May 6, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 6, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
While Getters and SetterHelpers both use locks to prevent race
conditions, Setters do not. Given that Setters run SetterHelpers through
posted tasks, it is possible for Getters to run in-between Setters and
SetterHelpers causing a race condition. To resolve this, effectively add
Getters into the PostTask Queue by calling WaitForFence. Also refactor
GetValues calls so that they are run by Setters rather than Getters to
limit the number of deep copies made.

Now that Getters and Setters no longer race, massively clean up the
tests by removing the unwieldly and now unneeded closures.

b/305057554
@briantting briantting merged commit feba187 into youtube:main May 9, 2024
306 of 308 checks passed
@briantting briantting added the cp-25.lts.1+ Cherry Pick to the 25.lts.1+ branch label May 10, 2024
cobalt-github-releaser-bot pushed a commit that referenced this pull request May 10, 2024
While Getters and SetterHelpers both use locks to prevent race
conditions, Setters do not. Given that Setters run SetterHelpers through
posted tasks, it is possible for Getters to run in-between Setters and
SetterHelpers causing a race condition. To resolve this, effectively add
Getters into the PostTask Queue by calling WaitForFence. Also refactor
GetValues calls so that they are run by Setters rather than Getters to
limit the number of deep copies made.

Now that Getters and Setters no longer race, massively clean up the
tests by removing the unwieldly and now unneeded closures.

b/305057554

(cherry picked from commit feba187)
briantting added a commit that referenced this pull request May 10, 2024
…ace. (#3213)

Refer to the original PR: #3095

While Getters and SetterHelpers both use locks to prevent race
conditions, Setters do not. Given that Setters run SetterHelpers through
posted tasks, it is possible for Getters to run in-between Setters and
SetterHelpers causing a race condition. To resolve this, effectively add
Getters into the PostTask Queue by calling WaitForFence. Also refactor
GetValues calls so that they are run by Setters rather than Getters to
limit the number of deep copies made.

Now that Getters and Setters no longer race, massively clean up the
tests by removing the unwieldly and now unneeded closures.

b/305057554

Co-authored-by: Brian Ting <[email protected]>
aee-google added a commit to aee-google/cobalt that referenced this pull request May 10, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 10, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 10, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 16, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 17, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 17, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 17, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 24, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 24, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit to aee-google/cobalt that referenced this pull request May 24, 2024
Building off the work of @briantting:
youtube#3095

b/305057554
aee-google added a commit that referenced this pull request May 24, 2024
Building off the work of @briantting:
#3095

b/305057554
cobalt-github-releaser-bot pushed a commit that referenced this pull request Jun 10, 2024
Building off the work of @briantting:
#3095

b/305057554

(cherry picked from commit aeaed9d)
kaidokert pushed a commit that referenced this pull request Jun 11, 2024
Refer to the original PR: #3173

Building off the work of @briantting:
#3095

b/305057554

Co-authored-by: aee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cp-25.lts.1+ Cherry Pick to the 25.lts.1+ branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants