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 the concurrency issues in removeObjectsOneByOne #78

Merged
merged 3 commits into from
Feb 12, 2024

Conversation

a-narsudinov
Copy link
Contributor

Hi there!

This PR fixes some obvious concurrency issues in function that tries to remove objects asynchronously:

  • goroutine variable capturing in for-loop
  • unsafe incrementing of counters

I had experienced some troubles with tests (minio server build failed, go 1.15 toolkit doesn't have cmd.Environ()) that is completely unrelated with my changes and as soon as I fixed it, everything worked fine.

This patch fixes classic golang for-loop variable capturing issue that
leeds to incorrect results in goroutines.

This is fixed in latest versions of golang, but this project uses go 1.15,
so it won't work as expected by an author.
Previous implementation didn't have any synchronization mechanism for
goroutines that does the work.

There are multiple approaches to make it work correctly, let's start with
the simplest - atomics.
I guess this is pretty reasonable to have the working queue with the same
size as the maximum number of workers.
@vitalif vitalif merged commit 700508e into yandex-cloud:master Feb 12, 2024
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