sanpwc commented on code in PR #6413:
URL: https://github.com/apache/ignite-3/pull/6413#discussion_r2288442215


##########
modules/api/src/main/java/org/apache/ignite/tx/RunInTransactionInternalImpl.java:
##########
@@ -0,0 +1,177 @@
+/*
+ * 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.tx;
+
+import static java.util.Collections.synchronizedList;
+import static java.util.concurrent.CompletableFuture.completedFuture;
+import static java.util.concurrent.CompletableFuture.failedFuture;
+import static java.util.function.Function.identity;
+import static 
org.apache.ignite.tx.IgniteTransactionDefaults.DEFAULT_RW_TX_TIMEOUT_SECONDS;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import org.jetbrains.annotations.Nullable;
+
+class RunInTransactionInternalImpl {
+    private static final int MAX_SUPPRESSED = 100;
+
+    static <T> T runInTransactionInternal(
+            IgniteTransactions igniteTransactions,
+            Function<Transaction, T> clo,
+            @Nullable TransactionOptions options,
+            long startTimestamp,
+            long initialTimeout
+    ) throws TransactionException {
+        Objects.requireNonNull(clo);
+
+        TransactionOptions txOptions = options == null
+                ? new 
TransactionOptions().timeoutMillis(TimeUnit.SECONDS.toMillis(DEFAULT_RW_TX_TIMEOUT_SECONDS))
+                : options;
+
+        List<Throwable> suppressed = new ArrayList<>();
+
+        while (true) {
+            Transaction tx = igniteTransactions.begin(txOptions);
+
+            try {
+                T ret = clo.apply(tx);
+
+                tx.commit();
+
+                return ret;
+            } catch (Throwable t) {

Review Comment:
   As mentioned above we should retry only in case of recoverable exceptions. 



-- 
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