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


##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -529,13 +529,51 @@ public Offset deserializeOffsetProperty(String offset) {
     }
 
     @Override
-    public void validateAlterOffset(String offset) throws Exception {
-        if (!DataSourceConfigValidator.isJsonOffset(offset)) {
+    public void validateAlterOffset(String offset) throws AnalysisException {
+        JsonNode offsetNode;
+        try {
+            offsetNode = objectMapper.readTree(offset);
+        } catch (Exception e) {
+            offsetNode = null;
+        }
+        if (offsetNode == null || !offsetNode.isObject()) {
             throw new AnalysisException(
                     "ALTER JOB for CDC only supports JSON specific offset, "
                     + "e.g. '{\"file\":\"binlog.000001\",\"pos\":\"154\"}' for 
MySQL "
                     + "or '{\"lsn\":\"12345678\"}' for PostgreSQL");
         }
+
+        if ((sourceType == DataSourceType.MYSQL || sourceType == 
DataSourceType.OCEANBASE)
+                && offsetNode.has("kind") && 
!"SPECIFIC".equals(offsetNode.path("kind").asText())) {
+            throw new AnalysisException("ALTER JOB offset kind must be 
SPECIFIC when specified");
+        }
+
+        boolean valid = switch (sourceType) {
+            case POSTGRES -> isNonNegativeLong(offsetNode.get("lsn"));

Review Comment:
   [P2] Validate retained PostgreSQL fields before accepting an offset
   
   For a paused PostgreSQL job, `{"lsn":"12345678","txId":"abc"}` passes this 
arm and `validateOffset()` and is installed/journaled by ALTER. On RESUME, 
`PostgresSourceReader.createOffset()` retains `txId`, while Flink CDC's 
`PostgresOffset.getTxid()` and 
[PostgresOffsetUtils.getPostgresOffsetContext](https://github.com/apache/flink-cdc/blob/release-3.6.0/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-postgres-cdc/src/main/java/org/apache/flink/cdc/connectors/postgres/source/offset/PostgresOffsetUtils.java#L35-L41)
 parse retained values as longs. The job consequently fails while building the 
stream reader instead of rejecting ALTER before state changes. Validate all 
retained PostgreSQL numeric fields or normalize the supported representation, 
and add a negative test. This is the PostgreSQL source arm and parser, distinct 
from the existing MySQL `kind` finding.



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