Skip to content

NIFI-16468: Return rolled-back FlowFiles to the active queue - #11815

Open
markap14 wants to merge 1 commit into
apache:mainfrom
markap14:nifi-16468
Open

markap14 wants to merge 1 commit into
apache:mainfrom
markap14:nifi-16468

Conversation

@markap14

Copy link
Copy Markdown
Contributor

Summary

NIFI-16468

When a Processor pulls a FlowFile and then rolls the session back, the FlowFile was returned with FlowFileQueue.put(). If the queue is swapping, that method places the FlowFile on the swap queue, behind every FlowFile still in the active queue. putToActive always places it on the active queue, which is where it was when it was pulled.

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-16468
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-16468
  • Pull request contains commits signed with a registered key indicating Verified status

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

StandardProcessSessionIT.testRollbackReturnsFlowFileToFrontOfSwappingQueue queues 10,001 FlowFiles, pulls the first, rolls the session back, and checks that the next pull returns that same FlowFile. TestSwappablePriorityQueue covers the same return path on the queue itself.

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

Session rollback used FlowFileQueue.put(), which places a FlowFile on the swap queue when the queue is swapping. That puts it behind FlowFiles that were already in the active queue.

Co-authored-by: Cursor <cursoragent@cursor.com>
final long expirationEpochMillis = System.currentTimeMillis() + context.getConnectable().getPenalizationPeriod(TimeUnit.MILLISECONDS);
final FlowFileRecord newFile = new StandardFlowFileRecord.Builder().fromFlowFile(record.getOriginal()).penaltyExpirationTime(expirationEpochMillis).build();
originalQueue.put(newFile);
originalQueue.putToActive(newFile);

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.

StatelessFlowTask (lines 397 and 404) also puts polled FlowFiles back with put() when the stateless group fails. Should it use putToActive() too, so the same reordering does not happen there?

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.

No need, in Stateless, we use a StatelessFlowFileQueue which does not support swapping. So the put vs putToActive is irrelevant there.

* ahead of any FlowFiles that are swapped out, and placing it back onto the active queue preserves that ordering.
*
* @param file the FlowFile to place onto the active queue
*/

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.

Should putToActive have a default implementation that calls put(file), so that FlowFileQueue implementations outside this repo keep compiling?

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.

No, there's no way to configure instantiation of FlowFileQueue objects outside of what exists in this repo.

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 meant that the source queue for the Stateless PG comes from port.getIncomingConnections() in the parent PG, not from the stateless engine. Can that queue swap meaning that lines 397 and 404 have the same reordering issue?

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