Copilot commented on code in PR #6897:
URL: https://github.com/apache/ignite-3/pull/6897#discussion_r2491322425


##########
modules/catalog-compaction/src/integrationTest/java/org/apache/ignite/internal/catalog/compaction/ItCatalogCompactionTest.java:
##########
@@ -305,4 +333,109 @@ private static void expectEarliestCatalogVersion(int 
expectedVersion) {
             }
         });
     }
+
+    class DebugInfoCollector {
+        private final List<IgniteImpl> nodes;
+        private final Map<UUID, String> nodesById;
+        private final IgniteStringBuilder buffer = new 
IgniteStringBuilder("Test debug info").nl();
+        private final List<InternalTransaction> transactions = new 
ArrayList<>();
+
+        DebugInfoCollector(List<IgniteImpl> nodes) {
+            this.nodes = nodes;
+            Map<UUID, String> nodesById = new HashMap<>();
+
+            for (IgniteImpl node : nodes) {
+                nodesById.put(node.id(), node.name());
+            }
+
+            this.nodesById = nodesById;
+        }
+
+        void recordCatalogState(String contextMessage) {
+            buffer.nl();
+
+            for (IgniteImpl node : nodes) {
+                buffer.app("Catalog state(").app(contextMessage)
+                        .app(") on node ").app(node.name()).nl();
+
+                CatalogManager mgr = node.catalogManager();
+
+                for (int ver = mgr.earliestCatalogVersion(); ver < 
mgr.latestCatalogVersion(); ver++) {
+                    Catalog catalog = mgr.catalog(ver);
+
+                    buffer.app("  ").app(ver).app(" | ").app(catalog == null ? 
-1 : catalog.time()).nl();
+                }
+            }
+        }
+
+        void recordMinTxTimesState(String contextMessage) {
+            buffer.nl();
+
+            buffer.app("Minimum RW tx times 
(").app(contextMessage).app(')').nl();
+
+            for (IgniteImpl node : nodes) {
+                ActiveLocalTxMinimumRequiredTimeProvider timeProvider = 
node.catalogCompactionRunner()
+                        .activeLocalTxMinimumRequiredTimeProvider();
+
+                buffer.app("  ").app(node.name()).app(": 
").app(timeProvider.minimumRequiredTime()).nl();
+            }
+        }
+
+        void recordTransactionsState() {
+            // Sort by start time.
+            transactions.sort(Comparator.comparing(t -> 
beginTimestamp(t.id())));
+
+            List<InternalTransaction> roTransactions = new ArrayList<>();
+            List<InternalTransaction> rwTransactions = new ArrayList<>();
+
+            for (InternalTransaction tx : transactions) {
+                if (tx.isReadOnly()) {
+                    roTransactions.add(tx);
+                } else {
+                    rwTransactions.add(tx);
+                }
+            }
+
+            buffer.nl();
+            buffer.app("RW transactions state").nl();
+
+            for (InternalTransaction tx : rwTransactions) {
+                buffer.app("  ")
+                        .app(tx.isFinishingOrFinished() ? "finished" : "active 
 ").app(" | ")
+                        .app(nodesById.get(tx.coordinatorId())).app(" | ")
+                        .app(beginTimestamp(tx.id()))
+                        .nl();
+            }
+
+            buffer.nl();
+            buffer.app("RO transactions state").nl();
+
+            for (InternalTransaction tx : rwTransactions) {

Review Comment:
   Incorrect variable used in loop. This should iterate over `roTransactions` 
instead of `rwTransactions` to display read-only transaction states. Currently, 
the RW transactions are being printed twice and RO transactions are never 
displayed.
   ```suggestion
               for (InternalTransaction tx : roTransactions) {
   ```



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