-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
vtorc
: use golang.org/x/sync/semaphore
, add flag for db concurrency
#17837
vtorc
: use golang.org/x/sync/semaphore
, add flag for db concurrency
#17837
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
vtorc
: use golang.org/x/sync/semaphore, add flag for db concurrencyvtorc
: use golang.org/x/sync/semaphore
, add flag for db concurrency
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17837 +/- ##
==========================================
+ Coverage 67.45% 67.47% +0.02%
==========================================
Files 1592 1593 +1
Lines 258167 258903 +736
==========================================
+ Hits 174143 174702 +559
- Misses 84024 84201 +177 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Tim Vaillancourt <[email protected]>
0fbc78e
to
0edc405
Compare
ctx, cancel := context.WithTimeout(context.Background(), maxBackendOpTime) | ||
defer cancel() | ||
|
||
if err := instanceWriteSem.Acquire(ctx, 1); err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't have a test before, but maybe its worth adding one to check that these concurrency controls are respected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GuptaManan100 sounds good 👍
I've been optimizing code as I come across it lately and only now I see ExecDBWriteFunc
is used only in a handful of write operations and instanceReadChan
/instanceReadSem
is never used
So some more cleanup is needed. Do we want all reads/writes to respect a limit? And considering a majority of reads/writes in VTOrc aren't respecting a limit, do we need one? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine too, but if we want to make all the read and write calls acqurie this lock too, then that would technically be more correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GuptaManan100 I'm torn, I suspect this semaphore made more sense when the backend was remote and not in-memory
For sqlite3 there is a single writer so I think it already will constrain concurrency, so potentially only a read limit will be useful 🤔
I merged this PR too soon when I saw it had 2 x reviews, but I can follow up with whatever we decide
Signed-off-by: Tim Vaillancourt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement!
Description
This PR migrates the concurrency control for VTOrc's backend to use
golang.org/x/sync/semaphore
and a flag is added to control the limitRelated Issue(s)
#17330
Checklist
Deployment Notes