-
Notifications
You must be signed in to change notification settings - Fork 374
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
slow sync and big script_pubkeys table (sqlite) #801
Comments
I think I found the issue, can you test with the linked PR and see if you can still reproduce? The PR is still missing the code to clean up existing databases, so please start fresh and see if the slowdown is still there. |
running the same test (20 sends with 5 recipients) on the PR branch yields a small constant slowdown, consistent with the first send operations, and no issue on the sqlite db. also tried sending more times with more recipients and there was no sign of the reported issue looks fixed to me, thanks for the quick response |
b5fcddc Add sqlite migration to drop duplicated script_pubkeys rows (Steve Myers) 21c96c9 Add test for issue #801 (Alekos Filini) c51d544 [wip] Ensure there are no duplicated script_pubkeys in sqlite (Alekos Filini) Pull request description: ### Description Add a `UNIQUE` constraint on the script_pubkeys table so that it doesn't grow constantly when caching new addresses. Fixes #801 ### Notes to the reviewers Adding it to the 0.25 milestone since it's just a bugfix. Still in draft because I need to add extra migration queries to clean up existing dbs. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### Bugfixes: * [ ] This pull request breaks the existing API * [x] I've added tests to reproduce the issue which are now passing * [x] I'm linking the issue being fixed by this PR ACKs for top commit: notmandatory: ACK b5fcddc Tree-SHA512: 7b10e453bb38af5c4f80f77692a56e37259680e50f9c2c9e554a0e5f04fb9cab897da6476c6c9930f1c501b455472984a1c92c4f137cff49acdc390d2e705107
Add a `UNIQUE` constraint on the script_pubkeys table so that it doesn't grow constantly when caching new addresses. Fixes bitcoindevkit#801
Describe the bug
wallet sync gets slow and the script_pubkeys (sqlite) db table grows in size
To Reproduce
looks like the situation is reproducible from scratch in a regtest environment by creating a new wallet and performing a series of send operations. I was able to see a progressive slowdown by sending 20 times to the wallet itself, with 5 recipients each time
Expected behavior
wallet sync should complete in relatively short amounts of time and db size should stay relatively small
Build environment
Additional context
a project using bdk became very slow after running for some time. the bdk sync time went up to ~5h (on a VPS with a fast Internet connection, remote electrum server also on a fast VPS) and the sqlite db file had grown to ~500MB. the service had operated for a few weeks and had performed a relatively small number of wallet operations, having sent ~130 transactions and currently having ~60 UTXOs
almost all the space in the db is taken by the
scripts_pubkeys
table, as deleting all records and vacuuming gives a ~200kb db filechecking the entries in the
script_pubkeys
db table gives:trying to reproduce the issue (20x send with 5 recipients) I got the following db situation (same queries as above):
The text was updated successfully, but these errors were encountered: