github-actions[bot] commented on code in PR #62490:
URL: https://github.com/apache/doris/pull/62490#discussion_r3083827669


##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -360,10 +362,33 @@ public Offset deserializeOffset(String offset) {
 
     @Override
     public Offset deserializeOffsetProperty(String offset) {
-        // no need cause cdc_stream has offset property
+        if (offset == null || offset.trim().isEmpty()) {
+            return null;
+        }
+        // JSON format: {"file":"binlog.000003","pos":154} or {"lsn":"123456"}
+        if (DataSourceConfigValidator.isJsonOffset(offset)) {
+            try {
+                Map<String, String> offsetMap = objectMapper.readValue(offset,
+                        new TypeReference<Map<String, String>>() {});
+                return new JdbcOffset(Collections.singletonList(new 
BinlogSplit(offsetMap)));
+            } catch (Exception e) {
+                log.warn("Failed to parse JSON offset: {}", offset, e);
+                return null;
+            }
+        }
         return null;
     }
 
+    @Override

Review Comment:
   This only checks whether the value is JSON, not whether the JSON is valid 
for the current source type. As written, a PostgreSQL job will accept 
MySQL-style JSON like `{"file":"binlog.000001","pos":"154"}` here, because 
`deserializeOffsetProperty()` also wraps any JSON object in a `BinlogSplit`. 
The ALTER succeeds, but the resumed job later fails in 
`PostgresSourceReader.generatePostgresConfig()` because that path requires an 
`lsn`. Please validate the JSON shape against `sourceType` here (MySQL: `file` 
+ `pos`; PostgreSQL: `lsn`) instead of treating every JSON object as valid.



##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java:
##########
@@ -780,8 +791,7 @@ public void replayOnUpdated(StreamingInsertJob replayJob) {
      */
     private void modifyPropertiesInternal(Map<String, String> inputProperties) 
throws AnalysisException, JobException {
         StreamingJobProperties inputStreamProps = new 
StreamingJobProperties(inputProperties);
-        if (StringUtils.isNotEmpty(inputStreamProps.getOffsetProperty())
-                && S3TableValuedFunction.NAME.equalsIgnoreCase(this.tvfType)) {
+        if (StringUtils.isNotEmpty(inputStreamProps.getOffsetProperty())) {
             Offset offset = 
validateOffset(inputStreamProps.getOffsetProperty());

Review Comment:
   For `FROM MYSQL/POSTGRES ... TO` jobs this only updates the in-memory 
provider. The durable state used by replay/reconstruction is still 
`sourceProperties` (`gsonPostProcess()` rebuilds `new 
JdbcSourceOffsetProvider(getJobId(), dataSourceType, sourceProperties)` from 
that map, and `createStreamingMultiTblTask()` also forwards it to BE). If FE 
restarts before the next successful commit, the altered offset is lost and the 
job resumes from the old mode/offset. Please also sync the new offset into 
`sourceProperties` for the non-TVF JDBC path before the ALTER is journaled.



-- 
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