Skip to content

Commit

Permalink
Fix 351354342367750L, acceptedOrCommitted state restore
Browse files Browse the repository at this point in the history
Caused by: java.lang.IllegalStateException: [6,9208,0,8] != [0,0,0,0]
	at accord.utils.Invariants.createIllegalState(Invariants.java:76)
	at accord.utils.Invariants.illegalState(Invariants.java:81)
	at accord.utils.Invariants.require(Invariants.java:271)
	at accord.impl.basic.Cluster.verifyConsistentRestore(Cluster.java:938)
	at accord.impl.basic.Cluster.lambda$run$24(Cluster.java:781)
	at accord.impl.basic.RecurringPendingRunnable.run(RecurringPendingRunnable.java:57)
	at accord.impl.basic.Cluster.processNext(Cluster.java:380)
	at accord.impl.basic.Cluster.processPending(Cluster.java:332)
	at accord.impl.basic.Cluster.run(Cluster.java:806)
	at accord.burn.BurnTestBase.burn(BurnTestBase.java:521)
  • Loading branch information
ifesdjeen committed Feb 4, 2025
1 parent 068bc13 commit 122838f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions accord-core/src/main/java/accord/local/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public boolean equals(Object o)
&& saveStatus() == command.saveStatus()
&& durability() == command.durability()
&& Objects.equals(participants(), command.participants())
&& Objects.equals(acceptedOrCommitted(), command.acceptedOrCommitted())
&& Objects.equals(promised(), command.promised());
}

Expand Down
15 changes: 10 additions & 5 deletions accord-core/src/test/java/accord/impl/basic/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import accord.impl.DefaultRemoteListeners;
import accord.impl.DefaultTimeouts;
import accord.impl.DurabilityScheduling;
import accord.impl.InMemoryCommandStore;
import accord.impl.InMemoryCommandStore.GlobalCommand;
import accord.impl.MessageListener;
import accord.impl.PrefixedIntHashKey;
Expand Down Expand Up @@ -762,6 +763,10 @@ public static Map<MessageType, Stats> run(Id[] nodes, int[] prefixes, MessageLis
((DefaultRemoteListeners) nodeMap.get(id).remoteListeners()).clear();
Int2ObjectHashMap<NavigableMap<TxnId, Command>> beforeStores = copyCommands(stores.all());

for (CommandStore store : stores.all())
{
((InMemoryCommandStore) store).clearForTesting();
}
// Re-create all command stores
nodeMap.get(id).commandStores().restoreShardStateUnsafe(t -> {});
stores = nodeMap.get(id).commandStores();
Expand Down Expand Up @@ -927,15 +932,15 @@ private static void verifyConsistentRestore(Int2ObjectHashMap<NavigableMap<TxnId
continue;
}
Invariants.require(isConsistent(beforeCommand.saveStatus(), afterCommand.saveStatus()),
"%s != %s", beforeCommand.saveStatus(), afterCommand.saveStatus());
"%s != %s", beforeCommand.saveStatus(), afterCommand.saveStatus());
Invariants.require(beforeCommand.executeAtOrTxnId().equals(afterCommand.executeAtOrTxnId()),
"%s != %s", beforeCommand.executeAtOrTxnId(), afterCommand.executeAtOrTxnId());
"%s != %s", beforeCommand.executeAtOrTxnId(), afterCommand.executeAtOrTxnId());
Invariants.require(beforeCommand.acceptedOrCommitted().equals(afterCommand.acceptedOrCommitted()),
"%s != %s", beforeCommand.acceptedOrCommitted(), afterCommand.acceptedOrCommitted());
"%s != %s", beforeCommand.acceptedOrCommitted(), afterCommand.acceptedOrCommitted());
Invariants.require(beforeCommand.promised().equals(afterCommand.promised()),
"%s != %s", beforeCommand.promised(), afterCommand.promised());
"%s != %s", beforeCommand.promised(), afterCommand.promised());
Invariants.require(beforeCommand.durability().equals(afterCommand.durability()),
"%s != %s", beforeCommand.durability(), afterCommand.durability());
"%s != %s", beforeCommand.durability(), afterCommand.durability());
}

if (before.size() > store.unsafeCommands().size())
Expand Down

0 comments on commit 122838f

Please sign in to comment.