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

vfs: Fix the short read check in vfsWalRead #445

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

cole-miller
Copy link
Contributor

@cole-miller cole-miller commented Dec 6, 2022

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 whether vfsWalFrameLookup returns NULL, indicating that there's no frame at the given index. vfsWalFrameLookup can retrieve frames from either w->frames or w->tx.

Closes #432

Signed-off-by: Cole Miller cole.miller@canonical.com

@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #445 (f9802d0) into master (50ee9af) will increase coverage by 0.11%.
The diff coverage is 33.33%.

@@            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     
Impacted Files Coverage Δ
src/vfs.c 83.97% <33.33%> (+0.20%) ⬆️
src/transport.c 69.93% <0.00%> (+0.65%) ⬆️
src/lib/transport.c 91.42% <0.00%> (+1.90%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@cole-miller cole-miller marked this pull request as ready for review December 6, 2022 19:19
@cole-miller
Copy link
Contributor Author

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?

@freeekanayaka
Copy link
Contributor

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>
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.

row size limit? getting "Error: disk I/O error" from dqlite-demo
3 participants