-
Notifications
You must be signed in to change notification settings - Fork 214
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
vfs: Fix the short read check in vfsWalRead #445
Conversation
Codecov Report
@@ Coverage Diff @@
## master #445 +/- ##
==========================================
+ Coverage 74.21% 74.33% +0.11%
==========================================
Files 32 32
Lines 5380 5381 +1
Branches 1682 1682
==========================================
+ Hits 3993 4000 +7
+ Misses 823 821 -2
+ Partials 564 560 -4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
One concern I had is that if a transaction is pending on one connection, other connections should definitely not be able to read uncommitted WAL data from that transaction; vfsWalRead itself doesn't have any checks around this, before or after this change. I think it should be taken care of by each connection having to hold the appropriate locks before trying to read from the WAL -- is that right? |
That's right, it's not a VFS concern. SQLite takes care of it by taking note of the highest committed WAL frame number at the time the transaction started, and never reading past it. |
Signed-off-by: Cole Miller <cole.miller@canonical.com>
Problem
When trying to read a page from the WAL, we bail early with an error if there are no committed pages in
struct vfsWal
. But sometimes a transaction will want to read its own WAL frames that haven't been committed yet, and this check will prevent that if the transaction starts out with an empty WAL (because it's running right after a checkpoint, for example).Solution
Remove the separate check for
w->n_frame == 0
and just see whethervfsWalFrameLookup
returnsNULL
, indicating that there's no frame at the given index.vfsWalFrameLookup
can retrieve frames from eitherw->frames
orw->tx
.Closes #432
Signed-off-by: Cole Miller cole.miller@canonical.com