Skip to content

fix user metrics in @OnTimer#35050

Closed
liferoad wants to merge 2 commits intoapache:masterfrom
liferoad:fix-user-metrics-timer
Closed

fix user metrics in @OnTimer#35050
liferoad wants to merge 2 commits intoapache:masterfrom
liferoad:fix-user-metrics-timer

Conversation

@liferoad
Copy link
Contributor

Fixes #29099


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.

@github-actions github-actions bot added the java label May 26, 2025
@github-actions
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@liferoad liferoad requested review from kennknowles and scwhittle May 26, 2025 20:05
@github-actions
Copy link
Contributor

Assigning reviewers:

R: @chamikaramj 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).

Copy link
Member

@kennknowles kennknowles left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

Copy link
Contributor

@scwhittle scwhittle left a comment

Choose a reason for hiding this comment

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

Sorry thought I replied this draft comment earlier

currentTimeDomain = timeDomain;
doFnInvoker.invokeOnTimer(timerId, timerFamilyId, onTimerContext);
// Finalize state to ensure metrics and other state changes are committed.
this.stateAccessor.finalizeState();
Copy link
Contributor

Choose a reason for hiding this comment

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

this is going to result in finalizeState being called multiple times if there are multiple timers.

But it also seems that this shouldn't be needed because finalizeState is already called in finishBundle. Is that not being called for some reason? The reported bug is old, have you verified that it is still present? If so adding a test that fails without a fix would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't verified this and just want to create the PR to get some feedback from you. I noticed this.stateAccessor.finalizeState has been called in other places (e.g., sdks/java/harness/src/main/java/org/apache/beam/fn/harness/SplittableSplitAndSizeRestrictionsDoFnRunner.java) outside finishBundle. Not fully understand the code but want to put this PR out for some feedback first.

@github-actions
Copy link
Contributor

Reminder, please take a look at this pr: @chamikaramj

@github-actions
Copy link
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @robertwb for label java.

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)

@github-actions
Copy link
Contributor

Reminder, please take a look at this pr: @robertwb

@github-actions
Copy link
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @Abacn for label java.

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)

@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2025

Reminder, please take a look at this pr: @Abacn

@scwhittle
Copy link
Contributor

@liferoad I don't think this is needed. I added a test in #35494 and counter plumbing appears to be working without any change.

That test also verifies that finishBundle is called which would flush the state. I'm not sure either how the state flushing would be tied to user counters.

@liferoad
Copy link
Contributor Author

liferoad commented Jul 1, 2025

Sounds good. Thanks for checking this. I will also close the issue.

@liferoad liferoad closed this Jul 3, 2025
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.

[Bug]: FnAPI Java SDK Harness doesn't update user counters in OnTimer callback functions

3 participants