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 when batch.Reset. Fix #1460 #1461

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lunny
Copy link

@lunny lunny commented Sep 8, 2020

This PR will try to fix the data race described on #1460.

When invoking Batch, a goroutine will be ruined and will read batch.IndexOps. Meanwhile, the user may call batch.Reset immediately which will clear batch.IndexOps. The PR will copy the point of the map to the goroutine but not read it directly to avoid the datarace.

@mschoch
Copy link
Contributor

mschoch commented Sep 8, 2020

The comment in this fix suggests that the API is being used incorrectly. We do not support resetting a batch until after batch execution is complete, at which time copying that slice is not required.

Can we start with a unit test that you think contains valid use of the API that fails the race dectector?

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.

2 participants