Skip to content

Philippe/jeb fixes medium severity#5

Merged
philippecamacho merged 6 commits intomainfrom
philippe/jeb-fixes-medium-severity
Apr 2, 2026
Merged

Philippe/jeb fixes medium severity#5
philippecamacho merged 6 commits intomainfrom
philippe/jeb-fixes-medium-severity

Conversation

@philippecamacho
Copy link
Copy Markdown
Contributor

@philippecamacho philippecamacho commented Mar 31, 2026

Closes https://app.asana.com/1/1208976916964769/project/1209976130071762/task/1213432243074587 and
https://app.asana.com/1/1208976916964769/project/1209976130071762/task/1213432243074595

This PR:

Bug fix — fallbackBatchPos initialization (NewEspressoStreamer):

fallbackBatchPos was incorrectly initialised to originBatchPos + 1, so a Reset() immediately after construction would advance BatchPos by an extra step. Fixed to originBatchPos (no +1), matching its documented semantics as "last safe batch".

Corresponds to ticket https://app.asana.com/1/1208976916964769/project/1209976130071762/task/1213432243074595

New test — TestResetAfterNewDoesNotSkipBatch:
Regression test for the fallbackBatchPos init bug — verifies BatchPos stays at originBatchPos + 1 after a Reset() immediately following construction.

Bug fix — off-by-one in skipPos rewind (fetchHotShotRange):

When a batch failed with ErrAtCapacity, skipPos was set to the range's start. After rewinding (hotShotPos = skipPos), the next scan computed start + 1, permanently skipping the batch at block start. Fixed by tracking the exact failing blockPos and recording skipPos = blockPos - 1, so the rewind correctly re-scans from blockPos.

Corresponds to ticket https://app.asana.com/1/1208976916964769/project/1209976130071762/task/1213432243074587

New test — rewind rescans the first block of the range where overflow began:
Regression test for the skipPos off-by-one — fills the buffer to exactly capacity, then places an overflow batch at the very first block of the next range. Verifies the batch is recoverable after the rewind.

Rename — namespaceRangeTransactions / namespaceTransaction:

Each element of the slice is a HotShot block (containing namespace transactions), not a transaction itself. Renamed to hotShotBlocks / namespaceBlock and updated the log key to numHotShotBlocks.

Key places to review:

Changes in op_streamer.go.

How to test this PR:

just test

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes a bug in the BatchStreamer where fallbackBatchPos was incorrectly initialized, causing Reset() to skip a batch. It also updates the skipPos logic to ensure that when the buffer is full, the streamer rewinds to the block immediately preceding the dropped batch, preventing data loss. Regression tests were added to verify the initialization fix and the rewind behavior. I have no feedback to provide.

@philippecamacho philippecamacho marked this pull request as ready for review April 1, 2026 15:11
@philippecamacho philippecamacho force-pushed the philippe/jeb-fixes-medium-severity branch from 0eed372 to 61ce29d Compare April 1, 2026 15:15
Copy link
Copy Markdown
Collaborator

@Sneh1999 Sneh1999 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Member

@Ayiga Ayiga left a comment

Choose a reason for hiding this comment

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

I was initially confused by the underflow protection code. But that was just me misreading it. (I think I was reading it as a variable assigning to itself, instead of the temporary variable)

Everything looks to be good to me.

(Be careful with committing those git diff artifacts :P)

@philippecamacho philippecamacho merged commit 3f8f8dc into main Apr 2, 2026
2 checks passed
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.

4 participants