JNSimba commented on code in PR #69673:
URL: https://github.com/apache/doris/pull/69673#discussion_r4736369525


##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -160,6 +164,63 @@ public void ensureInitialized(Long jobId, Map<String, 
String> newProps) throws J
                         DataSourceConfigKeys.SNAPSHOT_PARALLELISM_DEFAULT));
     }
 
+    @Override
+    public boolean hasPendingIncludeTablesChange() {
+        return addedTables != null;
+    }
+
+    private boolean hasCommittedIncrementalOffset() {
+        return MapUtils.isNotEmpty(binlogOffsetPersist);
+    }
+
+    @Override
+    public void validateAlterIncludeTables(List<String> updatedTables) throws 
JobException {
+        synchronized (splitsLock) {
+            if (!hasCommittedIncrementalOffset()) {
+                throw new JobException("Cannot alter include_tables before an 
incremental offset is committed");
+            }
+            if (hasPendingIncludeTablesChange() && 
!updatedTables.containsAll(addedTables)) {
+                throw new JobException("Cannot remove newly added tables until 
incremental synchronization resumes");
+            }
+        }
+    }
+
+    @Override
+    public void applyIncludeTablesChange(List<String> updatedTables, 
List<String> addedTables) throws JobException {
+        synchronized (splitsLock) {
+            // CDC fills missing schemas before resuming incremental reads; 
retain existing baselines.
+            String retainedSchemas = filterTableSchemas(tableSchemas, 
updatedTables);
+            if (!hasPendingIncludeTablesChange()) {
+                // Reset snapshot progress while preserving the committed 
incremental offset for resumption.
+                clearSnapshotState();
+                this.addedTables = new ArrayList<>();

Review Comment:
   The task will run one extra time; this does not affect correctness.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to