akka-persistence-cassandra
akka-persistence-cassandra copied to clipboard
Optimize asyncReadHighestSequenceNr implementation
CassandraRecovery
class implements the method. Following is the code
override def asyncReadHighestSequenceNr(persistenceId: String, fromSequenceNr: Long): Future[Long] =
asyncHighestDeletedSequenceNumber(persistenceId).flatMap { h =>
asyncFindHighestSequenceNr(persistenceId, math.max(fromSequenceNr, h))
}
It reads the metadata table first to get the deleted_to
for the given persistence id and then proceeds.
Metadata table would contain data only if snapshots are used or deleteMessages api is called. However that is not always true. Some application never insert data into metadata table because they do not delete messages or use snapshots. In those cases the read from metadata table is always an overhead.
Solution : provide a property that allows an application to tell if the metadata table should be read or not for getting the highest seq nr.
Sounds good, and then we should also reject snapshot and delete commands. Btw, is it really related to snapshots? Would you be able to create a pull request?
and better to make this flag somehow per persistenceId
:)
I’m not sure about the config per id, because ids are often not known up front. One can define multple plugins and thereby use this only for some persistent actors.