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

Dmitry Konstantinov commented on CASSANDRA-21845:
-------------------------------------------------

It is a concurrency bug in the test code:
1. One thread inserts the statement via preparedStatements.get(id, fn) to 
Caffeine cache. Inside the cache we have ConcurrentHashMap.compute(). That 
method makes the new entry visible before it increments the ConcurrentHashMap's 
size.
2. A second thread waiting on the same ConcurrentHashMap's lock wakes up as 
soon as it is released. It finds the entry and builds new HashMap<>(asMap()).
3. HashMap.putMapEntries() calls m.size() first and only copies entries if (s > 
0). Caffeine's size() delegates to ConcurrentHashMap.size(), which can still be 
0 at this point. The copy comes back empty, so containsKey returns false




> Flaky test: PreparedStatementTest.testPreparedStatementStaysInCache
> -------------------------------------------------------------------
>
>                 Key: CASSANDRA-21845
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21845
>             Project: Apache Cassandra
>          Issue Type: Bug
>          Components: Test/unit
>            Reporter: Dmitry Konstantinov
>            Assignee: Dmitry Konstantinov
>            Priority: Normal
>              Labels: green_ci
>
> https://astro-cass.ci/job/cassandra-5.0/48/testReport/junit/org.apache.cassandra.cql3.validation.miscellaneous/PreparedStatementTest/Tests___test_jdk17_3_16___testPreparedStatementStaysInCache__jdk17_x86_64/



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to