Skip to content
Permalink
Browse files
Avoid removing batch when it's not created during view replication
patch by Zhao Yang, Ekaterina Dimitrova; reviewed by Zhao Yang, Ekaterina Dimitrova, Brandon Williams for CASSANDRA-16175

Co-authored-by: Zhao Yang <zhao.yang@datastax.com>
Co-authored-by: Ekaterina Dimitrova <ekaterina.dimitrova@datastax.com>
  • Loading branch information
ekaterinadimitrova2 and zhaoyang1991 committed Sep 7, 2021
1 parent 267d3ce commit 57f53f53ae811f00cf9c1f84bd0414d99391f1ce
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
@@ -1,4 +1,5 @@
3.0.26:
* Avoid removing batch when it's not created during view replication (CASSANDRA-16175)
* Make the addition of regular column to COMPACT tables throw an InvalidRequestException (CASSANDRA-14564)
* Fix materialized view schema backup as table (CASSANDRA-12734)
* Avoid signaling DigestResolver until the minimum number of responses are guaranteed to be visible (CASSANDRA-16883)
@@ -107,9 +107,14 @@ public BatchlogCleanup(int mutationsWaitingFor, BatchlogCleanupCallback callback
this.callback = callback;
}

public int decrement()
{
return mutationsWaitingForUpdater.decrementAndGet(this);
}

public void ackMutation()
{
if (mutationsWaitingForUpdater.decrementAndGet(this) == 0)
if (decrement() == 0)
callback.invoke();
}
}
@@ -873,7 +873,8 @@ public static void mutateMV(ByteBuffer dataKey, Collection<Mutation> mutations,
{
mutation.apply(writeCommitLog);
nonLocalMutations.remove(mutation);
cleanup.ackMutation();
// won't trigger cleanup
cleanup.decrement();
}
catch (Exception exc)
{
@@ -119,6 +119,25 @@ public void testNonExistingOnes() throws Throwable
execute("DROP MATERIALIZED VIEW IF EXISTS keyspace_does_not_exist.view_does_not_exist");
}

@Test
public void testNoBatchlogCleanupForLocalMutations() throws Throwable
{
execute("USE " + keyspace());
executeNet(protocolVersion, "USE " + keyspace());

createTable("CREATE TABLE %s (k1 int primary key, v1 int)");
createView("view1", "CREATE MATERIALIZED VIEW view1 AS SELECT * FROM %%s WHERE k1 IS NOT NULL AND v1 IS NOT NULL PRIMARY KEY (v1, k1)");

ColumnFamilyStore batchlog = Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHES);
batchlog.disableAutoCompaction();
batchlog.forceBlockingFlush();
int batchlogSSTables = batchlog.getLiveSSTables().size();

updateView("INSERT INTO %s(k1, v1) VALUES(?, ?)", 1, 1);
batchlog.forceBlockingFlush();
assertEquals(batchlogSSTables, batchlog.getLiveSSTables().size());
}

@Test
public void testExistingRangeTombstoneWithFlush() throws Throwable
{

0 comments on commit 57f53f5

Please sign in to comment.