-
Notifications
You must be signed in to change notification settings - Fork 2.3k
vtorc: enable read_uncommitted when in sqlite shared-cache mode
#18658
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
base: main
Are you sure you want to change the base?
vtorc: enable read_uncommitted when in sqlite shared-cache mode
#18658
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
|
Signed-off-by: Tim Vaillancourt <[email protected]>
e277b58 to
d810ccd
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18658 +/- ##
==========================================
+ Coverage 67.50% 67.53% +0.02%
==========================================
Files 1607 1613 +6
Lines 263567 263796 +229
==========================================
+ Hits 177931 178163 +232
+ Misses 85636 85633 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
vtorc: enable read_committed when in sqlite shared-cache modevtorc: enable read_uncommitted when in sqlite shared-cache mode
shlomi-noach
left a comment
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.
I find it difficult to gauge the risk of this change. We'd need a thorough review of our queries/statements and see whether we at all use multi-statement transactions. If not, then any query is a transaction, and read_uncommitted is safe.
@shlomi-noach agreed, this is a hard one to review I've done some tim@mac vitess % git grep Begin go/vt/vtorc
go/vt/vtorc/db/db.go: tx, err := db.Begin()There are cases where many instances are written at the same time, but this is done using a multi-insert that |
|
Why would we use read_uncommitted rather than read_committed? |
@mattlord sqlite3 can only support |
mattlord
left a comment
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.
- I don't believe there's any doubt that this introduces some future risk — even if no danger is present today. We should understand the actual performance benefit this offers in practice so that we are able to do a proper cost/benefit analysis. Do you have any details regarding the performance benefits a user could expect?
- The shared-cache mode appears to be marked as obsolete/deprecated and its use is NOT recommended: https://www.sqlite.org/sharedcache.html
- Can you elaborate on why we're ignoring the SQLite authors' recommendations here?
- They instead recommend WAL mode. On a quick read, that seems to offer the benefits of the shared-cache mode and more AND without the potential danger of using
read-uncommitted(you should update the PR description as it saysread-committed). Why would we not move to WAL mode by default instead (it's "server mode", which is perfect forvtorc), if we're not already? Why would we want to supportshared-cachemode at all given all of this? What am I missing 🙂
Description
This PR causes VTOrc to use a
READ-COMMITTEDtransaction isolation when running in shared-cache mode, which is what VTOrc does by defaultWhy? The default isolation level of sqlite3 is
SERIALIZABLE, which has a major impact on concurrency of both reads and writes. VTOrc reads and writes data from the same sqlite3 tables concurrently. After the VTOrc performance tunings for concurrency (many-1000s of tablets per instance), the main bottleneck showing up in profiles is the sqlite3 golang library itselfA change to
READ-COMMITTEDshould reduce some overhead in the sqlite3 library and allow reads to occur without blocking on writes. Aside from CI passing, I believe this change is safe because the only explicitBEGIN/COMMITtransaction in VTOrc happens during init time, before the isolation level is set and any data is read or written. There are cases where many instances are written at once, however this is always done in a single mulit-INSERT/REPLACE INTO, never explicit transactions that could introduce consistency risks when paired withREAD-COMMITTEDRelated Issue(s)
Checklist
Deployment Notes