-
Notifications
You must be signed in to change notification settings - Fork 334
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
Fix SQLite panic when syncing many UTXOs #1828
base: release/0.30
Are you sure you want to change the base?
Fix SQLite panic when syncing many UTXOs #1828
Conversation
Test completes without panic in ~58 mins.
|
b9866f6
to
2f81ffb
Compare
@@ -76,10 +76,8 @@ static MIGRATIONS: &[&str] = &[ | |||
/// [`crate::database`] | |||
#[derive(Debug)] | |||
pub struct SqliteDatabase { | |||
/// Path on the local filesystem to store the sqlite file | |||
pub path: PathBuf, |
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 removed this since it's no longer needed.
2f81ffb
to
9b46860
Compare
Rebased on release/0.30 branch. |
69d371e
to
f9636b7
Compare
The sync is still very slow, but that's due to how electrum syncing works. It requests complete histories for all addresses for every sync. To support these sort of very large UTXO wallets on a mobile device I think a protocol like CBF (kyoto) is the only way to do it. CBF syncs block by block, so once blocks with new TX are processed they don't get processed again. Down side of CBF is it doesn't check the mempool, but a way to combine CBF for committed TX and electrum or esplora to get unconfirmed mempool TX should work. |
I'm trying to run |
Just adding some info when pointing to this branch from bdk-ffi and building. I'm using a branch based on the That branch was pointing to I won't list every error because from what I can tell the errors all seem to stem from the same root cause of Rc not being Send + Sync, but definitely let me know if you'd like to me to follow up with them.
|
I'm replacing the |
3f467a1
to
f72d772
Compare
e894a3a
to
9c34453
Compare
I retested with the
I also verified
|
This prevents: Error { code: DatabaseBusy, extended_code: 5 }, Some("database is locked") which occured when syncing very large number of utxos. See: electrum::test::test_electrum_large_num_utxos
9c34453
to
eaafbde
Compare
You should be able to test it now. I think I forgot to check in some dependency fixes that were preventing the electrum tests from building. |
Description
fixes #1827
I wrapped the
SqliteDatabase
sqlite connection in anRc
so the same connection can be reused when a batch is started. This prevents a large sync from trying to start and commit a batch (db transaction) while the initial non-batch connection is still busy writing it's data.Notes to the reviewers
I had to comment out the
test_batch_script_pubkey()
test forsqlite
since the fix in this PR prevents a new sqlite DB connections from being created when a batch is started. In practice our sync'ing code does all its initial work without starting a batch (db transaction), then before finishing it starts a batch to do some cleanup work and commits it.Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingBugfixes: