Closed negokaz closed 4 months ago
@danischroeter @nvollmar I did some investigation of the history of why the lazy vals were introduced in CassandraJournal and the 2 of you were involved in the changes. (https://github.com/akka/akka-persistence-cassandra/issues/816)
It seems that we need retry when the Future[PreparedStatement]
ends up in failed state.
@danischroeter @nvollmar I did some investigation of the history of why the lazy vals were introduced in CassandraJournal and the 2 of you were involved in the changes. (akka/akka-persistence-cassandra#816)
It seems that we need retry when the
Future[PreparedStatement]
ends up in failed state.
The solution would be pretty easy then, i.e. change to def
?
@mdedetrich the problem code used defs but were changed to lazy vals to fix issues - see the conversation in https://github.com/akka/akka-persistence-cassandra/issues/816. We may be better off trying to introduce code that recovers from failure than reverting to defs. But it's worth considering both approaches.
I'm going to press on with the 1.0.0 release and add this as a known issue in the release notes. Hopefully, we should be able to release a patch in the next few weeks that fixes this issue.
@negokaz I've released v1.0.0 of this lib with this as a known issue. I have a speculative PR (#106) but would like to get some feedback on it. If you are in a position to build your own jar based on this PR and see if it helps in your scenario, that would be great.
@pjfanning Thank you for addressing the issue. I'll see if your PR (#106) can fix my problem.
According to the conversation in https://github.com/akka/akka-persistence-cassandra/issues/816, we should also change CassandraSnapshotStore
to use something like LazyFutureEval
in #106 ?
CassandraSnapshotStore
creates PreparedStatement
s with def
:
@negokaz LazyFutureEval is designed to fix the issue where a lazy val
stores a failed future. A def
won't store a failed future. I'm not fully against changing those def
s that you highlighted but I think that could be treated as a separate issue. In my mind, changing those def
s is a potential performance optimisation.
scala:
2.13.12
pekko:1.0.1
pekko-persistence-cassandra:0.0.0-1120-5b7555fe-SNAPSHOT
CassandraJournal
cachesFuture[PreparedStatement]
withlazy val
. It caches failedFuture[PreparedStatement]
when PreparedStatement initialization fails. https://github.com/apache/incubator-pekko-persistence-cassandra/blob/7741ba0ab3be3ab0c132dcfc866d14c25e2c08de/core/src/main/scala/org/apache/pekko/persistence/cassandra/journal/CassandraJournal.scala#L117-L152 The failure can occur when the app starts where Cassandra or the network is unstable.The broken cache makes it fail to read events from the Journal continually.
We can reproduce the problem with the following sample project.