Skip to content

MINIFICPP-2771 Use separate state managers in schedule and trigger threads#2157

Open
lordgamez wants to merge 6 commits intoapache:mainfrom
lordgamez:MINIFICPP-2771
Open

MINIFICPP-2771 Use separate state managers in schedule and trigger threads#2157
lordgamez wants to merge 6 commits intoapache:mainfrom
lordgamez:MINIFICPP-2771

Conversation

@lordgamez
Copy link
Copy Markdown
Contributor

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


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.

Comment thread extension-framework/include/utils/ListingStateManager.h Outdated
Comment thread extensions/aws/s3/MultipartUploadStateStorage.cpp Outdated
Comment thread extensions/aws/s3/S3Wrapper.cpp Outdated
@martinzink martinzink requested review from martinzink and removed request for martinzink April 13, 2026 11:39
@martinzink martinzink added the priority Review these first label Apr 13, 2026
@lordgamez lordgamez marked this pull request as ready for review April 14, 2026 08:21
@szaszm szaszm self-requested a review April 14, 2026 10:42
@martinzink martinzink self-requested a review April 15, 2026 10:21
void StatefulProcessor::onTrigger(core::ProcessContext&, core::ProcessSession&) {
void StatefulProcessor::onTrigger(core::ProcessContext& context, core::ProcessSession&) {
std::lock_guard<std::mutex> lock(mutex_);
state_manager_ = context.getStateManager();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i know this is test code, but I think it would be clearer if state_manager_ would cease to be a member and only live on the stack during the onschedule and ontrigger

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated in f9e15ed

std::chrono::system_clock::time_point start_push_time_;
std::vector<std::shared_ptr<core::FlowFile>> batched_flowfiles_;
core::StateManager* state_manager_;
core::StateManager* state_manager_ = nullptr;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we remove this member and only use the state manager in the ontirgger and onschedule as a stack variabl?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is only used as part of the LogBatch object, but I added a gsl::finally directive to clear it at the end of the onTrigger to be sure in f9e15ed

Copy link
Copy Markdown
Member

@szaszm szaszm left a comment

Choose a reason for hiding this comment

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

I'm +1 for this after Martin's comments are resolved. I can see that this design is far from the best, but any better design would require thorough refactoring of core APIs, and I can't suggest a better low impact fix.

@fgerlits fgerlits self-requested a review April 15, 2026 12:25
Comment thread extensions/grafana-loki/PushGrafanaLoki.cpp Outdated
Comment thread extensions/sftp/processors/ListSFTP.cpp
Comment thread extensions/sql/processors/QueryDatabaseTable.cpp Outdated
Comment thread libminifi/src/core/ProcessContextImpl.cpp
Comment thread extensions/standard-processors/processors/TailFile.h Outdated
Comment thread extensions/systemd/tests/ConsumeJournaldTest.cpp Outdated
Comment thread extensions/aws/processors/ListS3.cpp
Comment thread minifi-api/include/minifi-cpp/core/ProcessContext.h Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority Review these first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants