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

Adding mutex locks in cache to prevent race conditions #185

Merged

Conversation

lucamrgs
Copy link
Collaborator

No description provided.

@lucamrgs lucamrgs linked an issue Jul 23, 2024 that may be closed by this pull request
@lucamrgs
Copy link
Collaborator Author

@MaartendeKruijf how do we test this?

@lucamrgs
Copy link
Collaborator Author

lucamrgs commented Aug 2, 2024

@MaartendeKruijf is this enough or should we do some more in-depth testing and such?

@MaartendeKruijf
Copy link
Collaborator

@lucamrgs let met check

@MaartendeKruijf MaartendeKruijf force-pushed the feature/184-prevent-reporter-race-conditions branch from 35a59ac to c0557a9 Compare August 2, 2024 09:26
@@ -85,7 +68,43 @@ func (cacheReporter *Cache) addExecution(newExecutionEntry cache_report.Executio
return nil
}

func (cacheReporter *Cache) GetExecutions() ([]cache_report.ExecutionEntry, error) {
cacheReporter.mutex.Lock()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would gaurd the most critical sections in getExecutions and addExecutions. Also then just use a go routine to let the decomposer not wait on any mutex.

@MaartendeKruijf MaartendeKruijf force-pushed the feature/184-prevent-reporter-race-conditions branch from eb52553 to 3b83bde Compare August 2, 2024 14:59
@lucamrgs lucamrgs marked this pull request as ready for review August 2, 2024 15:02
@lucamrgs
Copy link
Collaborator Author

lucamrgs commented Aug 8, 2024

@MaartendeKruijf both requested changes are implemented

@MaartendeKruijf MaartendeKruijf force-pushed the feature/184-prevent-reporter-race-conditions branch from 6317870 to 818cad4 Compare August 8, 2024 09:50

// Lock
cacheReporter.mutex.Lock()
for _, executionEntryKey := range cacheReporter.fifoRegister {
Copy link
Collaborator

Choose a reason for hiding this comment

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

user defer unlock if an error occurs the mutex will not be unlocked.

@MaartendeKruijf MaartendeKruijf merged commit cc5330e into development Aug 8, 2024
9 checks passed
@MaartendeKruijf MaartendeKruijf deleted the feature/184-prevent-reporter-race-conditions branch August 8, 2024 13:26
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.

prevent reporter race conditions
2 participants