|
24 | 24 | import static java.util.stream.Collectors.toMap; |
25 | 25 | import static org.apache.ignite.internal.logger.Loggers.toThrottledLogger; |
26 | 26 | import static org.apache.ignite.internal.tx.TxStateMeta.builder; |
27 | | -import static org.apache.ignite.internal.tx.impl.TxStateResolutionParameters.txStateResolutionParameters; |
28 | 27 | import static org.apache.ignite.internal.util.ExceptionUtils.sneakyThrow; |
29 | 28 | import static org.apache.ignite.internal.util.IgniteUtils.scheduleRetry; |
30 | 29 |
|
|
51 | 50 | import org.apache.ignite.internal.replicator.ReplicatorRecoverableExceptions; |
52 | 51 | import org.apache.ignite.internal.replicator.ZonePartitionId; |
53 | 52 | import org.apache.ignite.internal.tx.PartitionEnlistment; |
54 | | -import org.apache.ignite.internal.tx.TransactionMeta; |
55 | 53 | import org.apache.ignite.internal.tx.TxState; |
56 | | -import org.apache.ignite.internal.tx.TxStateMeta; |
57 | 54 | import org.apache.ignite.internal.tx.message.CleanupReplicatedInfo; |
58 | 55 | import org.apache.ignite.internal.tx.message.CleanupReplicatedInfoMessage; |
59 | 56 | import org.apache.ignite.internal.tx.message.TxCleanupMessageErrorResponse; |
@@ -149,41 +146,25 @@ private void onCleanupReplicated(CleanupReplicatedInfo info) { |
149 | 146 | }); |
150 | 147 |
|
151 | 148 | if (ctx != null && ctx.partitions.isEmpty()) { |
152 | | - markTxnCleanupReplicated(info.txId(), ctx.txState, ctx.commitPartitionId); |
| 149 | + markTxnCleanupReplicated(info.txId(), ctx.txState, ctx.commitTimestamp, ctx.commitPartitionId); |
153 | 150 |
|
154 | 151 | writeIntentsReplicated.remove(info.txId()); |
155 | 152 | } |
156 | 153 | } |
157 | 154 |
|
158 | | - private void markTxnCleanupReplicated(UUID txId, TxState state, ZonePartitionId commitPartitionId) { |
| 155 | + private void markTxnCleanupReplicated( |
| 156 | + UUID txId, |
| 157 | + TxState state, |
| 158 | + @Nullable HybridTimestamp commitTimestamp, |
| 159 | + ZonePartitionId commitPartitionId |
| 160 | + ) { |
159 | 161 | long cleanupCompletionTimestamp = System.currentTimeMillis(); |
160 | 162 |
|
161 | | - TxStateMeta txStateMeta = txStateVolatileStorage.state(txId); |
162 | | - final CompletableFuture<HybridTimestamp> commitTimestampFuture; |
163 | | - if (state == TxState.COMMITTED && (txStateMeta == null || txStateMeta.commitTimestamp() == null)) { |
164 | | - commitTimestampFuture = placementDriverHelper.awaitPrimaryReplicaWithExceptionHandling(commitPartitionId) |
165 | | - .thenCompose(replicaMeta -> { |
166 | | - String primaryNode = replicaMeta.getLeaseholder(); |
167 | | - HybridTimestamp startTime = replicaMeta.getStartTime(); |
168 | | - return txMessageSender.resolveTxStateFromCommitPartition( |
169 | | - txStateResolutionParameters().txId(txId).commitGroupId(commitPartitionId).build(), |
170 | | - primaryNode, |
171 | | - startTime.longValue() |
172 | | - ) |
173 | | - .thenApply(TransactionMeta::commitTimestamp); |
174 | | - } |
175 | | - ); |
176 | | - } else { |
177 | | - HybridTimestamp existingCommitTs = txStateMeta == null ? null : txStateMeta.commitTimestamp(); |
178 | | - commitTimestampFuture = CompletableFuture.completedFuture(existingCommitTs); |
179 | | - } |
180 | | - |
181 | | - commitTimestampFuture.thenAccept(commitTimestamp -> |
182 | | - txStateVolatileStorage.updateMeta(txId, oldMeta -> builder(oldMeta, state) |
183 | | - .commitPartitionId(commitPartitionId) |
184 | | - .commitTimestamp(commitTimestamp) |
185 | | - .cleanupCompletionTimestamp(cleanupCompletionTimestamp) |
186 | | - .build()) |
| 163 | + txStateVolatileStorage.updateMeta(txId, oldMeta -> builder(oldMeta, state) |
| 164 | + .commitPartitionId(commitPartitionId) |
| 165 | + .commitTimestamp(commitTimestamp) |
| 166 | + .cleanupCompletionTimestamp(cleanupCompletionTimestamp) |
| 167 | + .build() |
187 | 168 | ); |
188 | 169 | } |
189 | 170 |
|
@@ -228,7 +209,12 @@ public CompletableFuture<Void> cleanup( |
228 | 209 | if (commitPartitionId != null) { |
229 | 210 | writeIntentsReplicated.put( |
230 | 211 | txId, |
231 | | - new CleanupContext(commitPartitionId, enlistedPartitions.keySet(), commit ? TxState.COMMITTED : TxState.ABORTED) |
| 212 | + new CleanupContext( |
| 213 | + commitPartitionId, |
| 214 | + enlistedPartitions.keySet(), |
| 215 | + commit ? TxState.COMMITTED : TxState.ABORTED, |
| 216 | + commitTimestamp |
| 217 | + ) |
232 | 218 | ); |
233 | 219 | } |
234 | 220 |
|
@@ -280,8 +266,12 @@ private CompletableFuture<Void> cleanup( |
280 | 266 | // Start tracking the partitions we want to learn the replication confirmation from. |
281 | 267 | writeIntentsReplicated.put( |
282 | 268 | txId, |
283 | | - new CleanupContext(commitPartitionId, new HashSet<>(partitionIds.keySet()), |
284 | | - commit ? TxState.COMMITTED : TxState.ABORTED) |
| 269 | + new CleanupContext( |
| 270 | + commitPartitionId, |
| 271 | + new HashSet<>(partitionIds.keySet()), |
| 272 | + commit ? TxState.COMMITTED : TxState.ABORTED, |
| 273 | + commitTimestamp |
| 274 | + ) |
285 | 275 | ); |
286 | 276 | } |
287 | 277 |
|
@@ -492,10 +482,19 @@ private static class CleanupContext { |
492 | 482 | */ |
493 | 483 | private final TxState txState; |
494 | 484 |
|
495 | | - private CleanupContext(ZonePartitionId commitPartitionId, Set<ZonePartitionId> partitions, TxState txState) { |
| 485 | + @Nullable |
| 486 | + private final HybridTimestamp commitTimestamp; |
| 487 | + |
| 488 | + private CleanupContext( |
| 489 | + ZonePartitionId commitPartitionId, |
| 490 | + Set<ZonePartitionId> partitions, |
| 491 | + TxState txState, |
| 492 | + @Nullable HybridTimestamp commitTimestamp |
| 493 | + ) { |
496 | 494 | this.commitPartitionId = commitPartitionId; |
497 | 495 | this.partitions = partitions; |
498 | 496 | this.txState = txState; |
| 497 | + this.commitTimestamp = commitTimestamp; |
499 | 498 | } |
500 | 499 | } |
501 | 500 |
|
|
0 commit comments