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

Cleaning up of snapshots and events before snapshots based on time and a # of snapshots #828

Merged
merged 1 commit into from Oct 12, 2020

Conversation

chbatey
Copy link
Member

@chbatey chbatey commented Oct 9, 2020

No description provided.

Copy link
Member

@johanandren johanandren left a comment

Choose a reason for hiding this comment

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

LGTM, some smaller nitpicky stuff mostly

def deleteBeforeSnapshot(
persistenceId: String,
snapshotsToKeep: Int,
keepAfter: Long): Future[Option[SnapshotMetadata]] = {
Copy link
Member

Choose a reason for hiding this comment

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

Hard to parse what it does from name/docs but I'm not sure I can come up with anything better...

deleteSnapshotsBefore(persistenceId, unixTimestamp, nrSnapshotsToKeep)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yah i struggled to describe it.

Just having a timestamp makes it easy to understand "delete all snapshots older than X" but is an API that will lead to ppl deleting all their snapshots!


/**
* Deletes all but the last N snapshots and deletes all events before this snapshot
* Does not delete from the tag_views table
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps additional caveat about consequences for this? Events by tag would fail if you run it and see a tag for a message that is not there?

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 don't think it'll fail, it doesn't reconcile that way around. Only messages to tag_views table. I will add warnings tho

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

looking good, a few questions

val allRows: Source[Row, NotUsed] = session.select(ps.bind(persistenceId))
@volatile var count = 0
allRows
.takeWhile { row =>
Copy link
Member

Choose a reason for hiding this comment

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

could we skip the count hack with:

allRows
  .take(snapshotsToKeep)
  .takeWhile { row =>

?

Copy link
Member Author

Choose a reason for hiding this comment

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

No as we may wan to keep more than snapshotsToKeep if they are all newer than the toKeep time

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM, after some small doc additions

core/src/main/resources/reference.conf Show resolved Hide resolved
docs/src/main/paradox/cleanup.md Show resolved Hide resolved
docs/src/main/paradox/cleanup.md Show resolved Hide resolved
@chbatey chbatey force-pushed the wip-chbatey-cleanup-on-snapshots branch from ae39644 to f080bd1 Compare October 12, 2020 12:26
@chbatey chbatey merged commit 5d7837e into akka:master Oct 12, 2020
@chbatey chbatey deleted the wip-chbatey-cleanup-on-snapshots branch October 12, 2020 13:03
chbatey added a commit to chbatey/akka-persistence-cassandra that referenced this pull request Oct 12, 2020
chbatey added a commit to chbatey/akka-persistence-cassandra that referenced this pull request Oct 13, 2020
chbatey added a commit to chbatey/akka-persistence-cassandra that referenced this pull request Oct 13, 2020
chbatey added a commit that referenced this pull request Oct 13, 2020
Cleanup snapshots and events from before a configured snapshot (#828) (for 0.x branch)
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.

None yet

3 participants