Skip to content

batch event inserts to avoid SQLite bind variable limit#608

Merged
urvisavla merged 4 commits intorelease/v25.0.1from
fix-for-insert-events-error-from-v25-tag
Feb 20, 2026
Merged

batch event inserts to avoid SQLite bind variable limit#608
urvisavla merged 4 commits intorelease/v25.0.1from
fix-for-insert-events-error-from-v25-tag

Conversation

@karthikiyer56
Copy link
Contributor

A single Soroban transaction emitting >3,276 events would exceed SQLite's SQLITE_MAX_VARIABLE_NUMBER limit (32,767) since each event uses 10 bind variables in the INSERT statement. This caused crashes for transactions with ~4K events.

Batch insertableEvents into chunks of 1,000 per INSERT (10,000 bind variables) to stay well within the limit. All batches complete before InsertEvents returns.

Add TestInsertEventsBatchingExceedsLimit to verify a single transaction with 5,000 operation events inserts successfully.

A single Soroban transaction emitting >3,276 events would exceed
SQLite's SQLITE_MAX_VARIABLE_NUMBER limit (32,767) since each event
uses 10 bind variables in the INSERT statement. This caused crashes
for transactions with ~4K events.

Batch insertableEvents into chunks of 1,000 per INSERT (10,000 bind
variables) to stay well within the limit. All batches complete before
InsertEvents returns.

Add TestInsertEventsBatchingExceedsLimit to verify a single transaction
with 5,000 operation events inserts successfully.
Add TestInsertEventsBatchingExceedsLimit which creates a single
transaction with 5,000 operation events (5,003 total with tx-level
events), inserts, commits, reads back via GetEvents, and asserts
the exact count matches.

Also fix ledgerCloseMetaWithEvents helper to include a valid
TransactionResult so InsertLedger serialization succeeds.
…ounts

Cover 0, 1, 10, 1000, 3000, and 5000 op-level events to exercise
zero-event no-op, single batch, and multi-batch code paths in
InsertEvents. Each subtest inserts, commits, reads back via GetEvents,
and asserts the exact expected count (numOpEvents + 3 tx-level events).
@urvisavla urvisavla merged commit ccbc329 into release/v25.0.1 Feb 20, 2026
14 of 15 checks passed
@urvisavla urvisavla deleted the fix-for-insert-events-error-from-v25-tag branch February 20, 2026 22:02
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.

3 participants