Skip to content

[SolaceIO] refactor SolaceIO's writers finishBundle - #39612

Open
stankiewicz wants to merge 3 commits into
apache:masterfrom
stankiewicz:solace_writer_wait_for_response
Open

[SolaceIO] refactor SolaceIO's writers finishBundle#39612
stankiewicz wants to merge 3 commits into
apache:masterfrom
stankiewicz:solace_writer_wait_for_response

Conversation

@stankiewicz

Copy link
Copy Markdown
Contributor

Refactor SolaceIO's writers to block in @FinishBundle until all published persistent messages have received either an acknowledgment (ACK) or a negative acknowledgment (NACK/error) from the Solace broker, up to a timeout.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

…shed persistent messages have received either an acknowledgment (ACK) or a negative acknowledgment (NACK/error) from the Solace broker, up to a timeout.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@stankiewicz stankiewicz changed the title [SolaceIO] refactor SolaceIO's writers finishBunlde [SolaceIO] refactor SolaceIO's writers finishBundle Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

publishResults(context, messageIdsToAck);
if (!messageIdsToAck.isEmpty()) {
try {
Thread.sleep(10);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This will increase my project's test suite run by 10x :) Maybe this could be done without sleep, e.g. the waiting thread is woken up as soon as Solace callback with the ack arrives, and then checks the ack queue.

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.13%. Comparing base (4fd1744) to head (a1173bb).
⚠️ Report is 294 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #39612      +/-   ##
============================================
+ Coverage     58.12%   58.13%   +0.01%     
- Complexity    13086    13089       +3     
============================================
  Files          2521     2522       +1     
  Lines        264308   264352      +44     
  Branches      10786    10788       +2     
============================================
+ Hits         153616   153670      +54     
+ Misses       104922   104919       -3     
+ Partials       5770     5763       -7     
Flag Coverage Δ
java 64.26% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stankiewicz

Copy link
Copy Markdown
Contributor Author

fixes #39589

@stankiewicz

Copy link
Copy Markdown
Contributor Author

status: under testing by @ppawel .

@chamikaramj chamikaramj left a comment

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.

Thanks!


publishResults(BeamContextWrapper.of(context));
if (getDeliveryMode() == DeliveryMode.PERSISTENT && messageIdsToAck != null) {
waitForAcks(BeamContextWrapper.of(context), messageIdsToAck);

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.

Don't we need to invoke publishResults in this path as well ?

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.

waitForAcks is waiting for Acks and publishing results in it.

@OnTimer("bundle_flusher")
public void flushBundle(OnTimerContext context) throws IOException {
publishResults(BeamContextWrapper.of(context));
publishResults(BeamContextWrapper.of(context), 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.

What would happen if the same results get published via this timer and the finishBundle above ? If this is safe, probably add a comment to clarify.

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.

that is good point. publishResults is removing data from queue so it won't happen. In future or even this pr I also want to remove timer as it is not needed anymore. It was something also that shouldn't work correctly in batch.

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.

@chamikaramj I've removed timer.

public void waitForAcks(BeamContextWrapper context, Set<String> messageIdsToAck) {
BlockingQueue<PublishResult> queue =
solaceSessionServiceWithProducer().getPublishedResultsQueue();
long timeoutMs = System.currentTimeMillis() + ACKS_FLUSHING_INTERVAL_SECS * 1000;

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 we use exponential backoff here and set a larger overall timeout (O (minutes)) to support potentially large bundles and/or API rate limit issues ?

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.

so the tiny cost here will be cpu of worker on checking the queue. there is no api rate limit issue as different thread is publishing to the queue.

public void finishBundle(FinishBundleContext context) {
publishResults(BeamContextWrapper.of(context));
if (getDeliveryMode() == DeliveryMode.PERSISTENT) {
waitForAcks(BeamContextWrapper.of(context), messageIdsToAck);

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.

Ditto.

@ppawel

ppawel commented Aug 18, 2026

Copy link
Copy Markdown

From my testing it looks OK so far, all input elements have an output element (Solace publishing result).

I tested both in streaming pipelines and batch pipelines.

I am only testing using the default writer type (BATCHED). Does it make sense to also test it with the STREAMING writer type? I think I will do that as in fact we might consider switching writer types at some point... will report back.

@stankiewicz

Copy link
Copy Markdown
Contributor Author

From my testing it looks OK so far, all input elements have an output element (Solace publishing result).

I tested both in streaming pipelines and batch pipelines.

I am only testing using the default writer type (BATCHED). Does it make sense to also test it with the STREAMING writer type? I think I will do that as in fact we might consider switching writer types at some point... will report back.

Paweł, committed new version, it doesn't change too much, it's still stateful, but I've removed timer which wasn't needed as all ACKs are received and it was invalid for batch pipelines.

Regarding STREAMING, it is waiting for ACK on finishBundle, similarly to BATCHED mode, you should see same improvement there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants