Consolidate duplicate persistence sharding function #26451 (#26452)

This commit is contained in:
Helena Edelson 2019-03-05 08:05:51 -05:00 committed by GitHub
parent 7f0837a550
commit 27957649e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 28 deletions

View file

@ -562,21 +562,9 @@ private[akka] class PersistentShard(
}
override def receiveCommand: Receive = ({
case SaveSnapshotSuccess(m)
case e: SaveSnapshotSuccess
log.debug("PersistentShard snapshot saved successfully")
/*
* delete old events but keep the latest around because
*
* it's not safe to delete all events immediately because snapshots are typically stored with a weaker consistency
* level which means that a replay might "see" the deleted events before it sees the stored snapshot,
* i.e. it will use an older snapshot and then not replay the full sequence of events
*
* for debugging if something goes wrong in production it's very useful to be able to inspect the events
*/
val deleteToSequenceNr = m.sequenceNr - keepNrOfBatches * snapshotAfter
if (deleteToSequenceNr > 0) {
deleteMessages(deleteToSequenceNr)
}
internalDeleteMessagesBeforeSnapshot(e, keepNrOfBatches, snapshotAfter)
case SaveSnapshotFailure(_, reason)
log.warning("PersistentShard snapshot failure: [{}]", reason.getMessage)