ifesdjeen commented on code in PR #4225:
URL: https://github.com/apache/cassandra/pull/4225#discussion_r2183790937


##########
test/unit/org/apache/cassandra/db/virtual/AccordDebugKeyspaceTest.java:
##########
@@ -85,6 +110,48 @@ public void unknownIsEmpty()
     {
         createTable("CREATE TABLE %s (k int, c int, v int, PRIMARY KEY (k, c)) 
WITH transactional_mode = 'full'");
         assertRows(execute(QUERY_TXN_BLOCKED_BY, TxnId.NONE.toString()));
+        assertRows(execute(QUERY_TXN, TxnId.NONE.toString()));
+        assertRows(execute(QUERY_JOURNAL, TxnId.NONE.toString()));
+    }
+
+    @Test
+    public void tracing()
+    {
+        // simple test to confirm basic tracing functionality works, doesn't 
validate specific behaviours only requesting/querying/erasing
+        AccordMsgFilter filter = new AccordMsgFilter();
+        MessagingService.instance().outboundSink.add(filter);
+        try
+        {
+            String tableName = createTable("CREATE TABLE %s (k int, c int, v 
int, PRIMARY KEY (k, c)) WITH transactional_mode = 'full'");
+            var accord = accord();
+            DatabaseDescriptor.getAccord().fetch_txn = "1s";
+            TxnId id = accord.node().nextTxnId(Txn.Kind.Write, 
Routable.Domain.Key);
+            Txn txn = createTxn(wrapInTxn(String.format("INSERT INTO %s.%s(k, 
c, v) VALUES (?, ?, ?)", KEYSPACE, tableName)), 0, 0, 0);
+
+            execute(SET_TRACE, 1, id.toString(), "PROGRESS");
+            accord.node().coordinate(id, txn);
+            filter.preAccept.awaitThrowUncheckedOnInterrupt();
+
+            filter.apply.awaitThrowUncheckedOnInterrupt();
+            spinUntilSuccess(() -> Assertions.assertThat(execute(QUERY_TRACES, 
id.toString(), "PROGRESS").size()).isGreaterThan(0));
+            execute(ERASE_TRACES1, id.toString(), "PROGRESS", Long.MAX_VALUE);
+            Assertions.assertThat(execute(QUERY_TRACES, id.toString(), 
"PROGRESS").size()).isEqualTo(0);
+            // just check other variants don't fail
+            execute(ERASE_TRACES2, id.toString(), "PROGRESS");

Review Comment:
   ```
   execute(ERASE_TRACES2, id.toString(), "FETCH");
   ```
   
   would throw an NPE 
   
   ```
   
   java.lang.NullPointerException
        at 
org.apache.cassandra.service.accord.AccordTracing.lambda$eraseEvents$4(AccordTracing.java:264)
        at 
java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1932)
        at 
org.apache.cassandra.service.accord.AccordTracing.eraseEvents(AccordTracing.java:260)
        at 
org.apache.cassandra.db.virtual.AccordDebugKeyspace$TxnTracesTable.applyRangeTombstone(AccordDebugKeyspace.java:720)
        at 
org.apache.cassandra.db.virtual.AbstractMutableVirtualTable.lambda$apply$2(AbstractMutableVirtualTable.java:101)
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
        at 
org.apache.cassandra.db.virtual.AbstractMutableVirtualTable.apply(AbstractMutableVirtualTable.java:101)
        at 
org.apache.cassandra.db.virtual.VirtualMutation.lambda$apply$0(VirtualMutation.java:64)
   
   ```



-- 
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: pr-unsubscr...@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to