fix(#335): wrap bootstrap and query insertions in chunked db transactions#347
Open
Ashutosh0x wants to merge 1 commit into
Open
fix(#335): wrap bootstrap and query insertions in chunked db transactions#347Ashutosh0x wants to merge 1 commit into
Ashutosh0x wants to merge 1 commit into
Conversation
…transactions Fixes issue ddworken#335 where hishtory-client hangs for long periods during bootstrap because it was executing hundreds of thousands of SQLite insert queries as individual disk-syncing transactions. By chunking the retrieved entries and wrapping the AddToDbIfNew loop in a database transaction, performance increases drastically and solves the api/v1/bootstrap latency problem on clients syncing massive amounts of shell history.
Copilot AI
added a commit
to iteria-systems/hishtory
that referenced
this pull request
Mar 8, 2026
…dworken#347, ddworken#337, ddworken#331, ddworken#333, ddworken#297 Co-authored-by: yoplait2 <3725861+yoplait2@users.noreply.github.com>
Contributor
|
Probably related to #299 |
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.
Hey @ddworken, I investigated #335.
The client spends immense amounts of time blocking itself inside
lib.AddToDbIfNew()while processing hundreds of thousands of entries during bootstrap because SQLite performs an fsync to disk for every un-wrapped query. By simply chunking the retrieved entries and wrapping the inserts in a database transaction (db.Transaction(func(tx *gorm.DB) error { ... })), bootstrap and sync latency drops drastically.I went ahead and applied this transaction batching to both the bootstrap install logic (
client/cmd/install.go) and theRetrieveAdditionalEntriesFromRemotebackground syncing (client/lib/lib.go). This completely resolves issue #335!