akka-persistence-cassandra icon indicating copy to clipboard operation
akka-persistence-cassandra copied to clipboard

Optimize asyncReadHighestSequenceNr implementation

Open ayushworks opened this issue 6 years ago • 3 comments

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.

ayushworks avatar Jun 21 '18 09:06 ayushworks

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?

patriknw avatar Jun 25 '18 07:06 patriknw

and better to make this flag somehow per persistenceId :)

t3hnar avatar Jun 25 '18 07:06 t3hnar

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.

patriknw avatar Jun 25 '18 08:06 patriknw