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(scheduler): fix data race #2085

Merged

Conversation

eusebiu-constantin-petu-dbk
Copy link
Collaborator

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

andaaron
andaaron previously approved these changes Nov 28, 2023
Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (79e1402) 92.00% compared to head (8b0b567) 92.06%.

Files Patch % Lines
pkg/api/cookiestore.go 0.00% 3 Missing ⚠️
pkg/cli/server/config_reloader.go 90.90% 0 Missing and 1 partial ⚠️
pkg/cli/server/root.go 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2085      +/-   ##
==========================================
+ Coverage   92.00%   92.06%   +0.06%     
==========================================
  Files         165      165              
  Lines       28687    28681       -6     
==========================================
+ Hits        26394    26406      +12     
+ Misses       1697     1678      -19     
- Partials      596      597       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eusebiu-constantin-petu-dbk eusebiu-constantin-petu-dbk force-pushed the fix_scheduler_data_race branch 2 times, most recently from 23063eb to bfb9204 Compare December 5, 2023 13:03
@eusebiu-constantin-petu-dbk eusebiu-constantin-petu-dbk marked this pull request as ready for review December 5, 2023 13:54
andaaron
andaaron previously approved these changes Dec 5, 2023
Copy link
Contributor

@andaaron andaaron left a comment

Choose a reason for hiding this comment

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

LGTM

Andreea-Lupu
Andreea-Lupu previously approved these changes Dec 5, 2023
Copy link
Contributor

@Andreea-Lupu Andreea-Lupu left a comment

Choose a reason for hiding this comment

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

lgtm

adodon2go
adodon2go previously approved these changes Dec 5, 2023
andaaron
andaaron previously approved these changes Dec 5, 2023
@eusebiu-constantin-petu-dbk eusebiu-constantin-petu-dbk force-pushed the fix_scheduler_data_race branch 2 times, most recently from 71e977e to d86e4a1 Compare December 5, 2023 17:13
andaaron
andaaron previously approved these changes Dec 5, 2023
andaaron
andaaron previously approved these changes Dec 5, 2023
pkg/scheduler/scheduler.go Outdated Show resolved Hide resolved
pkg/storage/s3/s3_test.go Show resolved Hide resolved
the problem here is that scheduler can be closed in two ways:
- canceling the context given as argument to scheduler.RunScheduler()
- running scheduler.Shutdown()

because of this shutdown can trigger a data race between calling scheduler.inShutdown()
and actually pushing tasks into the pool workers

solved that by keeping a quit channel and listening on both quit channel and ctx.Done()
and closing the worker chan and scheduler afterwards.

Signed-off-by: Petu Eusebiu <[email protected]>
@eusebiu-constantin-petu-dbk eusebiu-constantin-petu-dbk force-pushed the fix_scheduler_data_race branch 2 times, most recently from a123456 to f3f8e4f Compare December 8, 2023 12:07
before this we could stop scheduler either by closing the context
provided to RunScheduler(ctx) or by running Shutdown().

simplify things by getting rid of the external context in RunScheduler().
keep an internal context in the scheduler itself and pass it down to all tasks.

Signed-off-by: Petu Eusebiu <[email protected]>
@rchincha rchincha merged commit 7642e5a into project-zot:main Dec 11, 2023
32 of 33 checks passed
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.

5 participants