maedhroz commented on code in PR #3700:
URL: https://github.com/apache/cassandra/pull/3700#discussion_r2452637476
##########
test/distributed/org/apache/cassandra/distributed/test/SecondaryIndexTest.java:
##########
@@ -122,4 +133,44 @@ public void test_only_coordinator_chooses_index_for_query()
});
}
}
+
+ @Test
+ public void test_secondary_rebuild_with_small_memtable_memory()
+ {
+ // populate data
+ for (int i = 0 ; i < 100 ; ++i)
+ cluster.coordinator(1).execute(String.format("INSERT INTO %s (k,
v) VALUES (?, ?)", tableName), ConsistencyLevel.ALL, i,
ValueGenerator.randomString(new Random(), 50000));
+
+ cluster.forEach(i -> i.flush(KEYSPACE));
+
+ // restart node 1 with small memtable allocation so that index rebuild
will cause memtable flush which will need
+ // to reclaim the memory. see CASSANDRA-19564
+ waitOn(cluster.get(1).shutdown());
+ Object originalMemTableHeapSpace =
cluster.get(1).config().get("memtable_heap_space");
+ cluster.get(1).config().set("memtable_heap_space", "1MiB");
+ cluster.get(1).startup();
+ String tableNameWithoutKeyspaceName = tableName.split("\\.")[1];
+ String indexName = String.format("v_index_%d", seq.get());
+ Runnable task = cluster.get(1).runsOnInstance(
+ () -> {
+ ColumnFamilyStore cfs =
Keyspace.open(KEYSPACE).getColumnFamilyStore(tableNameWithoutKeyspaceName);
+
cfs.indexManager.rebuildIndexesBlocking(Sets.newHashSet(Arrays.asList(indexName)));
+ }
+ );
+ ExecutorService es = Executors.newFixedThreadPool(1);
+ Future<?> future = es.submit(task);
+ try
+ {
+ future.get(30, TimeUnit.SECONDS);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ Assert.fail("Rebuild should finish within 30 seconds without
issue.");
+ }
+ finally
+ {
+ cluster.get(1).config().set("memtable_heap_space",
originalMemTableHeapSpace);
Review Comment:
There would still need to be a restart here though, right? If this test runs
first, the `memtable_heap_space` change won't be picked up by subsequent tests,
as initial node starts happen in `@BeforeClass`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]