Mark Payne created NIFI-16495:
---------------------------------

             Summary: ProcessSession can silently drop or overwrite state 
updates when another writer changes state
                 Key: NIFI-16495
                 URL: https://issues.apache.org/jira/browse/NIFI-16495
             Project: Apache NiFi
          Issue Type: Bug
          Components: Core Framework
            Reporter: Mark Payne
            Assignee: Mark Payne


When a {{ProcessSession}} commits a state update made with {{setState}}, 
{{clearState}}, or {{replaceState}}, {{StandardProcessSession}} reads the 
stored state, compares its version with the version the session assigned to its 
own update, and calls {{setState}} only if the two differ. This compares 
against the wrong version. If another writer stores state exactly once after 
the session read it, the versions match and the session's update is silently 
dropped. If the other writer stores state more than once, the session 
overwrites it. The read and the write are also separate calls, so another 
writer can store state between them.

The session should keep the {{StateMap}} it read before building its update 
and, on commit, call {{StateManager.replace}} with that {{StateMap}}. That 
stores the update only if no other writer changed the state since the session 
read it, as the {{ProcessSession.setState}} JavaDoc describes, and does so in 
one call instead of two. Each State Provider's {{replace}} must accept the 
{{StateMap}} instance the session received.




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

Reply via email to