ascherbakoff commented on code in PR #5752:
URL: https://github.com/apache/ignite-3/pull/5752#discussion_r2084071294


##########
modules/client/src/main/java/org/apache/ignite/internal/client/ClientTransactionInflights.java:
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.client;
+
+import static java.util.concurrent.CompletableFuture.failedFuture;
+import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
+import static 
org.apache.ignite.internal.util.CompletableFutures.nullCompletedFuture;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
+
+/**
+ * Client transaction inflights tracker.
+ */
+public class ClientTransactionInflights {
+    /** Hint for maximum concurrent txns. */
+    private static final int MAX_CONCURRENT_TXNS = 1024;
+
+    /** Txn contexts. */
+    private final ConcurrentHashMap<UUID, TxContext> txCtxMap = new 
ConcurrentHashMap<>(MAX_CONCURRENT_TXNS);
+
+    /**
+     * Registers the inflight update for a transaction.
+     *
+     * @param txId The transaction id.
+     */
+    public void addInflight(UUID txId) {
+        txCtxMap.compute(txId, (uuid, ctx) -> {
+            if (ctx == null) {
+                ctx = new TxContext();
+            }
+
+            ctx.addInflight();
+
+            return ctx;
+        });
+    }
+
+    /**
+     * Unregisters the inflight for a transaction.
+     *
+     * @param txId The transaction id.
+     * @param t Not null on error from a server.
+     */
+    public void removeInflight(UUID txId, @Nullable Throwable t) {
+        var ctx0 = txCtxMap.compute(txId, (uuid, ctx) -> {
+            if (ctx == null) {
+                throw new AssertionError();
+            }
+
+            ctx.removeInflight(txId);
+
+            if (t != null && ctx.err == null) {
+                ctx.err = t; // Retain only first exception.

Review Comment:
   This is the intentional behavior.
   Because the number of failed enlistements is potentially unlimited, we can 
end up with a root exception and a huge number of supressed. 
   It doesn't make much sense to me. So we retain only first error.



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to