[
https://issues.apache.org/jira/browse/NIFI-15801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18073502#comment-18073502
]
ASF subversion and git services commented on NIFI-15801:
--------------------------------------------------------
Commit a68e129e11ac2420c1491fbe7a3cb52d32f06964 in nifi's branch
refs/heads/main from Kevin Doran
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=a68e129e11a ]
NIFI-15801 Stop processors in synchronizeProcessors before updating (#11111)
* NIFI-15801 Stop processors in synchronizeProcessors before updating
synchronizeProcessors() calls updateProcessor() which requires the
processor to be stopped (setAnnotationData throws IllegalStateException
if isRunning). The NiFi REST path stops affected processors before
calling synchronizeFlow, but the Connector applyUpdate path does not,
exposing this gap.
Stop processors via stopOrTerminate before updateProcessor, matching
the single-processor synchronize(ProcessorNode, ...) path. Track
stopped processors and restart them in a finally block, matching
the pattern used in synchronizeProcessGroupSettings.
> StandardVersionedComponentSynchronizer.synchronizeProcessors fails when
> processors are running
> ----------------------------------------------------------------------------------------------
>
> Key: NIFI-15801
> URL: https://issues.apache.org/jira/browse/NIFI-15801
> Project: Apache NiFi
> Issue Type: Task
> Components: Core Framework
> Reporter: Kevin Doran
> Assignee: Kevin Doran
> Priority: Minor
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> `StandardVersionedComponentSynchronizer.synchronizeProcessors()` calls
> `updateProcessor()` without first stopping the processor. `updateProcessor()`
> begins with `processor.setAnnotationData(...)`, and
> `StandardProcessorNode.setAnnotationData()` throws `IllegalStateException` if
> the processor is running.
> This was never triggered before the introduction of Connectors, because the
> NiFi REST API `FlowUpdateResource.updateFlow()` explicitly stops all affected
> processors and disables affected controller services *before* calling
> `StandardProcessGroup.updateFlow()` -> `synchronizeFlow()` -> `synchronize()`
> -> `synchronizeProcessors()`.
> The Connector framework's `applyUpdate` path, introduced in NIFI-15258, calls
> `StandardProcessGroup.updateFlow()` directly without stopping processors
> first, exposing this gap.
> The single-processor synchronization path (`synchronize(ProcessorNode,
> VersionedProcessor, ...)`) already correctly calls `stopOrTerminate()` before
> `updateProcessor()`. The group-level `synchronizeProcessors()` was relying on
> the caller to have stopped processors, which was a valid assumption for the
> REST path.
> **Steps to Reproduce:**
> 1. Start a Connector
> 2. While the connector is running, change a configuration property that
> affects an existing processor in the flow.
> 3. Call `applyUpdate()`.
> **Expected:** The flow is updated successfully; affected processors are
> stopped, updated, and restarted.
> **Actual:** `FlowUpdateException` wrapping `IllegalStateException: Cannot set
> AnnotationData on CaptureChangePostgreSQL[...] while processor is running`.
> **Fix:** Stop running processors in `synchronizeProcessors()` before calling
> `updateProcessor()`, matching the pattern used in `synchronize(ProcessorNode,
> ...)` and `synchronizeProcessGroupSettings()`. Track which processors were
> stopped and restart them in a `finally` block to ensure they are restarted
> even if the update fails.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)