Lalant commented on code in PR #7482:
URL: https://github.com/apache/ignite-3/pull/7482#discussion_r2797270422


##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/TxStateMeta.java:
##########
@@ -191,6 +239,56 @@ public TxState txState() {
         return txLabel;
     }
 
+    public @Nullable List<TxStateMetaExceptionInfo> exceptionInfos() {
+        return exceptionInfos;
+    }
+
+    /**
+     * Records exceptional information by mutating tx state or by creating a 
new one. This method should be called after tx is finished.
+     *
+     * @param old previous TxStateMeta.
+     * @param throwable to record
+     */
+    public static TxStateMeta recordExceptionInfo(@Nullable TxStateMeta old, 
Throwable throwable) {
+        TxStateMetaExceptionInfo exceptionInfo = fromThrowable(throwable);
+        return old == null
+                ? builder(old, ABORTED).exceptionInfo(exceptionInfo).build()
+                : old.mutate().exceptionInfo(exceptionInfo).build();
+    }
+
+    /**
+     * Aggregates exception infos into a single throwable, using the last 
exception as the primary one and attaching previous exceptions as
+     * suppressed.
+     *
+     * @param exceptionInfos Exception infos list.
+     * @return Aggregated throwable or {@code null} if nothing usable is 
present.
+     */
+    public static @Nullable Throwable aggregateExceptionInfos(@Nullable 
List<TxStateMetaExceptionInfo> exceptionInfos) {
+        if (exceptionInfos == null || exceptionInfos.isEmpty()) {
+            return null;
+        }
+
+        Throwable primary = exceptionInfos.get(exceptionInfos.size() - 
1).throwable();
+        if (primary == null) {
+            return null;
+        }
+
+        if (exceptionInfos.size() == 1) {
+            return primary;
+        }
+
+        RuntimeException aggregate = new RuntimeException("Multiple 
transaction abort reasons", primary);

Review Comment:
   This one is removed since we use one exception.



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/TxStateMeta.java:
##########
@@ -258,6 +356,7 @@ public static class TxStateMetaBuilder {
         protected @Nullable Boolean isFinishedDueToTimeout;
         protected @Nullable String txLabel;
         protected @Nullable InternalTransaction tx;
+        protected @Nullable List<TxStateMetaExceptionInfo> exceptionInfos;

Review Comment:
   Done



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

Reply via email to