(Requires Audit) PLEX-2473 LogPoller switch to batch inserts (Part 2)#356
Merged
dhaidashenko merged 11 commits intodevelopfrom Apr 24, 2026
Merged
(Requires Audit) PLEX-2473 LogPoller switch to batch inserts (Part 2)#356dhaidashenko merged 11 commits intodevelopfrom
dhaidashenko merged 11 commits intodevelopfrom
Conversation
Contributor
|
Krish-vemula
previously approved these changes
Feb 17, 2026
Unheilbar
reviewed
Feb 17, 2026
29ffcf3 to
ccc00f8
Compare
0833d36 to
715d9ba
Compare
jmank88
reviewed
Feb 26, 2026
jmank88
previously approved these changes
Feb 26, 2026
Base automatically changed from
feature/PLEX-2473-fix-reorg-handing-on-replay
to
develop
April 24, 2026 13:01
The base branch was changed.
# Conflicts: # pkg/logpoller/log_poller.go # pkg/logpoller/log_poller_test.go
Contributor
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the LogPoller batching work by enabling batch insertion of blocks (and logs+blocks together) to reduce DB I/O, and refactors unfinalized log processing to accumulate blocks/logs before persisting.
Changes:
- Replaced
InsertLogsWithBlockwithInsertLogsWithBlocks, addedInsertBlocks, and introduced a sharedbatchInserthelper for batched SQL inserts. - Refactored unfinalized polling to gather blocks/logs across a range and persist them in one call, with explicit reorg detection via a typed error.
- Updated and added tests to cover block batching and adjusted polling/reorg property tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/logpoller/orm.go | Adds batched block insert + generic batch insert helper; updates ORM API to accept multiple blocks. |
| pkg/logpoller/log_poller.go | Refactors unfinalized polling flow to collect blocks/logs and batch-persist; adds reorgError plumbing. |
| pkg/logpoller/observability.go | Updates observed ORM wrapper for the new insert API and block-count tracking. |
| pkg/logpoller/orm_test.go | Adds a block batching test and updates call sites for the new insert API. |
| pkg/logpoller/observability_test.go | Updates tests to call the new insert API. |
| pkg/logpoller/log_poller_test.go | Adjusts property test randomness and poll start block handling. |
| pkg/logpoller/helper_test.go | Updates canonical-hash assertions to compare via string formatting. |
Comments suppressed due to low confidence (1)
pkg/logpoller/orm.go:576
- InsertLogsWithBlocks currently allows inserting logs when blocks is empty (InsertBlocks becomes a no-op). This changes the old InsertLogsWithBlock contract (which always persisted the accompanying block) and can lead to logs existing without corresponding entries in log_poller_blocks, breaking confirmation-based queries and reorg detection. Consider returning an error when len(logs) > 0 && len(blocks) == 0, or documenting/enforcing the intended behavior.
func (o *DSORM) InsertLogsWithBlocks(ctx context.Context, logs []Log, blocks []Block) error {
// Optimization, don't open TX when there is only a block to be persisted
if len(logs) == 0 {
return o.InsertBlocks(ctx, blocks)
}
if err := o.validateLogs(logs); err != nil {
return err
}
// Block and logs goes with the same TX to ensure atomicity
return o.Transact(ctx, func(orm *DSORM) error {
err := orm.InsertBlocks(ctx, blocks)
if err != nil {
return err
}
return orm.insertLogsWithinTx(ctx, logs, orm.ds)
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fernandezlautaro
approved these changes
Apr 24, 2026
ilija42
approved these changes
Apr 24, 2026
dhaidashenko
added a commit
that referenced
this pull request
Apr 28, 2026
This reverts commit ffb14c0.
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.
Insert blocks and logs in batches to reduce DB IO usage.
Depends on: #355