denis-chudov commented on code in PR #2585:
URL: https://github.com/apache/ignite-3/pull/2585#discussion_r1326515610
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/TransactionStateResolver.java:
##########
@@ -115,4 +308,64 @@ private void sendAndRetry(CompletableFuture<TxMeta>
resFut, ReplicationGroupId r
}
});
}
+
+ /**
+ * Tries to send a request to the given node.
+ *
+ * @param resFut Response future.
+ * @param node Node to send to.
+ * @param request Request.
+ */
+ private void sendAndRetry(CompletableFuture<TransactionMeta> resFut,
ClusterNode node, TxStateRequest request) {
+ messagingService.invoke(node, request, RPC_TIMEOUT).thenAccept(resp ->
{
+ assert resp instanceof TxStateResponse : "Unsupported response
type [type=" + resp.getClass().getSimpleName() + ']';
+
+ TxStateResponse response = (TxStateResponse) resp;
+
+ resFut.complete(response.txStateMeta());
+ });
+ }
+
+ /**
+ * Processes the transaction state requests that are used for coordinator
path based write intent resolution. Can't return
+ * {@link org.apache.ignite.internal.tx.TxState#FINISHING}, it waits for
actual completion instead.
+ *
+ * @param request Request.
+ * @return Future that should be completed with transaction state meta.
+ */
+ private CompletableFuture<TransactionMeta>
processTxStateRequest(TxStateRequest request) {
+ clock.update(request.readTimestamp());
+
+ UUID txId = request.txId();
+
+ TxStateMeta txStateMeta = txManager.stateMeta(txId);
+
+ if (txStateMeta != null && txStateMeta.txState() == FINISHING) {
+ assert txStateMeta instanceof TxStateMetaFinishing;
+
+ TxStateMetaFinishing txStateMetaFinishing = (TxStateMetaFinishing)
txStateMeta;
+
+ AtomicReference<CompletableFuture<TransactionMeta>> futRef = new
AtomicReference<>();
+
+ txStateFutures.computeIfAbsent(txId, k -> {
+ TxStateMeta meta = txManager.stateMeta(txId);
+
+ if (meta != null && meta.txState() != FINISHING) {
+ futRef.set(completedFuture(meta));
+
+ return null;
+ }
+
+ futRef.set(txStateMetaFinishing.future());
+
+ return futRef.get();
+ });
+
+ futRef.get().whenComplete((v, e) -> txStateFutures.remove(txId));
+
+ return futRef.get();
Review Comment:
Probably you are right and these dances with second check inside of
`compute` are not needed. I will fix it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]