fix: sink events as they happen#24
Conversation
Replace per-row INSERT loops with multi-row INSERT batches so commits with several events hit SQLite once per batch instead of once per event. Co-authored-by: Cursor <cursoragent@cursor.com>
Reuse sqlite_es::insert_serialized_events_batch instead of issuing one INSERT per event from the event-sorcery repository wrapper. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reached
More reviews will be available in 48 minutes and 50 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
How to use the Graphite Merge QueueAdd the label add-to-gt-merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has required the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merge activity
|

Motivation
Inserting events one row at a time requires a separate round trip to SQLite for each event, which becomes a bottleneck when persisting many events in a single transaction. A batched approach is needed to reduce round trips and improve throughput.
Solution
INSERTloop with a newinsert_serialized_events_batchfunction that usessqlx::QueryBuilderto emit multi-rowINSERTstatements.insert_serialized_events_batchas a public function fromsqlite-esso thatevent-sorcerycan reuse it directly rather than duplicating the insertion logic.is_optimistic_lock_errorhelper and manual error mapping inevent-sorcerywith amap_sqlite_aggregate_errorfunction that convertsSqliteAggregateErrorvariants exhaustively intoSqliteEventRepositoryError.insert_eventquery builder method fromSqlQueryFactoryin favour of a newevents_tableaccessor that supplies the table name to the shared batch insert function.