Skip to content

[IMPROVED] PurgeEx only loads within subject range#8004

Open
MauriceVanVeen wants to merge 1 commit intomainfrom
maurice/purge-ex-perf
Open

[IMPROVED] PurgeEx only loads within subject range#8004
MauriceVanVeen wants to merge 1 commit intomainfrom
maurice/purge-ex-perf

Conversation

@MauriceVanVeen
Copy link
Copy Markdown
Member

PurgeEx would loop over all blocks and load their subject state if it wasn't loaded already. For a multi-GB stream this would be very expensive, especially if the subject to be purged only exists in a very small subset of the stream.

For example, when using single-delayed scheduled messages, the schedule itself is purged after the delayed message is persisted. A schedule has a unique subject, so it will only exist once in the stream, in a single message block. When purging, we only need to load that single block and remove that subject from it, there's no need to load all blocks for such an operation.

Signed-off-by: Maurice van Veen github@mauricevanveen.com

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
@MauriceVanVeen MauriceVanVeen requested a review from a team as a code owner April 5, 2026 13:21
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b82ed778ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


// If literal subject check for presence.
if wc {
start = fs.lmb.index
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Guard wildcard purge when no message blocks exist

PurgeEx now unconditionally reads fs.lmb.index for wildcard filters, but fs.lmb can be nil when the store has been reset/truncated to zero blocks (for example Truncate(0) leaves numMsgBlocks()==0 in TestFileStoreStreamTruncateResetMultiBlock). In that state, calling PurgeEx with a wildcard subject (e.g. foo.*) will panic on nil dereference instead of returning 0,nil as before, so empty-stream wildcard purges become a crash path.

Useful? React with 👍 / 👎.

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.

1 participant