Anurag-S1ngh commented on code in PR #41358:
URL: https://github.com/apache/beam/pull/41358#discussion_r4712216424


##########
sdks/python/apache_beam/runners/worker/statesampler.py:
##########
@@ -156,7 +156,9 @@ def scoped_state(
         step_name=name_context.metrics_name(),
         io_target=io_target)
     if counter_name in self._states_by_name:
-      return self._states_by_name[counter_name]
+      state = self._states_by_name[counter_name]
+      state.set_metrics_container(metrics_container)

Review Comment:
   I ran the same `TestStream` pipeline on Prism with the `statesampler` 
changes reverted. Both the Cython and pure-Python samplers return `{'seen': 2, 
'second_bundle': 1}`. The same test still fails on `BundleBasedDirectRunner` 
with `{'seen': 1}`.
   
   Prism's portable worker reuses the operation's `MetricsContainer` across 
bundles and resets it per bundle, so the cached `ScopedState` keeps pointing at 
the correct container. `BundleBasedDirectRunner` instead creates a new 
container per bundle. The setter only refreshes that execution-context 
reference; it does not change the state's identity or timing data.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to