[ 
https://issues.apache.org/jira/browse/CASSANDRA-19991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17888277#comment-17888277
 ] 

Dmitry Konstantinov commented on CASSANDRA-19991:
-------------------------------------------------

For 5.0 the patch from 4.1 looks applicable..

As I see there were an extra test added in to the same test class for 
CASSANDRA-17821.
The test has 2 places with 
{code:java}
Thread.sleep(2000); // simulate waiting before finishing sampling {code}
I think they can be replaced with ensureThatSamplerExecutorProcessedAllSamples 
logic to make they more predictable + execute faster..

> Unit test 
> org.apache.cassandra.tools.TopPartitionsTest#testServiceTopPartitionsSingleTable
>  is still flaky
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-19991
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-19991
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Test/unit
>            Reporter: Dmitry Konstantinov
>            Assignee: Dmitry Konstantinov
>            Priority: Normal
>             Fix For: 4.0.x, 4.1.x, 5.0.x, 5.x
>
>         Attachments: image-2024-10-09-22-28-39-629.png, 
> image-2024-10-09-22-29-03-576.png
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> org.apache.cassandra.tools.TopPartitionsTest#testServiceTopPartitionsSingleTable
>  fails randomly and quite frequently on CI:
> [https://ci-cassandra.apache.org/view/Cassandra%204.1/job/Cassandra-4.1/521/testReport/org.apache.cassandra.tools/TopPartitionsTest/]
> [https://ci-cassandra.apache.org/job/Cassandra-4.0/726/testReport/junit/org.apache.cassandra.tools/TopPartitionsTest/]
> Based on the source code - the most probably cause of this flakiness is async 
> logic when we submit a sample here: 
> org.apache.cassandra.metrics.Sampler#addSample - the submitted task can 
> executed after we invoke finishLocalSampling(..) within the test.
> The failure can be emulated by adding a synthetic delay to this logic like 
> this:
> {code:java}
> public void addSample(final T item, final int value)
> {
>     if (isEnabled())
>         samplerExecutor.submit(() -> {
>             // ------ synthetic delay -----
>             try
>             {
>                 Thread.sleep(10000);
>             } catch (Exception e) {};
>             // ----------------------- -----
>             insert(item, value);
>         });
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to