Skip to content

Commit

Permalink
SamplingManager samples before cancelling.
Browse files Browse the repository at this point in the history
Patch by brandonwilliams; reviewed by bereng for CASSANDRA-18065
  • Loading branch information
driftx committed Aug 28, 2023
1 parent a9606c6 commit c611632
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
6 changes: 0 additions & 6 deletions src/java/org/apache/cassandra/metrics/SamplingManager.java
Expand Up @@ -195,12 +195,6 @@ private Runnable createSamplingBeginRunnable(JobId jobId, Iterable<ColumnFamilyS
{
return () ->
{
if (cancelingTasks.contains(jobId))
{
logger.debug("The sampling job of {} is currently canceling. Not issuing a new run.", jobId);
activeSamplingTasks.remove(jobId);
return;
}
List<String> tableNames = StreamSupport.stream(tables.spliterator(), false)
.map(cfs -> String.format("%s.%s", cfs.keyspace, cfs.name))
.collect(Collectors.toList());
Expand Down
9 changes: 3 additions & 6 deletions test/unit/org/apache/cassandra/tools/TopPartitionsTest.java
Expand Up @@ -31,7 +31,6 @@
import javax.management.openmbean.CompositeData;

import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Uninterruptibles;

import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -43,6 +42,8 @@
import org.apache.cassandra.metrics.Sampler;
import org.apache.cassandra.schema.KeyspaceParams;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.Util;


import static java.lang.String.format;
import static org.apache.cassandra.cql3.QueryProcessor.executeInternal;
Expand Down Expand Up @@ -217,11 +218,7 @@ public void testStartAndStopScheduledSampling()

assertTrue("Existing scheduled sampling tasks should be cancellable", ss.stopSamplingPartitions(null, null));

int timeout = 10;
while (timeout-- > 0 && ss.getSampleTasks().size() > 0)
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.MILLISECONDS);

assertEquals("Scheduled sampled tasks should be removed", Collections.emptyList(), ss.getSampleTasks());
Util.spinAssertEquals(Collections.emptyList(), ss::getSampleTasks, 30);

assertTrue("When nothing is scheduled, you should be able to stop all scheduled sampling tasks",
ss.stopSamplingPartitions(null, null));
Expand Down

0 comments on commit c611632

Please sign in to comment.