loserwang1024 commented on code in PR #3221:
URL: https://github.com/apache/flink-cdc/pull/3221#discussion_r1560701972


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mongodb-cdc/src/main/java/org/apache/flink/cdc/connectors/mongodb/source/reader/fetch/MongoDBStreamFetchTask.java:
##########
@@ -108,7 +110,32 @@ public void execute(Context context) throws Exception {
         this.taskRunning = true;
         try {
             while (taskRunning) {
-                Optional<BsonDocument> next = 
Optional.ofNullable(changeStreamCursor.tryNext());
+                Optional<BsonDocument> next = Optional.empty();
+                try {
+                    next = Optional.ofNullable(changeStreamCursor.tryNext());
+                } catch (MongoQueryException e) {
+                    if (e.getErrorCode() == CHANGE_STREAM_FATAL_ERROR) {
+                        ChangeStreamOffset offset =
+                                new 
ChangeStreamOffset(streamSplit.getStartingOffset().getOffset());
+                        if (offset.getTimestamp() != null) {
+                            LOG.warn(
+                                    "Resume token {} has expired, fallback to 
timestamp startup mode.",

Review Comment:
   Still initial startup mode  or latest mode, maybe "Resume token {} has 
expired, fallback to restart based on timestamp"?
   
    I'm not a mongodb expert. I wonder whether some data will loss or 
duplicated when fallback from resume token to timestamp? @Jiabao-Sun , CC



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to