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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterJobCommand.java:
##########
@@ -212,14 +213,21 @@ private void 
checkUnmodifiableSourceProperties(Map<String, String> originSourceP
                     sourceProperties.get(DataSourceConfigKeys.EXCLUDE_TABLES)),
                     "The exclude_tables property cannot be modified in ALTER 
JOB");
         }
+
+        if (sourceProperties.containsKey(DataSourceConfigKeys.OFFSET)) {
+            Preconditions.checkArgument(Objects.equals(
+                    originSourceProperties.get(DataSourceConfigKeys.OFFSET),
+                    sourceProperties.get(DataSourceConfigKeys.OFFSET)),
+                    "The offset in source properties cannot be modified in 
ALTER JOB. "
+                    + "Use PROPERTIES('offset'='{...}') to alter offset");
+        }
     }
 
     private void validateProps(StreamingInsertJob streamingJob) throws 
AnalysisException {
         StreamingJobProperties jobProperties = new 
StreamingJobProperties(properties);
         jobProperties.validate();
-        // from to job no need valiate offset in job properties
-        if (streamingJob.getDataSourceType() == null
-                && jobProperties.getOffsetProperty() != null) {
+        if (jobProperties.getOffsetProperty() != null) {

Review Comment:
   This only validates the `PROPERTIES("offset"=...)` path. `ALTER JOB <name> 
DO INSERT ... SELECT ... FROM cdc_stream(...)` still goes through the 
SQL-rewrite branch: `checkUnmodifiableProperties()` allows changing `offset`, 
`alterJob()` refreshes `originTvfProps`, but it never calls 
`validateAlterOffset()`, `validateOffset()`, or 
`offsetProvider.updateOffset()`. After resume, 
`JdbcTvfSourceOffsetProvider.getNextOffset()` keeps using the old provider 
state, so the SQL-level offset change is silently ignored and it also bypasses 
the new JSON-only rule. Please either reject SQL-side offset changes for 
`cdc_stream` or route them through the same validated reset path.



##########
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
+    public void validateAlterOffset(String offset) throws Exception {

Review Comment:
   `isJsonOffset()` is too weak for JDBC ALTER validation. 
`deserializeOffsetProperty()` plus `JdbcOffset.isValidOffset()` treat any 
non-empty JSON object as valid, so a MySQL job can be altered to something like 
`{"lsn":"123"}` or `{"foo":"bar"}`. On resume, 
`MySqlSourceReader.createBinlogSplit()` cannot build a specific binlog offset 
from that meta and falls back to the old startup offset or earliest, so the 
requested reset is silently ignored. This validator needs to enforce 
source-specific keys such as `file` plus `pos` for MySQL and `lsn` for 
PostgreSQL before FE accepts the ALTER.



##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java:
##########
@@ -783,11 +794,12 @@ 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());
             this.offsetProvider.updateOffset(offset);
             this.offsetProviderPersist = offsetProvider.getPersistInfo();
+            log.info("modifyPropertiesInternal: offset updated to {}, job {}",
+                    inputStreamProps.getOffsetProperty(), getJobId());
             if (Config.isCloudMode()) {

Review Comment:
   `replayOnUpdated()` calls `modifyPropertiesInternal()` while the update-job 
edit log is being replayed. With this change, any CDC job that has 
`properties["offset"]` now reaches `resetCloudProgress()` here as well. In 
cloud mode that RPC is not read-only: `reset_streaming_job_offset` overwrites 
the commit-attach offset stored in meta-service. Replaying an old ALTER entry 
on follower startup can therefore rewind the job progress back to the ALTER 
offset, and the next `replayOnCloudMode()` will resume from stale progress. 
This helper needs a replay-safe path that skips the RPC, or replay should 
restore only persisted provider state.



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