-
Notifications
You must be signed in to change notification settings - Fork 257
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
height_consistency constraint blocking sync when code updates two columns independently #1611
Comments
And incidentally, I can't see what value bringing in the librustzcash/zcash_client_sqlite/src/wallet.rs Lines 2329 to 2333 in 8b49ca8
Why not simplify it to just this: "UPDATE transactions
SET block = :height
WHERE txid = :txid", Which then becomes trivial to join with the other query for one atomic operation: "UPDATE transactions
SET mined_height = :height, block = :height
WHERE txid = :txid", |
I also note that the |
The invariant of the The wallet may know about a transaction and the block that it was mined in without having scanned that block. The problem here isn't with the database constraints; it's a bug somewhere in the assumptions about the database state at the time that this update is being performed. The constraints are guarding against database corruption, and thereby revealing this bug, but they're not the source of the problem. |
This just hit two of my wallets again. I'm forced to delete the database and recover from seed phrase. And I can only hope that does the trick for a while. |
When a transaction is to be updated for the block it is actually mined in, this code executes:
librustzcash/zcash_client_sqlite/src/wallet.rs
Lines 2313 to 2338 in 8b49ca8
Notice how two distinct SQL statements are executed, one per column to be updated.
But this creates a constraint violations in the
transactions
table, which requires thatblock
andmined_height
be in sync:In the repro, a user's wallet in unable to sync beyond a particular block number because this violation fires and breaks storing any more transactions in the db.
The new block # being set is just +1 of what is already there. Both
block
andmined_height
columns are set to n in the transaction table, and in this code, theheight
parameter that is being applied to the db is n + 1.Maybe there is a bug here in that both columns were set to n in the first place, where if the value wasn't final, perhaps
mined_height
shouldn't have been set. Or maybe a re-org changed the mined height such that it needed to be set again.It seems to me that this code should be more resilient, by updating both columns atomically so as to not upset the table constraint.
The text was updated successfully, but these errors were encountered: