You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Leonard Xu (Jira)" <ji...@apache.org> on 2023/10/31 07:24:00 UTC
[jira] [Comment Edited] (FLINK-33360) HybridSource fails to clear the previous round's state when switching sources, leading to data loss
[ https://issues.apache.org/jira/browse/FLINK-33360?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17780899#comment-17780899 ]
Leonard Xu edited comment on FLINK-33360 at 10/31/23 7:23 AM:
--------------------------------------------------------------
Fixed in master(1.19): 8d21c321dda18ad20022532c861d57ee38b70fda
1.18:013b337329ff4732e62d631cac8429cb68dd4776
1.17:19637741e9e56ab231fdcafd1dec4be4087e738e
was (Author: leonard xu):
Fixed in master(1.19): 8d21c321dda18ad20022532c861d57ee38b70fda
> HybridSource fails to clear the previous round's state when switching sources, leading to data loss
> ---------------------------------------------------------------------------------------------------
>
> Key: FLINK-33360
> URL: https://issues.apache.org/jira/browse/FLINK-33360
> Project: Flink
> Issue Type: Bug
> Components: Connectors / HybridSource
> Affects Versions: 1.16.2, 1.18.0, 1.17.1
> Reporter: Feng Jiajie
> Assignee: Feng Jiajie
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.19.0
>
>
> org.apache.flink.connector.base.source.hybrid.HybridSourceSplitEnumerator:
> {code:java}
> // track readers that have finished processing for current enumerator
> finishedReaders.add(subtaskId);
> if (finishedReaders.size() == context.currentParallelism()) {
> LOG.debug("All readers finished, ready to switch enumerator!");
> if (currentSourceIndex + 1 < sources.size()) {
> switchEnumerator();
> // switch all readers prior to sending split assignments
> for (int i = 0; i < context.currentParallelism(); i++) {
> sendSwitchSourceEvent(i, currentSourceIndex);
> }
> }
> } {code}
> I think that *finishedReaders* is used to keep track of all the subTaskIds that have finished reading the current round of the source. Therefore, in the *switchEnumerator* function, *finishedReaders* should be cleared:
> If it's not cleared, then in the next source reading, whenever any SourceReader reports a *SourceReaderFinishedEvent* (while other SourceReaders may not have finished processing in parallel), the condition *finishedReaders.size() == context.currentParallelism()* will be satisfied and it will trigger {*}sendSwitchSourceEvent{*}(i, currentSourceIndex), sending a *SwitchSourceEvent* to all SourceReaders.
> If a SourceReader receives a SwitchSourceEvent before it finishes reading the previous source, it will execute {*}currentReader.close(){*}, and some data may not be fully read, resulting in a partial data loss in the source.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)