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/03/02 06:32:40 UTC

[GitHub] [cassandra] bereng commented on a change in pull request #1468: Fix race condition bug during local session repair (CASSANDRA-17335)

bereng commented on a change in pull request #1468:
URL: https://github.com/apache/cassandra/pull/1468#discussion_r817385385



##########
File path: src/java/org/apache/cassandra/repair/consistent/LocalSessions.java
##########
@@ -862,6 +860,25 @@ public void onFailure(Throwable t)
         }, MoreExecutors.directExecutor());
     }
 
+    /**
+     * Checks for the session state, and sets it to prepared unless it is on a failed state.
+     * Making the checks inside a synchronized block to prevent the session state from
+     * being changed between the read and the update.
+     *
+     * @param session The local session to be set to prepared.
+     * @return true if the session is prepared, false if not, i.e. session failed
+     */
+    private boolean prepareSessionExceptFailed(LocalSession session) {

Review comment:
       The suggestion is to add to:
   -  `setStateAndSave()` and argument `currentState` that can be null. If null the method behaves as it does now. If a state is provided it will then compare `state.getState()` to `currentState` and fail or return false if they don't match. Rename the method to `compareAndSaveState`i.e.
   - Add a new `setStateAndSave`method without the `currentState` argument for all calls that don't need the compare behavior.




-- 
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