Vinz2168 commented on code in PR #11885:
URL: https://github.com/apache/nifi/pull/11885#discussion_r4466594609


##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardComponentStateDAO.java:
##########
@@ -108,6 +112,9 @@ private void clearState(final String componentId, final 
ComponentStateDTO compon
 
                 if (hasExactlyOneKeyRemoved(currentClusterState, 
newClusterState)) {
                     manager.setState(newClusterState, Scope.CLUSTER);

Review Comment:
   Good catch, thanks. This race was there before this PR, but it is closely 
tied to this change, so I addressed it here in 45ebb60ef1. Both the cluster and 
local paths now use `manager.replace()` with the `StateMap` that was read. When 
the replace fails in a cluster, the DAO reads the state again. If it already 
matches the requested state (another node applied the same replicated request 
between the read and the replace), the request is a no-op. Otherwise it fails 
with a conflict saying the state was modified concurrently, so a processor 
update is never overwritten. I added unit tests for both interleavings, plus 
local key removal with and without a concurrent update.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to