Skip to content

Commit fdfb343

Browse files
committed
fix SafeRedundantBefore initialisation
1 parent 91ba2f0 commit fdfb343

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/java/org/apache/cassandra/service/accord/AccordCommandStore.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,14 +545,21 @@ public void unsafeUpsertRedundantBefore(RedundantBefore addRedundantBefore)
545545
super.unsafeUpsertRedundantBefore(addRedundantBefore);
546546
}
547547

548+
@VisibleForTesting
549+
public void unsafeUpdateRangesForEpoch()
550+
{
551+
super.unsafeUpdateRangesForEpoch();
552+
safeRedundantBefore = new SafeRedundantBefore(0, unsafeGetRedundantBefore());
553+
}
554+
548555
public static class AccordCommandStoreReplayer extends AbstractReplayer
549556
{
550557
private final AccordCommandStore commandStore;
551558
private final boolean onlyNonDurable;
552559

553560
private AccordCommandStoreReplayer(AccordCommandStore commandStore, boolean onlyNonDurable)
554561
{
555-
super(commandStore);
562+
super(commandStore, null);
556563
this.commandStore = commandStore;
557564
this.onlyNonDurable = onlyNonDurable;
558565
}
@@ -579,12 +586,16 @@ public AsyncChain<Route> replay(TxnId txnId)
579586

580587
void maybeLoadRedundantBefore(RedundantBefore redundantBefore)
581588
{
589+
Invariants.require(safeRedundantBefore == null);
582590
if (redundantBefore != null)
583591
{
584592
loadRedundantBefore(redundantBefore);
585-
Invariants.require(safeRedundantBefore == null);
586593
safeRedundantBefore = new SafeRedundantBefore(0, redundantBefore);
587594
}
595+
else
596+
{
597+
safeRedundantBefore = new SafeRedundantBefore(0, this.unsafeGetRedundantBefore());
598+
}
588599
}
589600

590601
void maybeLoadBootstrapBeganAt(NavigableMap<TxnId, Ranges> bootstrapBeganAt)

src/java/org/apache/cassandra/service/accord/AccordJournal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ public ReplayStream(CommandStore commandStore)
630630
this.commandStore = commandStore;
631631
this.replayer = (AbstractReplayer) commandStore.replayer();
632632
// Keys in the index are sorted by command store id, so index iteration will be sequential
633-
this.iter = journalTable.keyIterator(new JournalKey(replayer.minReplay, COMMAND_DIFF, commandStore.id()), new JournalKey(TxnId.MAX.withoutNonIdentityFlags(), COMMAND_DIFF, commandStore.id()), false);
633+
this.iter = journalTable.keyIterator(new JournalKey(replayer.minReplay.withoutNonIdentityFlags(), COMMAND_DIFF, commandStore.id()), new JournalKey(TxnId.MAX.withoutNonIdentityFlags(), COMMAND_DIFF, commandStore.id()), false);
634634
}
635635

636636
boolean replay()

test/distributed/org/apache/cassandra/service/accord/AccordJournalBurnTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import accord.utils.PersistentField;
5555
import accord.utils.RandomSource;
5656
import org.apache.cassandra.ServerTestUtils;
57+
import org.apache.cassandra.config.DatabaseDescriptor;
5758
import org.apache.cassandra.db.ColumnFamilyStore;
5859
import org.apache.cassandra.db.Directories;
5960
import org.apache.cassandra.db.Keyspace;
@@ -69,6 +70,7 @@
6970
import org.apache.cassandra.io.sstable.format.SSTableReader;
7071
import org.apache.cassandra.io.util.File;
7172
import org.apache.cassandra.journal.Journal;
73+
import org.apache.cassandra.journal.Params;
7274
import org.apache.cassandra.journal.SegmentCompactor;
7375
import org.apache.cassandra.journal.StaticSegment;
7476
import org.apache.cassandra.journal.TestParams;
@@ -140,7 +142,8 @@ public void beforeTest() throws Throwable
140142
@Test
141143
public void testOne()
142144
{
143-
long seed = System.nanoTime();
145+
// long seed = System.nanoTime();
146+
long seed = 31954502422236224L;
144147
int operations = 1000;
145148

146149
logger.info("Seed: {}", seed);

0 commit comments

Comments
 (0)