You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "je-ik (via GitHub)" <gi...@apache.org> on 2025/01/15 14:49:59 UTC
[PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
je-ik opened a new pull request, #33606:
URL: https://github.com/apache/beam/pull/33606
Fixes #31313
------------------------
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](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "je-ik (via GitHub)" <gi...@apache.org>.
je-ik commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1920702553
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -111,10 +131,19 @@ public void handleSplitRequest(int subtaskId, @Nullable String requesterHostname
@Override
public void addSplitsBack(List<FlinkSourceSplit<T>> splits, int subtaskId) {
- LOG.info("Adding splits {} back from subtask {}", splits, subtaskId);
- List<FlinkSourceSplit<T>> splitsForSubtask =
- pendingSplits.computeIfAbsent(subtaskId, ignored -> new ArrayList<>());
- splitsForSubtask.addAll(splits);
+ // reshuffle splits, needed after rescaling
Review Comment:
I see. The code was originally to solve the rescaling issue, but the whole process works a little differently and the corner case that this might solve is highly speculative, so I reverted the code to the previous version.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "dmvk (via GitHub)" <gi...@apache.org>.
dmvk commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1918732296
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSource.java:
##########
@@ -73,18 +71,6 @@ public static <T> FlinkUnboundedSource<T> unbounded(
return new FlinkUnboundedSource<>(stepName, source, serializablePipelineOptions, numSplits);
}
- public static FlinkUnboundedSource<byte[]> unboundedImpulse(long shutdownSourceAfterIdleMs) {
Review Comment:
🤦
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #33606:
URL: https://github.com/apache/beam/pull/33606#issuecomment-2593240868
Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
R: @johnjcasey added as fallback since no labels match configuration
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).
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #33606:
URL: https://github.com/apache/beam/pull/33606#issuecomment-2595814594
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment `assign set of reviewers`
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "je-ik (via GitHub)" <gi...@apache.org>.
je-ik commented on PR #33606:
URL: https://github.com/apache/beam/pull/33606#issuecomment-2595800676
R: @dmvk
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "je-ik (via GitHub)" <gi...@apache.org>.
je-ik commented on PR #33606:
URL: https://github.com/apache/beam/pull/33606#issuecomment-2596000768
> The fix makes sense, good catch 👍 My main question is whether not re-listing partitions breaks the contract or not 🤔
No, under the legary Source Read API, splitting the source is a one-shot operation.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #33606:
URL: https://github.com/apache/beam/pull/33606#issuecomment-2602434718
## [Codecov](https://app.codecov.io/gh/apache/beam/pull/33606?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 57.38%. Comparing base [(`e1245d9`)](https://app.codecov.io/gh/apache/beam/commit/e1245d9da136805ab5d40710e968b472b215b6c4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`960fe79`)](https://app.codecov.io/gh/apache/beam/commit/960fe797c88c4d7ff8476df16be21e65a1e31612?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 211 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #33606 +/- ##
=========================================
Coverage 57.38% 57.38%
Complexity 1474 1474
=========================================
Files 973 973
Lines 154624 154624
Branches 1076 1076
=========================================
Hits 88733 88733
Misses 63689 63689
Partials 2202 2202
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/beam/pull/33606?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "je-ik (via GitHub)" <gi...@apache.org>.
je-ik merged PR #33606:
URL: https://github.com/apache/beam/pull/33606
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "je-ik (via GitHub)" <gi...@apache.org>.
je-ik commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1918677923
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -111,10 +131,19 @@ public void handleSplitRequest(int subtaskId, @Nullable String requesterHostname
@Override
public void addSplitsBack(List<FlinkSourceSplit<T>> splits, int subtaskId) {
- LOG.info("Adding splits {} back from subtask {}", splits, subtaskId);
- List<FlinkSourceSplit<T>> splitsForSubtask =
- pendingSplits.computeIfAbsent(subtaskId, ignored -> new ArrayList<>());
- splitsForSubtask.addAll(splits);
+ // reshuffle splits, needed after rescaling
Review Comment:
This change could be reverted. I kept it, because it might make a difference under one improbable situation - reader returns splits to enumerator, and just after that a rescale happens. In all other cases this is equivalent to the previous implementation.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "je-ik (via GitHub)" <gi...@apache.org>.
je-ik commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1918681204
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -63,45 +63,65 @@ public FlinkSourceSplitEnumerator(
Source<T> beamSource,
PipelineOptions pipelineOptions,
int numSplits) {
+
+ this(context, beamSource, pipelineOptions, numSplits, false);
+ }
+
+ public FlinkSourceSplitEnumerator(
+ SplitEnumeratorContext<FlinkSourceSplit<T>> context,
+ Source<T> beamSource,
+ PipelineOptions pipelineOptions,
+ int numSplits,
+ boolean splitsInitialized) {
+
this.context = context;
this.beamSource = beamSource;
this.pipelineOptions = pipelineOptions;
this.numSplits = numSplits;
this.pendingSplits = new HashMap<>(numSplits);
- this.splitsInitialized = false;
+ this.splitsInitialized = splitsInitialized;
+
+ LOG.info(
Review Comment:
This happens only when the job starts, I think info is fine here.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "dmvk (via GitHub)" <gi...@apache.org>.
dmvk commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1918622103
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSource.java:
##########
@@ -73,18 +71,6 @@ public static <T> FlinkUnboundedSource<T> unbounded(
return new FlinkUnboundedSource<>(stepName, source, serializablePipelineOptions, numSplits);
}
- public static FlinkUnboundedSource<byte[]> unboundedImpulse(long shutdownSourceAfterIdleMs) {
Review Comment:
this change seems unrelated to the PR, please revert or move it to separate commit
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "dmvk (via GitHub)" <gi...@apache.org>.
dmvk commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1918643568
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -111,10 +131,19 @@ public void handleSplitRequest(int subtaskId, @Nullable String requesterHostname
@Override
public void addSplitsBack(List<FlinkSourceSplit<T>> splits, int subtaskId) {
- LOG.info("Adding splits {} back from subtask {}", splits, subtaskId);
- List<FlinkSourceSplit<T>> splitsForSubtask =
- pendingSplits.computeIfAbsent(subtaskId, ignored -> new ArrayList<>());
- splitsForSubtask.addAll(splits);
+ // reshuffle splits, needed after rescaling
Review Comment:
👍 would it make sense to provide additional reasoning?
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -63,45 +63,65 @@ public FlinkSourceSplitEnumerator(
Source<T> beamSource,
PipelineOptions pipelineOptions,
int numSplits) {
+
+ this(context, beamSource, pipelineOptions, numSplits, false);
+ }
+
+ public FlinkSourceSplitEnumerator(
+ SplitEnumeratorContext<FlinkSourceSplit<T>> context,
+ Source<T> beamSource,
+ PipelineOptions pipelineOptions,
+ int numSplits,
+ boolean splitsInitialized) {
+
this.context = context;
this.beamSource = beamSource;
this.pipelineOptions = pipelineOptions;
this.numSplits = numSplits;
this.pendingSplits = new HashMap<>(numSplits);
- this.splitsInitialized = false;
+ this.splitsInitialized = splitsInitialized;
+
+ LOG.info(
+ "Created new enumerator with parallelism {}, source {}, numSplits {}, initialized {}",
+ context.currentParallelism(),
+ beamSource,
+ numSplits,
+ splitsInitialized);
}
@Override
public void start() {
- context.callAsync(
- () -> {
- try {
- LOG.info("Starting source {}", beamSource);
- List<? extends Source<T>> beamSplitSourceList = splitBeamSource();
- Map<Integer, List<FlinkSourceSplit<T>>> flinkSourceSplitsList = new HashMap<>();
- int i = 0;
- for (Source<T> beamSplitSource : beamSplitSourceList) {
- int targetSubtask = i % context.currentParallelism();
- List<FlinkSourceSplit<T>> splitsForTask =
- flinkSourceSplitsList.computeIfAbsent(
- targetSubtask, ignored -> new ArrayList<>());
- splitsForTask.add(new FlinkSourceSplit<>(i, beamSplitSource));
- i++;
+ if (!splitsInitialized) {
Review Comment:
WDYT about minimizing the changset and minizing nesting by doing
```
@Override
public void start() {
if (!splitsInitialized) {
initializeSplits()
}
}
```
?
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -111,10 +131,19 @@ public void handleSplitRequest(int subtaskId, @Nullable String requesterHostname
@Override
public void addSplitsBack(List<FlinkSourceSplit<T>> splits, int subtaskId) {
- LOG.info("Adding splits {} back from subtask {}", splits, subtaskId);
- List<FlinkSourceSplit<T>> splitsForSubtask =
- pendingSplits.computeIfAbsent(subtaskId, ignored -> new ArrayList<>());
- splitsForSubtask.addAll(splits);
+ // reshuffle splits, needed after rescaling
+ splits.forEach(
+ split -> {
+ int target = split.splitIndex() % context.currentParallelism();
+ List<FlinkSourceSplit<T>> splitsForSubtask =
+ pendingSplits.computeIfAbsent(target, ignored -> new ArrayList<>());
+ splitsForSubtask.add(split);
+ });
+ LOG.info(
Review Comment:
```suggestion
LOG.debug(
```
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -63,45 +63,65 @@ public FlinkSourceSplitEnumerator(
Source<T> beamSource,
PipelineOptions pipelineOptions,
int numSplits) {
+
+ this(context, beamSource, pipelineOptions, numSplits, false);
+ }
+
+ public FlinkSourceSplitEnumerator(
+ SplitEnumeratorContext<FlinkSourceSplit<T>> context,
+ Source<T> beamSource,
+ PipelineOptions pipelineOptions,
+ int numSplits,
+ boolean splitsInitialized) {
+
this.context = context;
this.beamSource = beamSource;
this.pipelineOptions = pipelineOptions;
this.numSplits = numSplits;
this.pendingSplits = new HashMap<>(numSplits);
- this.splitsInitialized = false;
+ this.splitsInitialized = splitsInitialized;
+
+ LOG.info(
+ "Created new enumerator with parallelism {}, source {}, numSplits {}, initialized {}",
+ context.currentParallelism(),
+ beamSource,
+ numSplits,
+ splitsInitialized);
}
@Override
public void start() {
- context.callAsync(
- () -> {
- try {
- LOG.info("Starting source {}", beamSource);
- List<? extends Source<T>> beamSplitSourceList = splitBeamSource();
- Map<Integer, List<FlinkSourceSplit<T>>> flinkSourceSplitsList = new HashMap<>();
- int i = 0;
- for (Source<T> beamSplitSource : beamSplitSourceList) {
- int targetSubtask = i % context.currentParallelism();
- List<FlinkSourceSplit<T>> splitsForTask =
- flinkSourceSplitsList.computeIfAbsent(
- targetSubtask, ignored -> new ArrayList<>());
- splitsForTask.add(new FlinkSourceSplit<>(i, beamSplitSource));
- i++;
+ if (!splitsInitialized) {
Review Comment:
hmm, is this correct? are splits guaranteed to be stable over time? is it possible that you for example want to re-list kafka partitions? How are new partitions handled in Beam?
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -63,45 +63,65 @@ public FlinkSourceSplitEnumerator(
Source<T> beamSource,
PipelineOptions pipelineOptions,
int numSplits) {
+
+ this(context, beamSource, pipelineOptions, numSplits, false);
+ }
+
+ public FlinkSourceSplitEnumerator(
+ SplitEnumeratorContext<FlinkSourceSplit<T>> context,
+ Source<T> beamSource,
+ PipelineOptions pipelineOptions,
+ int numSplits,
+ boolean splitsInitialized) {
+
this.context = context;
this.beamSource = beamSource;
this.pipelineOptions = pipelineOptions;
this.numSplits = numSplits;
this.pendingSplits = new HashMap<>(numSplits);
- this.splitsInitialized = false;
+ this.splitsInitialized = splitsInitialized;
+
+ LOG.info(
Review Comment:
debug?
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSource.java:
##########
@@ -117,7 +103,8 @@ public Boundedness getBoundedness() {
@Override
public SplitEnumerator<FlinkSourceSplit<T>, Map<Integer, List<FlinkSourceSplit<T>>>>
- createEnumerator(SplitEnumeratorContext<FlinkSourceSplit<T>> enumContext) throws Exception {
+ createEnumerator(SplitEnumeratorContext<FlinkSourceSplit<T>> enumContext) {
Review Comment:
nit: unrelated change -> separate commit
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "dmvk (via GitHub)" <gi...@apache.org>.
dmvk commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1920112784
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -111,10 +131,19 @@ public void handleSplitRequest(int subtaskId, @Nullable String requesterHostname
@Override
public void addSplitsBack(List<FlinkSourceSplit<T>> splits, int subtaskId) {
- LOG.info("Adding splits {} back from subtask {}", splits, subtaskId);
- List<FlinkSourceSplit<T>> splitsForSubtask =
- pendingSplits.computeIfAbsent(subtaskId, ignored -> new ArrayList<>());
- splitsForSubtask.addAll(splits);
+ // reshuffle splits, needed after rescaling
Review Comment:
Can you please revert it then?
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "dmvk (via GitHub)" <gi...@apache.org>.
dmvk commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1920572946
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -111,10 +131,19 @@ public void handleSplitRequest(int subtaskId, @Nullable String requesterHostname
@Override
public void addSplitsBack(List<FlinkSourceSplit<T>> splits, int subtaskId) {
- LOG.info("Adding splits {} back from subtask {}", splits, subtaskId);
- List<FlinkSourceSplit<T>> splitsForSubtask =
- pendingSplits.computeIfAbsent(subtaskId, ignored -> new ArrayList<>());
- splitsForSubtask.addAll(splits);
+ // reshuffle splits, needed after rescaling
Review Comment:
That's where I was headed. If it fixes a corner case it CAN'T be reverted and we should provide proper reasoning about the corner case to provide context for whoever touches the code next.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "je-ik (via GitHub)" <gi...@apache.org>.
je-ik commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1918674303
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -63,45 +63,65 @@ public FlinkSourceSplitEnumerator(
Source<T> beamSource,
PipelineOptions pipelineOptions,
int numSplits) {
+
+ this(context, beamSource, pipelineOptions, numSplits, false);
+ }
+
+ public FlinkSourceSplitEnumerator(
+ SplitEnumeratorContext<FlinkSourceSplit<T>> context,
+ Source<T> beamSource,
+ PipelineOptions pipelineOptions,
+ int numSplits,
+ boolean splitsInitialized) {
+
this.context = context;
this.beamSource = beamSource;
this.pipelineOptions = pipelineOptions;
this.numSplits = numSplits;
this.pendingSplits = new HashMap<>(numSplits);
- this.splitsInitialized = false;
+ this.splitsInitialized = splitsInitialized;
+
+ LOG.info(
+ "Created new enumerator with parallelism {}, source {}, numSplits {}, initialized {}",
+ context.currentParallelism(),
+ beamSource,
+ numSplits,
+ splitsInitialized);
}
@Override
public void start() {
- context.callAsync(
- () -> {
- try {
- LOG.info("Starting source {}", beamSource);
- List<? extends Source<T>> beamSplitSourceList = splitBeamSource();
- Map<Integer, List<FlinkSourceSplit<T>>> flinkSourceSplitsList = new HashMap<>();
- int i = 0;
- for (Source<T> beamSplitSource : beamSplitSourceList) {
- int targetSubtask = i % context.currentParallelism();
- List<FlinkSourceSplit<T>> splitsForTask =
- flinkSourceSplitsList.computeIfAbsent(
- targetSubtask, ignored -> new ArrayList<>());
- splitsForTask.add(new FlinkSourceSplit<>(i, beamSplitSource));
- i++;
+ if (!splitsInitialized) {
Review Comment:
This codepath works for deprecated Read transforms. Beam does modern IO using SDF, which can handle dynamic splitting. In Read, splitting is essentially static.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "je-ik (via GitHub)" <gi...@apache.org>.
je-ik commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1920152547
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -111,10 +131,19 @@ public void handleSplitRequest(int subtaskId, @Nullable String requesterHostname
@Override
public void addSplitsBack(List<FlinkSourceSplit<T>> splits, int subtaskId) {
- LOG.info("Adding splits {} back from subtask {}", splits, subtaskId);
- List<FlinkSourceSplit<T>> splitsForSubtask =
- pendingSplits.computeIfAbsent(subtaskId, ignored -> new ArrayList<>());
- splitsForSubtask.addAll(splits);
+ // reshuffle splits, needed after rescaling
Review Comment:
I could, but why? It helps under a rare circumstances and does no harm otherwise, so ... why revert?
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "dmvk (via GitHub)" <gi...@apache.org>.
dmvk commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1920572946
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSourceSplitEnumerator.java:
##########
@@ -111,10 +131,19 @@ public void handleSplitRequest(int subtaskId, @Nullable String requesterHostname
@Override
public void addSplitsBack(List<FlinkSourceSplit<T>> splits, int subtaskId) {
- LOG.info("Adding splits {} back from subtask {}", splits, subtaskId);
- List<FlinkSourceSplit<T>> splitsForSubtask =
- pendingSplits.computeIfAbsent(subtaskId, ignored -> new ArrayList<>());
- splitsForSubtask.addAll(splits);
+ // reshuffle splits, needed after rescaling
Review Comment:
That's where I was headed. If it fixes a corner case it CAN'T be reverted and we should document reasoning about the corner case to provide context for whoever touches the code next.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [flink] FlinkRunner initializes the same split twice (#31313) [beam]
Posted by "je-ik (via GitHub)" <gi...@apache.org>.
je-ik commented on code in PR #33606:
URL: https://github.com/apache/beam/pull/33606#discussion_r1918652612
##########
runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/io/source/FlinkSource.java:
##########
@@ -73,18 +71,6 @@ public static <T> FlinkUnboundedSource<T> unbounded(
return new FlinkUnboundedSource<>(stepName, source, serializablePipelineOptions, numSplits);
}
- public static FlinkUnboundedSource<byte[]> unboundedImpulse(long shutdownSourceAfterIdleMs) {
Review Comment:
we squash commits on merge requests, so moving to different commit will be a nop. The method is unused, the removal is pure cleanup.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org