Skip to content

Conversation

chbatey
Copy link
Contributor

@chbatey chbatey commented Sep 10, 2018

Journals can use this to make the bulk deletion more efficient

Use keepNrBatches to delete the last few snapshots in case previous
deletes failed.

I started writing a test with a mock snapshot store but seemed overkill.

@akka-ci akka-ci added the validating PR is currently being validated by Jenkins label Sep 10, 2018
deleteSnapshots(SnapshotSelectionCriteria(maxSequenceNr = toSequenceNr - 1))
val deleteFrom = math.max(0, toSequenceNr - (keepNrOfBatches * snapshotAfter))
val deleteTo = toSequenceNr - 1
log.debug("PersistentShard messages to {} deleted successfully. Deleting snapshots from {} to {}", toSequenceNr, deleteFrom, deleteTo)
Copy link
Contributor

Choose a reason for hiding this comment

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

for consistency with other log messages add [] around the {}

@@ -546,8 +537,13 @@ private[akka] class PersistentShard(
log.warning("PersistentShard snapshot failure: {}", reason.getMessage)

case DeleteMessagesSuccess(toSequenceNr) ⇒
log.debug("PersistentShard messages to {} deleted successfully", toSequenceNr)
deleteSnapshots(SnapshotSelectionCriteria(maxSequenceNr = toSequenceNr - 1))
val deleteFrom = math.max(0, toSequenceNr - (keepNrOfBatches * snapshotAfter))
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be deleteTo - (keepNrOfBatches * snapshotAfter), e.g. otherwise would be wrong when keepNrOfBatches is 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good catch

persistent actors should use the `deleteSnapshots` method.
persistent actors should use the `deleteSnapshots` method. Depending on the journal used this might be inefficient. It is
best practice to do specific deletes with `deleteSnapshot` or to include a `minSequenceNr` as well as a `maxSequenceNr`
for the `SnapshotSelectionCriteria`.
Copy link
Contributor

Choose a reason for hiding this comment

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

good

@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR is currently being validated by Jenkins labels Sep 10, 2018
@akka-ci
Copy link

akka-ci commented Sep 10, 2018

Test PASSed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins and removed tested PR that was successfully built and tested by Jenkins labels Sep 10, 2018
Copy link
Contributor

@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

@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR is currently being validated by Jenkins labels Sep 10, 2018
@akka-ci
Copy link

akka-ci commented Sep 10, 2018

Test PASSed.

@chbatey chbatey added this to the 2.5.17 milestone Sep 14, 2018
@chbatey
Copy link
Contributor Author

chbatey commented Sep 14, 2018

Set the milestone as promised it would be in the next release

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Sep 18, 2018
@akka-ci
Copy link

akka-ci commented Sep 18, 2018

Test FAILed.

Journals can use this to make the bulk deletion more efficient

Use keepNrBatches to delete the last few snapshots in case previous
deletes failed.
@chbatey chbatey force-pushed the sharding-snaphost-deletion branch from 95a39f5 to 2ca2fe1 Compare September 20, 2018 16:23
@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Sep 20, 2018
@akka-ci
Copy link

akka-ci commented Sep 20, 2018

Test PASSed.

Copy link
Contributor

@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 (if i understood the range part correctly)

log.debug("PersistentShard messages to {} deleted successfully", toSequenceNr)
deleteSnapshots(SnapshotSelectionCriteria(maxSequenceNr = toSequenceNr - 1))
val deleteTo = toSequenceNr - 1
val deleteFrom = math.max(0, deleteTo - (keepNrOfBatches * snapshotAfter))
Copy link
Contributor

Choose a reason for hiding this comment

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

So the low end of the range is a performance opt to not always delete from 0?

Copy link
Contributor

Choose a reason for hiding this comment

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

that's right, and it's used in Cassandra plugin when akka/akka-persistence-cassandra#394 has been released

Choose a reason for hiding this comment

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

@patriknw @johanandren what is the consequence if I want to upgade akka-cluster version to the 2.5.17 or newer (let's say the latest 2.5.23) but with akka-persistence-cassandra-0.62? Is it possible or do I have to use minimum of akka-persistence-cassandra-0.90 ?

@patriknw patriknw added the 2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding label Sep 25, 2018
@chbatey chbatey merged commit 23b9266 into akka:master Sep 25, 2018
@chbatey chbatey deleted the sharding-snaphost-deletion branch September 25, 2018 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants