[FLINK-37979] Remove obsolete MySQL CDC snapshot split assigner code #4048
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a redundant condition and a misleading comment in
MySqlSnapshotSplitAssigner#captureNewlyAddedTables()
that complicate understanding of the code:flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/assigners/MySqlSnapshotSplitAssigner.java
Lines 280 to 285 in 1646715
By the time when the above condition is being evaluated, an identical condition has been already evaluated earlier in the code:
flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/assigners/MySqlSnapshotSplitAssigner.java
Lines 226 to 228 in 1646715
Therefore, the second evaluation will always result in
true
and thus is redundant.Code Change History
Prior to #3519, table discovery would happen in any assigner status, so the condition in the end of the method made sense. Together with adding this condition in the beginning of the method, #3519 should have removed it from the end.
What Exactly is Obsolete
flink-cdc/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/assigners/MySqlSnapshotSplitAssigner.java
Lines 274 to 275 in 1646715
Since [FLINK-35859][cdc-connector] Fix: The assigner is not ready to offer finished split information, this should not be called #3519, if the job is still in the snapshot reading phase, this code won't be executed. This comment should be removed as misleading.
if (AssignerStatus.isAssigningFinished(assignerStatus))
statement. While thecaptureNewlyAddedTables()
method is running, the assigner status cannot be modified by a different thread because this code is only executed as part ofMySqlSourceEnumerator#open()
, i.e. the source in its initialization phase.