Skip to content

NIFI-15169 Ensure ExecuteSQLRecord routes streaming failures#10584

Closed
takraj wants to merge 2 commits intoapache:mainfrom
takraj:pr/NIFI-15169_execute_sql_batching_route_to_failure
Closed

NIFI-15169 Ensure ExecuteSQLRecord routes streaming failures#10584
takraj wants to merge 2 commits intoapache:mainfrom
takraj:pr/NIFI-15169_execute_sql_batching_route_to_failure

Conversation

@takraj
Copy link
Copy Markdown
Contributor

@takraj takraj commented Dec 1, 2025

  • Retain incoming FlowFile attributes whenever batching removes the original, so late ResultSet errors have context and can be routed to failure.
  • Recreate the FlowFile from those saved attributes, because commitAsync forces us to remove the original.
  • Add a record-oriented streaming failure test that forces a mocked RecordSetWriter to throw mid-stream and asserts the reconstructed FlowFile still hits REL_FAILURE with original attributes.

Summary

NIFI-15169

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

* Retain incoming `FlowFile` attributes whenever batching removes the
  original, so late `ResultSet` errors have context and can be routed
  to failure.
* Recreate the `FlowFile` from those saved attributes, because
  `commitAsync` forces us to remove the original.
* Add a record-oriented streaming failure test that forces a mocked
  `RecordSetWriter` to throw mid-stream and asserts the reconstructed
  `FlowFile` still hits `REL_FAILURE` with original attributes.
@mark-bathori mark-bathori self-requested a review December 3, 2025 09:42
Copy link
Copy Markdown
Contributor

@mark-bathori mark-bathori left a comment

Choose a reason for hiding this comment

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

Thanks, @takraj, for fixing this issue. The changes overall look good, I have only one minor comment.

if (fileToProcess != null) {
// Need to remove the original input file if it exists,
// but save the attributes to add them to the failure flow file if it is created
if (fileToProcess != null && retainedFlowFileAttributes == null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the retainedFlowFileAttributes == null check is unnecessary. If fileToProcess is not null, we should always store the attributes and remove the FlowFile.

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.

Thank you for pointing this out. I have removed the superfluous condition in: 4d1a81d

@takraj takraj requested a review from mark-bathori December 3, 2025 16:01
Copy link
Copy Markdown
Contributor

@mark-bathori mark-bathori left a comment

Choose a reason for hiding this comment

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

Thanks @takraj for the adjustment.
LGTM +1
Merging.

mark-bathori pushed a commit to mark-bathori/nifi that referenced this pull request Feb 5, 2026
Signed-off-by: Mark Bathori <mbathori@apache.org>

This closes apache#10584.
yisun-anetac pushed a commit to Eng-Anetac/nifi that referenced this pull request Apr 4, 2026
Signed-off-by: Mark Bathori <mbathori@apache.org>

This closes apache#10584.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants