Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subject delete markers on purges and removes for filestore #6428

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

neilalexander
Copy link
Member

@neilalexander neilalexander commented Jan 29, 2025

This PR adds subject delete markers when doing purge/compact/remove operations for the filestore.

Memstore will be a separate PR but expect it to look a lot like this one.

Remaining questions before I mark for review:

  • Are we happy with the approach?
  • Does the name Nats-Applied-Limit make sense or do we want a more generic name like Nats-Marker-Reason?
  • ... or do we want a separate header for administrative reasons like Purge and Remove?

Signed-off-by: Neil Twigg neil@nats.io

server/filestore.go Outdated Show resolved Hide resolved
server/filestore.go Outdated Show resolved Hide resolved
@@ -4491,7 +4495,7 @@ func (fs *fileStore) removeMsg(seq uint64, secure, viaLimits, needFSLock bool) (

// If we are tracking multiple subjects here make sure we update that accounting.
mb.removeSeqPerSubject(sm.subj, seq)
fs.removePerSubject(sm.subj)
wasLast := fs.removePerSubject(sm.subj)
Copy link
Member

Choose a reason for hiding this comment

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

Since removePerSubject is fs scoped can just do this inside that function IMO..

Copy link
Member Author

Choose a reason for hiding this comment

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

I did try that, but there's a couple cases where it doesn't make sense, i.e. in expireMsgs and expireMsgsOnRecover, we want to first make sure that the deleted message isn't itself a delete marker (so that we don't end up making more of them endlessly), but we still need to do removePerSubject regardless.

Copy link
Member

Choose a reason for hiding this comment

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

But that can all be in removePerSubject() if we pass in bool yes that indicates if this is a marker?

Copy link
Member Author

Choose a reason for hiding this comment

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

Have updated it so we pass in a bool on whether or not to queue a marker.

server/filestore.go Outdated Show resolved Hide resolved
server/filestore.go Outdated Show resolved Hide resolved
@neilalexander neilalexander force-pushed the neil/purgemarkers branch 2 times, most recently from 1223b9b to b0ddc7d Compare January 30, 2025 11:29
@neilalexander
Copy link
Member Author

Have renamed the Nats-Applied-Limit header to Nats-Marker-Reason with @ripienaar's agreement so that it also makes sense for the "Purge" and "Remove" reasons.

@neilalexander neilalexander marked this pull request as ready for review January 30, 2025 15:25
@neilalexander neilalexander requested a review from a team as a code owner January 30, 2025 15:25
@derekcollison derekcollison self-requested a review January 30, 2025 15:27
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

In general LGTM -small question on possible perf issue for non-marker configured streams.

fs.subjectDeleteMarkerIfNeeded(sm, JSAppliedLimitMaxAge)
mb.mu.Lock()
}
fs.removePerSubject(sm.subj, len(getHeader(JSMarkerReason, sm.hdr)) == 0)
Copy link
Member

Choose a reason for hiding this comment

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

This a perf hit you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

It might be narrowly, so I've uplifted the config check up as you suggested.

server/filestore.go Outdated Show resolved Hide resolved
Signed-off-by: Neil Twigg <neil@nats.io>
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

LGTM

@derekcollison derekcollison merged commit 5fd5409 into main Jan 30, 2025
5 checks passed
@derekcollison derekcollison deleted the neil/purgemarkers branch January 30, 2025 16:14
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.

2 participants