Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mysql] add new tables to existing cdc job #777

Closed
wants to merge 4 commits into from
Closed

[mysql] add new tables to existing cdc job #777

wants to merge 4 commits into from

Conversation

zhjwpku
Copy link
Contributor

@zhjwpku zhjwpku commented Jan 6, 2022

This PR try to achieve the feature mentioned in [0]

  1. MySqlSourceEnumerator
    1.1 check whether there is newly added table in MySqlSnapshotSplitAssigner#open
    1.1.1 if assigner not finished, add the tables to remainingTables
    and continue the normal processure
    1.1.2 if assigner has finished, a.k.a the job has enter the incremental phase
    1.1.2.1 set the assigner to suspend status
    1.1.2.2 send SuspendBinlogSplitReaderRequestEvent to SourceReader
  2. MySqlSourceReader
    2.1 on receiving the SuspendBinlogSplitReaderRequestEvent
    2.1.2 set a flag to tell MySqlSplitReader to suspend
    2.1.3 MySqlSplitReader stop currentReader in fetch() and update
    binlog offset in MySqlRecordEmitter#emitRecord
    2.1.4 response a SuspendBinlogSplitReaderResponseEvent event to
    MySqlSplitEnumerator in MySqlSourceReader#snapshotState
  3. MySqlSourceEnumerator
    3.1 on receiving the SuspendBinlogSplitReaderResponseEvent
    3.1.1 save the received offset, and start again the snapshot phase
    3.1.2 when snapshot phase finished, use the saved offset as minBinlogOffset
    in MySqlHybridSplitAssigner#createBinlogSplit

[0] #513

Signed-off-by: 元组 zhaojunwang.zjw@alibaba-inc.com

@zhjwpku zhjwpku marked this pull request as draft January 6, 2022 08:04
@zhjwpku
Copy link
Contributor Author

zhjwpku commented Jan 7, 2022

Current implementation use a Singleton class SuspendInfoCarrier to pass data among the MySqlSourceReader, MySqlSplitReader and MySqlRecordEmitter, this will cause problem when there is multiple tasks run in a single TaskManager.

I'm working with @leonardBang to find an elegant way to exchange data among them.

Copy link
Contributor

@leonardBang leonardBang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @zhjwpku for the great work, I left some comments. And I think we need to consider more cases, and we'd better to split different feature into to separate PRs.

@@ -120,6 +120,77 @@ public void testJobManagerFailoverSingleParallelism() throws Exception {
1, FailoverType.JM, FailoverPhase.SNAPSHOT, new String[] {"customers"});
}

@Test
public void testJobManagerFailoverInBinlogPhaseWithNewlyAddTable() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need test more cases, like new adding table in snapshot phase and new adding table in binglog pahse.
And we also can split below support to two PRs. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, definitely, this simple case is for my local test, we should come up with more cases to make it behave right.

@@ -54,6 +54,7 @@ public static BinlogOffset readBinlogPosition(int offsetVersion, DataInputDeseri
return in.readBoolean() ? new BinlogOffset(in.readUTF(), in.readLong()) : null;
case 2:
case 3:
case 4:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do not need upgrade offsetVersion, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bump the VERSION in MySqlSplitSerializer, I think this will propagate to all the serializer?

@zhjwpku zhjwpku changed the title [WIP][mysql] add new tables to existing cdc job [mysql] add new tables to existing cdc job Jan 14, 2022
@zhjwpku zhjwpku marked this pull request as ready for review January 14, 2022 04:34
@leonardBang leonardBang linked an issue Jan 23, 2022 that may be closed by this pull request
leonardBang added a commit to leonardBang/flink-cdc-connectors that referenced this pull request Feb 11, 2022
@leonardBang
Copy link
Contributor

Thanks @zhjwpku for the great continuous contribution, LGTM. I also help polish the code and test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants