ConsistentCut splits WAL on 2 global areas - Before
and After
. It guarantees that every transaction committed Before
also will be committed Before
on every other node participated in the transaction. It means that an Ignite node can safely recover itself to the Before
state without any coordination with other nodes.
The border between Before
and After
areas consists of two WAL records - ConsistentCutStartRecord
and ConsistentCutFinishRecord
. It guarantees that the Before
consists of:
1. transactions committed before ConsistentCutStartRecord
and weren't included into ConsistentCutFinishRecord#after()
;
2. transactions committed between ConsistentCutStartRecord
and ConsistentCutFinishRecord
and were included into ConsistentCutFinishRecord#before()
.
On the picture below the Before
area consist of transactions colored to yellow, while After
is green.
/** */ public class ConsistentCutStartRecord extends WALRecord { /** Marker that inits Consistent Cut. */ private final ConsistentCutMarker marker; } /** */ public class ConsistentCutFinishRecord extends WALRecord { /** Marker that inits Consistent Cut. */ private final ConsistentCutMarker marker; /** * Collections of transactions committed BEFORE. */ private final Set<GridCacheVersion> before; /** * Collections of transactions committed AFTER. */ private final Set<GridCacheVersion> after; }
DistributedProcess
with special message holds new ConsistentCutMarker
(goal is to notify every node in a cluster about running incremental snapshot). ConsistentCutMarker
by discovery.ConsistentCutMarker
by transaction message (Prepare, Finish)topVersion
with received in marker. Skip if it is different.ConsistentCut
futurecommittingTx,
goal is to track COMMITTING transactions, that aren't part of IgniteTxManager#activeTx
ConsistentCutMarker
.ConsistentCutStartRecord
to WAL with the received ConsistentCutMarker
.IgniteTxManager#activeTx
and committingTxs
.DistributedProcess
is alive every node signs output transaction messages:ConsistentCutMarker
(to trigger ConsistentCut
on remote node, if not yet).ConsistentCutMarker
(to trigger...) and transaction ConsistentCutMarker
(to notify nodes which side of cut this transaction belongs to).ConsistentCutMarker
on node that commits first.committingTxs
.tx#finishFuture
with callback. Callback is called when transaction finished:tx.finalizationStatus
!= RECOVERY_FINISH). If it isn't then this cut is inconsistent. Complete ConsistentCut exceptionally.txMarker
is null or differs from local, then transaction put into before
txMarker
equals to local, then transaction put into after
before
, after
). committingTxs
and clean this collection.ConsistentCut
future, and notifies a node-initiator about finishing local procedure (with DistributedProcess
protocol).ConsistentCut
:ConsistentCut
future becomes null.Consistent Cut is such cut that correctly finished on all baseline nodes - ConsistentCutStartRecord
and ConsistentCutFinishRecord
are written.
"Inconsistent" Cut is such a cut when one or more baseline nodes hasn't wrote ConsistentCutFinishRecord
. It's possible in cases:
tx.finalizationStatus
== RECOVERY_FINISH).Every ignite nodes tracks current ConsistentCutMarker
:
class ConsistentCutMarker { UUID id; AffinityTopologyVersion topVer; }
id
is just a unique ConsistentCut
ID (is assigned on the node initiator).
topVer
is topology version on node initiator before Incremental Snapshot starts.
On the picture below on left side is a diagram of sending transaction messages. Before sending message it checks whether cut is running with cutMarker()
. If it is then wrap message, otherwise send ordinary message (PrepareRequest
in example).
Ignite transaction protocol includes multiple messages. But only some of them affects meaningful (relating to the algorithm) that change state of transactions (PREPARED, COMMITTED):
GridNearTxPrepareRequest / GridDhtTxPrepareRequest
GridNearTxPrepareResponse / GridDhtTxPrepareResponse
GridNearTxFinishRequest / GridDhtTxFinishRequest
Those messages are wrapped in MarkerMessage
that is prepared right before sending message on other node. They used the current ConsistentCutMarker
for setting the marker.
class MarkerMessage { Message msg; ConsistentCutMarker marker; }
Also some messages require to be signed with additional ConsistentCutMarker
to check it them on primary/backup node.
GridNearTxFinishRequest / GridDhtTxFinishRequest
GridNearTxPrepareResponse / GridDhtTxPrepareResponse
(for 1PC algorithm).Those messages are wrapped in TransactionFinishMarkerMessage
that is prepared right before transaction starts committing on first committing node. They used the current ConsistentCutMarker
for setting the txMarker
. txMarker
can be null, if transaction starts committing before ConsistentCut starts.
class TransactionFinishMarkerMessage extends MarkerMessage { @Nullable ConsistentCutMarker txMarker; }