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

Yifan Cai commented on CASSANDRA-15958:
---------------------------------------

Nice finding! 
I am able to reproduce the race, as long as the 
{{nextExpirationDeadlineUpdater}} that sets {{earliestExpiresAt}} to 
{{Long.MAX_VALUE}} in {{pruneInternalQueueWithLock}} happens after the updater 
in the *last* {{add()}} message call in the test. 

The impact is that the prune task might not be able to prune the queue when 
there is no new message with expiration time that can trigger 
{{pruneWithLock()}} enqueued. But in an operating system, there should be new 
messages enqueued continuously. Therefore, the chance that messages not being 
pruned should be low. 
In the worst case that an expired message is not pruned in the queue, the 
message is still discarded when outbound connection sends the message. It 
checks {{shouldSend()}} when polling from the queue. 
Therefore, it seems a special case in the test. It should not harm in 
production.

Regarding the third alternative, if I understand correctly, without updating 
the {{nextExpirationDeadline}} in the {{add()}} message method, no prune task 
will be scheduled. Because the {{nextExpirationDeadline}} remains 
{{Long.MAX_VALUE}} and {{clock.isAfter(nowNanos, nextExpirationDeadline)}} 
always returns false in the {{maybePruneExpired()}} method.

> org.apache.cassandra.net.ConnectionTest testMessagePurging
> ----------------------------------------------------------
>
>                 Key: CASSANDRA-15958
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15958
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Test/unit
>            Reporter: David Capwell
>            Assignee: Adam Holmberg
>            Priority: Normal
>             Fix For: 4.0-beta
>
>
> Build: 
> https://ci-cassandra.apache.org/job/Cassandra-trunk-test/196/testReport/junit/org.apache.cassandra.net/ConnectionTest/testMessagePurging/
> Build: 
> https://ci-cassandra.apache.org/job/Cassandra-trunk-test/194/testReport/junit/org.apache.cassandra.net/ConnectionTest/testMessagePurging/
> java.util.concurrent.TimeoutException
>       at org.apache.cassandra.net.AsyncPromise.get(AsyncPromise.java:258)
>       at org.apache.cassandra.net.FutureDelegate.get(FutureDelegate.java:143)
>       at 
> org.apache.cassandra.net.ConnectionTest.doTestManual(ConnectionTest.java:268)
>       at 
> org.apache.cassandra.net.ConnectionTest.testManual(ConnectionTest.java:236)
>       at 
> org.apache.cassandra.net.ConnectionTest.testMessagePurging(ConnectionTest.java:679)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to