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

Fix data race (accessing charmInfo) in TestV2CharmExitsApplicationWorker #13211

Merged
merged 1 commit into from
Aug 4, 2021

Conversation

benhoyt
Copy link
Contributor

@benhoyt benhoyt commented Aug 3, 2021

This fixes a data race accessing the charmInfo returned by the mocked ApplicationCharmInfo function. This was happening because we synchronize by waiting for the ApplicationCharmInfo call itself, but then write to charmInfo straight away, and the charmFormat() function may not be finished reading it yet, causing a data race.

The fix removes the first call to ApplicationCharmInfo in the application worker (there's no need to call it twice), and then waits for the main worker's Life() call to synchronize and know when the worker has definitely finished the charmFormat() call before changing charmInfo fields.

See go test -race ./worker/caasunitprovisioner/ output here.

Copy link
Member

@hpidcock hpidcock left a comment

Choose a reason for hiding this comment

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

LGTM thank-you

@benhoyt
Copy link
Contributor Author

benhoyt commented Aug 4, 2021

$$merge$$

@jujubot jujubot merged commit 5c9bdad into juju:2.9 Aug 4, 2021
@benhoyt benhoyt deleted the fix-caasunitprovisioner-race branch August 4, 2021 00:44
@wallyworld wallyworld mentioned this pull request Aug 6, 2021
jujubot added a commit that referenced this pull request Aug 8, 2021
#13220

Merge 2.9

#13211 Fix data race (accessing charmInfo) in TestV2CharmExitsApplicationWorker
#13212 Fix retry-provisioning command
#13210 Add note and todo
#13209 Improve readablity of 'no prdesc not found' error message
#13214 Adds remaining authorization objects to ignore
#13215 Use a key-based mutex lock to download resources/agent bins once
#13218 Show application data set by the remote app in show-unit output
#13219 Add impish to the ubuntu series list

Trivial conflicts in imports/code comments.

```
Conflicts:
# apiserver/facades/client/client/client.go
# apiserver/facades/schema.json
# resource/resourceadapters/opener.go
```
## QA steps

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

Successfully merging this pull request may close these issues.

3 participants