You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/02/17 18:22:00 UTC

[GitHub] [cassandra] yifan-c commented on a change in pull request #1452: Fix Flaky testNoSuchRepairSessionAnticompaction

yifan-c commented on a change in pull request #1452:
URL: https://github.com/apache/cassandra/pull/1452#discussion_r809342623



##########
File path: src/java/org/apache/cassandra/repair/consistent/LocalSessions.java
##########
@@ -828,16 +828,19 @@ public void onSuccess(@Nullable List<Void> result)
             {
                 try
                 {
-                    logger.info("Prepare phase for incremental repair session {} completed", sessionID);
-                    if (session.getState() != FAILED)
-                        setStateAndSave(session, PREPARED);
-                    else
-                        logger.info("Session {} failed before anticompaction completed", sessionID);
+                    synchronized (session)

Review comment:
       The synchronized scope is a bit too large. I think you only need to make the two operations, `getState` and `setStateAndSave` atomic. You can make the synchronized block to cover the if..else.. statement.
   
   One small step forward, you can probably add a `prepareSessionExceptFailed` method to wrap the get and set logic, e.g.
   ```java
       /**
        * return true if prepared. Return false if not, i.e. session faield
        */
       boolean prepareSessionExceptFailed(LocalSession session)
   ```




-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org