Skip to content

MINIFICPP-2791 Fix deadlock during C2 flow update#2163

Closed
lordgamez wants to merge 3 commits into
apache:mainfrom
lordgamez:MINIFICPP-2791
Closed

MINIFICPP-2791 Fix deadlock during C2 flow update#2163
lordgamez wants to merge 3 commits into
apache:mainfrom
lordgamez:MINIFICPP-2791

Conversation

@lordgamez
Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/MINIFICPP-2791


Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.

@lordgamez lordgamez marked this pull request as ready for review April 30, 2026 14:41
@martinzink martinzink added priority Review these first bug-fix labels May 4, 2026
@martinzink martinzink requested a review from Copilot May 4, 2026 11:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a reported deadlock during C2-driven flow updates by changing the shutdown/reload ordering around controller services and by making the ProcessGroup on-schedule retry timer teardown thread-safe.

Changes:

  • Parse new flow payload before stopping the running flow, then clear controller services only after timer/scheduler threads are stopped (FlowController).
  • Add a dedicated mutex for ProcessGroup::onScheduleTimer_ access and restructure timer stop/destroy logic to avoid stop/join deadlocks (ProcessGroup).
  • Adjust CallBackTimer destructor locking to avoid potential destructor-time lock contention.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
libminifi/src/FlowController.cpp Reorders flow update steps to defer controller-service clearing until after schedulers/timers are stopped.
libminifi/src/core/ProcessGroup.cpp Adds synchronization and a safer stop/destroy loop for the onSchedule retry timer to prevent deadlocks.
libminifi/include/core/ProcessGroup.h Introduces on_schedule_timer_mutex_ to guard onScheduleTimer_.
core-framework/src/utils/CallBackTimer.cpp Simplifies destructor by removing an extra mutex lock before joining the thread.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libminifi/src/FlowController.cpp Outdated
Comment thread libminifi/src/FlowController.cpp
Comment thread libminifi/src/core/ProcessGroup.cpp
Comment thread libminifi/src/FlowController.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants