[ 
https://issues.apache.org/jira/browse/NIFI-16294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18111602#comment-18111602
 ] 

ASF subversion and git services commented on NIFI-16294:
--------------------------------------------------------

Commit e8fd070f953e976cfb7841dddd81f199a597970a in nifi's branch 
refs/heads/main from Sönke Liebau
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=e8fd070f953 ]

NIFI-16294 Guard against null controller status in 
SiteToSiteStatusReportingTask (#11627)

Signed-off-by: David Handermann <[email protected]>

> NPE in SiteToSiteStatusReportingTask when root flow is unavailable
> ------------------------------------------------------------------
>
>                 Key: NIFI-16294
>                 URL: https://issues.apache.org/jira/browse/NIFI-16294
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 2.11.0
>         Environment: Observed when running 2.9.0 on Kubernetes, but 
> objectively unrelated to the environment.
>            Reporter: Sönke Liebau
>            Assignee: Sönke Liebau
>            Priority: Minor
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> We recently encountered infrequent NullPointerExceptions when using the 
> SiteToSiteStatusReportingTask in NiFi. We looked at the code and investigated 
> in the cluster and usually those Exceptions correlated to cluster nodes 
> restarting and rejoining the cluster.
> {code:java}
> SiteToSiteStatusReportingTask[id=xxx] Error running task 
> SiteToSiteStatusReportingTask[id=xxx]: java.lang.NullPointerException
> {code}
> *Other issues*
> NIFI-7105 sounds very similar to this, but is not in fact related.
> *Root cause*
> We think we found the root cause and a possible fix, I'll open a PR to 
> facilitate discussion on the code as well soon.
> The SiteToSiteStatusReportingTask calls 
> context.getEventAccess().getControllerStatus() in 
> [onTrigger|https://github.com/apache/nifi/blob/f5e20e3687f3eee9fecb3a6b59a5b542390616ef/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteStatusReportingTask.java#L126],
>  which returns
> null when the root process group isn't available (e.g. during startup before 
> the flow is fully initialized, or when nodes join).
> The line immediately following that line guards against `null` when 
> retrieving the name, but [further 
> down|https://github.com/apache/nifi/blob/f5e20e3687f3eee9fecb3a6b59a5b542390616ef/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteStatusReportingTask.java#L146]
>  the result of getControllerStatus is passed on directly to deserialization, 
> which throws an Exception in the case of `null`.
> *Fix*
> For a potential fix I looked at the 
> [SiteToSiteMetricsReportingTask|https://github.com/apache/nifi/blob/f5e20e3687f3eee9fecb3a6b59a5b542390616ef/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/SiteToSiteMetricsReportingTask.java#L160]
>  , which already guards against `null` and skips execution in that case
> Something similar should be done in the StatusReporting task to skip the 
> trigger, when the status cannot be retrieved.
> I'm happy to open a PR to discuss directly on the code.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to