Skip to content

fix(#335): wrap bootstrap and query insertions in chunked db transactions#347

Open
Ashutosh0x wants to merge 1 commit into
ddworken:masterfrom
Ashutosh0x:fix/bootstrap-hang
Open

fix(#335): wrap bootstrap and query insertions in chunked db transactions#347
Ashutosh0x wants to merge 1 commit into
ddworken:masterfrom
Ashutosh0x:fix/bootstrap-hang

Conversation

@Ashutosh0x

Copy link
Copy Markdown

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 the RetrieveAdditionalEntriesFromRemote background syncing (client/lib/lib.go). This completely resolves issue #335!

…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

@GRbit GRbit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GRbit

GRbit commented May 3, 2026

Copy link
Copy Markdown
Contributor

Probably related to #299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants