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

CassandraPersistenceQueries.currentEventsBefore can skip deleted partitions #208

Closed
xirc opened this issue May 17, 2023 · 0 comments · Fixed by #209
Closed

CassandraPersistenceQueries.currentEventsBefore can skip deleted partitions #208

xirc opened this issue May 17, 2023 · 0 comments · Fixed by #209
Milestone

Comments

@xirc
Copy link
Contributor

xirc commented May 17, 2023

For #201

CassandraPersistenceQueries.currentEventsBefore iterates events on all partitions (from + 1 to 0) but can skip deleted partitions by using the highest deleted sequence number (callled deleted_to), which reduces some read-events queries.

CassandraPersistenceQueries.currentEventsBefore:

override def currentEventsBefore(
persistenceId: String,
from: SequenceNr,
): Source[PersistenceQueries.TaggedEventEnvelope, NotUsed] = {
val fromPartitionNr = PartitionNr.fromSequenceNr(from, journalSettings.targetPartitionSize)
val sources =
for (partitionNr <- fromPartitionNr.value + 1 to 0 by -1) yield {
currentEventsBeforeOnPartition(persistenceId, from, PartitionNr(partitionNr))
}
sources
.fold(Source.empty)(_.concat(_))
.mapMaterializedValue(_ => NotUsed)
}

CassandraPersistenceQueries can fetch the highest deleted sequence number (called deleted_to) from the metadata table (akka.metadata).

deleted_to is described as:

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 a pull request may close this issue.

1 participant