Skip to content

Commit

Permalink
Fix ordering issue found by performance tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtar committed Nov 28, 2023
1 parent a42ebd6 commit 47f4057
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ object SnapshotCassandra {
): F[Unit] = {
val sortedSnapshots = savedSnapshots.toList.sortBy { case (_, (seqNr, timestamp)) => (seqNr, timestamp) }

val oldestSnapshot = sortedSnapshots.lastOption
val oldestSnapshot = sortedSnapshots.headOption
MonadThrow[F].fromOption(oldestSnapshot, SnapshotStoreError("Could not find an oldest snapshot")).flatMap {
oldestSnapshot =>
val (bufferNr, (deleteSnapshot, _)) = oldestSnapshot
Expand All @@ -112,7 +112,7 @@ object SnapshotCassandra {
val sortedSnapshots = savedSnapshots.toList.sortBy { case (_, (seqNr, timestamp)) => (seqNr, timestamp) }

val olderSnapshot =
sortedSnapshots.findLast { case (_, (seqNr, _)) => seqNr == insertSnapshot.snapshot.seqNr }
sortedSnapshots.find { case (_, (seqNr, _)) => seqNr == insertSnapshot.snapshot.seqNr }
MonadThrow[F].fromOption(olderSnapshot, SnapshotStoreError("Could not find snapshot with seqNr")).flatMap {
olderSnapshot =>
val (bufferNr, (deleteSnapshot, _)) = olderSnapshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ object SnapshotStatements {
}

val statement = statementOf(snapshot)
val row = statement.setConsistencyLevel(consistencyConfig.value).first
val row = statement.first
row.map(_.fold(false)(_.wasApplied))
}
}
Expand Down Expand Up @@ -167,7 +167,7 @@ object SnapshotStatements {
}

val statement = statementOf(insertSnapshot)
val row = statement.setConsistencyLevel(consistencyConfig.value).first
val row = statement.first
row.map(_.fold(false)(_.wasApplied))
}
}
Expand Down

0 comments on commit 47f4057

Please sign in to comment.