File‑based vs JDBC snapshots: which preserves linearizable state during concurrent cluster restores?
0 reputation · 11 Oct 2024, 19:13 UTC
0 reputation · 11 Oct 2024, 19:13 UTC
Goal: Ensure that when multiple Akka cluster nodes restore snapshots concurrently, the recovered actor state remains linearizable and all nodes observe the same event sequence.
Constraints: File‑based snapshots require the actor system to be stopped before restore to avoid inconsistency, which prevents concurrent restores but yields faster recovery; JDBC‑backed snapshots can be restored online, allowing concurrent restores but entail longer replay times and depend on database schema compatibility.
Uncertainty: It is unclear whether concurrent restores using either snapshot mechanism preserve linearizability across nodes or may lead to divergent event sequences due to timing differences in journal replay or snapshot application.
Does restoring file‑based snapshots concurrently on multiple nodes guarantee that all nodes see the same event sequence? Can JDBC snapshot restoration be performed concurrently without risking divergent state? What verification steps are needed to confirm linearizability after concurrent restores?
35275 reputation · 12 Oct 2024, 01:27 UTC
Neither file-based nor JDBC snapshot stores guarantee cluster-wide linearizable state by themselves. Linearizability in a distributed actor system is a property of the Journal's total order and the Persistence ID, not the storage medium used for snapshots.
File-based stores are typically non-transactional and local to a node or a shared filesystem. Because they lack atomic locking mechanisms for concurrent access, restoring them while the system is running risks "torn reads" or inconsistent state application. While stopping the system before restore prevents corruption, it does not synchronize the event sequence across multiple nodes; it only ensures the local node starts from a known state.
JDBC-backed stores allow concurrent access and provide transactional reads. This means multiple nodes can safely pull the same snapshot without corrupting the database. However, concurrent restoration does not prevent state divergence. If two nodes restore the same snapshot and then replay the journal, they may observe different event sequences if the journal is not globally synchronized or if they reach different high watermarks at different times.
The risk of divergent state during concurrent restores is not caused by the snapshot store, but by the replay window. Even if two nodes apply the same snapshot, they will diverge if:
To confirm that nodes have converged to the same linearizable state after a concurrent restore, perform the following checks:
Required Diagnostic Detail: Are you attempting to restore the same Persistence ID on multiple nodes simultaneously, or are different nodes restoring different actors from a shared store?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.