[
https://issues.apache.org/jira/browse/BEAM-8537?focusedWorklogId=370084&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-370084
]
ASF GitHub Bot logged work on BEAM-8537:
----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Jan/20 21:18
Start Date: 10/Jan/20 21:18
Worklog Time Spent: 10m
Work Description: boyuanzz commented on pull request #10375: [BEAM-8537]
Provide WatermarkEstimator to track watermark
URL: https://github.com/apache/beam/pull/10375#discussion_r365434163
##########
File path: sdks/python/apache_beam/runners/common.py
##########
@@ -771,22 +810,33 @@ def try_split(self, fraction):
# Temporary workaround for [BEAM-7473]: get current_watermark before
# split, in case watermark gets advanced before getting split results.
# In worst case, current_watermark is always stale, which is ok.
- if self.watermark_estimator:
- current_watermark = self.watermark_estimator.current_watermark()
- else:
- current_watermark = None
+ current_watermark = None
split = restriction_tracker.try_split(fraction)
if split:
primary, residual = split
element = self.current_windowed_value.value
restriction_provider = self.signature.get_restriction_provider()
primary_size = restriction_provider.restriction_size(element, primary)
residual_size = restriction_provider.restriction_size(element,
residual)
- return (
- ((self.current_windowed_value.with_value((
- (element, primary), primary_size)), None), None),
- ((self.current_windowed_value.with_value((
- (element, residual), residual_size)), current_watermark),
None))
+ if self.threadsafe_watermark_estimator:
+ current_watermark = (
Review comment:
Right that's the issue. Here are 2 options:
- Get watermark before splitting like what we did before. The worse case is
we always get earlier watermark then the realistic one.
- Create a synchronized_lock inside the DoFnInvoker, and pass this lock into
`ThreadsafeRestrictionTracker` and `ThreadsafeWatermarkEstimator`.
Take`ThreadsafeWatermarkEstimator` as an example:For the updating method, we
have 2-level locking:
```python
try_claim():
with self.synchronized_lock:
with self._lock:
implementation
try_split():
with self._lock:
implementation
```
In `DoFnInvoker.try_split`:
````python
with self.synchronized_lock:
self.threadsafe_restriction_tacker.try_split()
self.threadsafe_watermark_estimator.current_watermark()
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 370084)
Time Spent: 3h (was: 2h 50m)
> Provide WatermarkEstimatorProvider for different types of WatermarkEstimator
> ----------------------------------------------------------------------------
>
> Key: BEAM-8537
> URL: https://issues.apache.org/jira/browse/BEAM-8537
> Project: Beam
> Issue Type: Improvement
> Components: sdk-py-core, sdk-py-harness
> Reporter: Boyuan Zhang
> Assignee: Boyuan Zhang
> Priority: Major
> Time Spent: 3h
> Remaining Estimate: 0h
>
> This is a follow up for in-progress PR:
> https://github.com/apache/beam/pull/9794.
> Current implementation in PR9794 provides a default implementation of
> WatermarkEstimator. For further work, we want to let WatermarkEstimator to be
> a pure Interface. We'll provide a WatermarkEstimatorProvider to be able to
> create a custom WatermarkEstimator per windowed value. It should be similar
> to how we track restriction for SDF:
> WatermarkEstimator <---> RestrictionTracker
> WatermarkEstimatorProvider <---> RestrictionTrackerProvider
> WatermarkEstimatorParam <---> RestrictionDoFnParam
--
This message was sent by Atlassian Jira
(v8.3.4#803005)