fix(persistence): avoid hitting SQLite limits when doing blocks and transactions bulk storage#3045
Merged
Merged
Conversation
…place query definition" This reverts commit 6bed07f. There's still more works to do for this refactor to take fruit: We needs to be able to provide part of the sql query after `Query::get_definition` as we only know after this call the number of rows to binds when doing insert or update.
* mithril-persistence from `0.2.64` to `0.2.65`
Test Results 5 files ±0 172 suites ±0 43m 44s ⏱️ -3s Results for commit afd4b4e. ± Comparison against base commit 22d3580. This pull request removes 1 and adds 2 tests. Note that renamed tests count towards both. |
Alenar
temporarily deployed
to
testing-preview
February 24, 2026 09:49 — with
GitHub Actions
Inactive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Content
This PR fixes an error raised while doing blocks and transactions bulk storage because we hits the SQLite binding limits.
In SQLite we can't bind more than 32 766 items per prepared queries, but for blocks and especially transactions insertion we needs to insert millions rows in the import process, making it possible to hits those limits when inserting a range of blocks that have a large number of transactions.
This PR fix the issue by chunking the transactions insert per batches of 10 000 as each stored transactions needs to bind 2 fields, so this means binding 20 000 maximum, far below the limit.
Note
This branch commits include a preliminary work to solve those issue at our persistence API level instead of doing it per repository method.
As the work could not be complete in a small time it have been reverted but it's a good start.
What miss is a rework of
Query::get_definitionin order to make it returns a type that can be used to change the produced SQL or to provide it as a parameter.This is needed because
get_definitioncurrently don't know how much fields must be bind when doing insert or update and the sql must provide the arguments (with(?, ? , ?)for each row, one?for each column).Pre-submit checklist
Issue(s)
Closes #3028