Skip to content

Commit e4d0de3

Browse files
committed
Durability Deadlock
1 parent 836e274 commit e4d0de3

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "modules/accord"]
22
path = modules/accord
3-
url = https://github.com/apache/cassandra-accord.git
4-
branch = trunk
3+
url = https://github.com/belliottsmith/cassandra-accord.git
4+
branch = durability-deadlock

src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,7 @@ protected void collect(PartitionsCollector collector)
21112111
DebugBlockedTxns.visit(AccordService.unsafeInstance(), txnId, maxDepth, collector.deadlineNanos(), txn -> {
21122112
String keyStr = txn.blockedViaKey == null ? "" : txn.blockedViaKey.toString();
21132113
String txnIdStr = txn.txnId == null || txn.txnId.equals(txnId) ? "" : txn.txnId.toString();
2114-
rows.add(txn.commandStoreId, txn.depth, keyStr, txnIdStr)
2114+
rows.add(txn.depth, txn.commandStoreId, txnIdStr, keyStr)
21152115
.eagerCollect(columns -> {
21162116
columns.add("save_status", txn.saveStatus, TO_STRING)
21172117
.add("execute_at", txn.executeAt, TO_STRING);
@@ -2160,8 +2160,9 @@ private ShardEpochsTable()
21602160
" quorum_fast_privileged_deps int,\n" +
21612161
" quorum_fast_privileged_nodeps int,\n" +
21622162
" token_end 'TokenUtf8Type',\n" +
2163-
" PRIMARY KEY (table_id, token_start, epoch_start DESC)" +
2164-
')', UTF8Type.instance), FAIL, ASC);
2163+
" PRIMARY KEY (table_id, token_start, epoch_start))," +
2164+
" WITH CLUSTERING ORDER BY (token_start, epoch_start DESC)"
2165+
, UTF8Type.instance), FAIL, ASC);
21652166
}
21662167

21672168
@Override

test/unit/org/apache/cassandra/db/virtual/AccordDebugKeyspaceTest.java

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.concurrent.TimeUnit;
3131
import java.util.function.BiPredicate;
3232

33+
import org.junit.After;
3334
import org.junit.Assert;
3435
import org.junit.BeforeClass;
3536
import org.junit.Test;
@@ -44,6 +45,7 @@
4445
import accord.primitives.Status.Durability.HasOutcome;
4546
import accord.primitives.Txn;
4647
import accord.primitives.TxnId;
48+
import org.apache.cassandra.ServerTestUtils;
4749
import org.apache.cassandra.config.Config;
4850
import org.apache.cassandra.config.DatabaseDescriptor;
4951
import org.apache.cassandra.config.OptionaldPositiveInt;
@@ -215,6 +217,11 @@ public static void setUpClass()
215217
requireNetwork();
216218
}
217219

220+
@After
221+
public void afterTest() throws Throwable
222+
{
223+
}
224+
218225
@Test
219226
public void unknownIsEmpty()
220227
{
@@ -492,7 +499,7 @@ public void completedTxn()
492499
getBlocking(accord.node().coordinate(id, txn));
493500
filter.apply.awaitThrowUncheckedOnInterrupt();
494501
spinUntilSuccess(() -> assertRows(execute(QUERY_TXN_BLOCKED_BY, id.toString()),
495-
row(id.toString(), anyInt(), 0, "", "", any(), "Applied")));
502+
row(id.toString(), 0, anyInt(), "", "", any(), "Applied")));
496503
assertRows(execute(QUERY_TXN, id.toString()), row(id.toString(), "Applied"));
497504
assertRows(execute(QUERY_TXN_REMOTE, nodeId, id.toString()), row(id.toString(), "Applied"));
498505
assertRows(execute(QUERY_JOURNAL, id.toString()), row(id.toString(), "PreAccepted"), row(id.toString(), "Applying"), row(id.toString(), "Applied"), row(id.toString(), null));
@@ -577,14 +584,14 @@ public void inflight() throws ExecutionException, InterruptedException
577584

578585
filter.preAccept.awaitThrowUncheckedOnInterrupt();
579586
assertRows(execute(QUERY_TXN_BLOCKED_BY, id.toString()),
580-
row(id.toString(), anyInt(), 0, "", "", any(), anyOf(SaveStatus.PreAccepted.name(), SaveStatus.ReadyToExecute.name())));
587+
row(id.toString(), 0, anyInt(), "", "", any(), anyOf(SaveStatus.PreAccepted.name(), SaveStatus.ReadyToExecute.name())));
581588
assertRows(execute(QUERY_TXN_BLOCKED_BY_REMOTE, nodeId, id.toString()),
582-
row(nodeId, id.toString(), anyInt(), 0, "", "", any(), anyOf(SaveStatus.PreAccepted.name(), SaveStatus.ReadyToExecute.name())));
589+
row(nodeId, id.toString(), 0, anyInt(), "", "", any(), anyOf(SaveStatus.PreAccepted.name(), SaveStatus.ReadyToExecute.name())));
583590
filter.apply.awaitThrowUncheckedOnInterrupt();
584591
assertRows(execute(QUERY_TXN_BLOCKED_BY, id.toString()),
585-
row(id.toString(), anyInt(), 0, "", "", any(), SaveStatus.ReadyToExecute.name()));
592+
row(id.toString(), 0, anyInt(), "", "", any(), SaveStatus.ReadyToExecute.name()));
586593
assertRows(execute(QUERY_TXN_BLOCKED_BY_REMOTE, nodeId, id.toString()),
587-
row(nodeId, id.toString(), anyInt(), 0, "", "", any(), SaveStatus.ReadyToExecute.name()));
594+
row(nodeId, id.toString(), 0, anyInt(), "", "", any(), SaveStatus.ReadyToExecute.name()));
588595
}
589596
finally
590597
{
@@ -619,14 +626,14 @@ public void blocked() throws ExecutionException, InterruptedException
619626

620627
filter.preAccept.awaitThrowUncheckedOnInterrupt();
621628
assertRows(execute(QUERY_TXN_BLOCKED_BY, first.toString()),
622-
row(first.toString(), anyInt(), 0, "", any(), any(), anyOf(SaveStatus.PreAccepted.name(), SaveStatus.ReadyToExecute.name())));
629+
row(first.toString(), 0, anyInt(), "", any(), any(), anyOf(SaveStatus.PreAccepted.name(), SaveStatus.ReadyToExecute.name())));
623630
assertRows(execute(QUERY_TXN_BLOCKED_BY_REMOTE, nodeId, first.toString()),
624-
row(nodeId, first.toString(), anyInt(), 0, "", any(), any(), anyOf(SaveStatus.PreAccepted.name(), SaveStatus.ReadyToExecute.name())));
631+
row(nodeId, first.toString(), 0, anyInt(), "", any(), any(), anyOf(SaveStatus.PreAccepted.name(), SaveStatus.ReadyToExecute.name())));
625632
filter.apply.awaitThrowUncheckedOnInterrupt();
626633
assertRows(execute(QUERY_TXN_BLOCKED_BY, first.toString()),
627-
row(first.toString(), anyInt(), 0, "", any(), anyNonNull(), SaveStatus.ReadyToExecute.name()));
634+
row(first.toString(), 0, anyInt(), "", any(), anyNonNull(), SaveStatus.ReadyToExecute.name()));
628635
assertRows(execute(QUERY_TXN_BLOCKED_BY_REMOTE, nodeId, first.toString()),
629-
row(nodeId, first.toString(), anyInt(), 0, "", any(), anyNonNull(), SaveStatus.ReadyToExecute.name()));
636+
row(nodeId, first.toString(), 0, anyInt(), "", any(), anyNonNull(), SaveStatus.ReadyToExecute.name()));
630637

631638
filter.reset();
632639

@@ -643,15 +650,15 @@ public void blocked() throws ExecutionException, InterruptedException
643650
return rs.size() == 2;
644651
});
645652
assertRows(execute(QUERY_TXN_BLOCKED_BY, second.toString()),
646-
row(second.toString(), anyInt(), 0, "", "", anyNonNull(), SaveStatus.Stable.name()),
647-
row(second.toString(), anyInt(), 1, any(), first.toString(), anyNonNull(), SaveStatus.ReadyToExecute.name()));
653+
row(second.toString(), 0, anyInt(), "", "", anyNonNull(), SaveStatus.Stable.name()),
654+
row(second.toString(), 1, anyInt(), first.toString(), any(), anyNonNull(), SaveStatus.ReadyToExecute.name()));
648655
assertRows(execute(QUERY_TXN_BLOCKED_BY + " AND depth < 1", second.toString()),
649-
row(second.toString(), anyInt(), 0, any(), "", anyNonNull(), SaveStatus.Stable.name()));
656+
row(second.toString(), 0, anyInt(), "", any(), anyNonNull(), SaveStatus.Stable.name()));
650657
assertRows(execute(QUERY_TXN_BLOCKED_BY_REMOTE, nodeId, second.toString()),
651-
row(nodeId, second.toString(), anyInt(), 0, "", "", anyNonNull(), SaveStatus.Stable.name()),
652-
row(nodeId, second.toString(), anyInt(), 1, any(), first.toString(), anyNonNull(), SaveStatus.ReadyToExecute.name()));
658+
row(nodeId, second.toString(), 0, anyInt(), "", "", anyNonNull(), SaveStatus.Stable.name()),
659+
row(nodeId, second.toString(), 1, anyInt(), first.toString(), any(), anyNonNull(), SaveStatus.ReadyToExecute.name()));
653660
assertRows(execute(QUERY_TXN_BLOCKED_BY_REMOTE + " AND depth < 1", nodeId, second.toString()),
654-
row(nodeId, second.toString(), anyInt(), 0, any(), "", anyNonNull(), SaveStatus.Stable.name()));
661+
row(nodeId, second.toString(), 0, anyInt(), "", any(), anyNonNull(), SaveStatus.Stable.name()));
655662
}
656663
finally
657664
{

0 commit comments

Comments
 (0)