[IMPROVED] PurgeEx only loads within subject range#8004
[IMPROVED] PurgeEx only loads within subject range#8004MauriceVanVeen wants to merge 1 commit intomainfrom
Conversation
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
There was a problem hiding this comment.
💡 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 |
There was a problem hiding this comment.
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 👍 / 👎.
PurgeExwould 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