-
Notifications
You must be signed in to change notification settings - Fork 142
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
fix: delete all but last #847
Changes from 1 commit
ff47283
b891431
22955b1
39684aa
46b526e
01d5d32
4bcab6b
05ea6f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,10 +69,10 @@ class JournalQueries( | |
JournalTable.filter(_.persistenceId === persistenceId).filter(_.sequenceNumber <= toSequenceNr).delete | ||
} | ||
|
||
def markJournalMessagesAsDeleted(persistenceId: String, maxSequenceNr: Long) = | ||
def markAsDeleted(persistenceId: String, highestMarkedSequenceNr: Long) = | ||
JournalTable | ||
.filter(_.persistenceId === persistenceId) | ||
.filter(_.sequenceNumber <= maxSequenceNr) | ||
.filter(_.sequenceNumber === highestMarkedSequenceNr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. being more explicitly and only marking a single message as delete. Only used when deleted events though and what we want is to delete the latest. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this will probably not work as expected. Looking further in the code. |
||
.filter(_.deleted === false) | ||
.map(_.deleted) | ||
.update(true) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was indeed not efficient and there was also a little bug here.
For a journal with events: 1, 2, 3, 4, 5
Deleting up to 3, would first:
logically delete: 1, 2, 3
collect the highest logically deleted nr, thus 3
delete everything until 3, so delete 1 and 2.
The journal remains with: 3, 4, 5 while 3 is invisible because logically deleted.
There is no reason to keep 3, because it's not the highest anyway.