github-actions[bot] commented on code in PR #62553:
URL: https://github.com/apache/doris/pull/62553#discussion_r3109792003
##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java:
##########
@@ -398,6 +400,7 @@ public void alterJob(AlterJobCommand alterJobCommand)
throws AnalysisException,
// update source properties
Review Comment:
`validateSource()` only checks that `ssl_rootcert` is non-empty, not that
the small file exists. Because this mutates `this.sourceProperties` before
`convertCertFile()` can fail, `ALTER JOB ... FROM MYSQL ("ssl_rootcert" =
"FILE:missing.pem")` leaves the in-memory job partially updated even though the
command returns an error and no edit log is written. After that, `SHOW JOBS`
exposes the failed value and later ALTERs can keep failing until the cert key
is overwritten or FE restarts.
Please build a merged copy, run `convertCertFile()` on the copy, and only
assign `sourceProperties` / `convertedSourceProperties` after conversion
succeeds.
##########
regression-test/suites/job_p0/streaming_job/cdc/test_streaming_mysql_job_alter_props_restart_fe.groovy:
##########
@@ -0,0 +1,199 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+
+import org.apache.doris.regression.suite.ClusterOptions
+import org.awaitility.Awaitility
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+/**
+ * Verify that ALTERed source/target properties survive FE restart.
+ *
+ * replayOnUpdated() currently syncs properties (job props), executeSql,
+ * offsetProviderPersist, etc., but does NOT sync sourceProperties and
+ * targetProperties. After FE restart, the CDC job reverts to the original
+ * source/target properties written at CREATE time.
+ *
+ * This test:
+ * 1. Creates a CDC job with only "replication_num" in target properties
+ * 2. ALTERs target properties to add "load.max_filter_ratio"
+ * 3. ALTERs source properties to add "snapshot_split_size"
+ * 4. Restarts FE
+ * 5. Asserts that ExecuteSql (built from sourceProperties/targetProperties)
+ * still contains the ALTERed values
+ */
+suite("test_streaming_mysql_job_alter_props_restart_fe",
"docker,mysql,external_docker,external_docker_mysql,nondatalake") {
+ def jobName = "test_streaming_mysql_job_alter_props_restart_fe"
+ def options = new ClusterOptions()
+ options.setFeNum(1)
+ options.cloudMode = null
+
+ docker(options) {
+ def currentDb = (sql "select database()")[0][0]
+ def table1 = "alter_props_restart_user"
+ def mysqlDb = "test_cdc_db"
+
+ sql """DROP JOB IF EXISTS where jobname = '${jobName}'"""
+ sql """drop table if exists ${currentDb}.${table1} force"""
+
+ String enabled = context.config.otherConfigs.get("enableJdbcTest")
+ if (enabled != null && enabled.equalsIgnoreCase("true")) {
+ String mysql_port =
context.config.otherConfigs.get("mysql_57_port");
+ String externalEnvIp =
context.config.otherConfigs.get("externalEnvIp")
+ String s3_endpoint = getS3Endpoint()
+ String bucket = getS3BucketName()
+ String driver_url =
"https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.4.0.jar"
+
+ // Prepare upstream MySQL data
+ connect("root", "123456",
"jdbc:mysql://${externalEnvIp}:${mysql_port}") {
+ sql """CREATE DATABASE IF NOT EXISTS ${mysqlDb}"""
+ sql """DROP TABLE IF EXISTS ${mysqlDb}.${table1}"""
+ sql """CREATE TABLE ${mysqlDb}.${table1} (
+ `name` varchar(200) NOT NULL,
+ `age` int DEFAULT NULL,
+ PRIMARY KEY (`name`)
+ ) ENGINE=InnoDB"""
+ sql """INSERT INTO ${mysqlDb}.${table1} (name, age) VALUES
('A1', 1);"""
+ sql """INSERT INTO ${mysqlDb}.${table1} (name, age) VALUES
('B1', 2);"""
+ }
+
+ // Step 1: Create CDC job with initial target properties
+ sql """CREATE JOB ${jobName}
+ ON STREAMING
+ FROM MYSQL (
+ "jdbc_url" =
"jdbc:mysql://${externalEnvIp}:${mysql_port}",
+ "driver_url" = "${driver_url}",
+ "driver_class" = "com.mysql.cj.jdbc.Driver",
+ "user" = "root",
+ "password" = "123456",
+ "database" = "${mysqlDb}",
+ "include_tables" = "${table1}",
+ "offset" = "initial"
+ )
+ TO DATABASE ${currentDb} (
+ "table.create.properties.replication_num" = "1"
+ )
+ """
+
+ // Step 2: Wait for initial data to be consumed
+ try {
+ Awaitility.await().atMost(300, SECONDS)
+ .pollInterval(1, SECONDS).until(
+ {
+ def jobSucceedCount = sql """ select
SucceedTaskCount from jobs("type"="insert") where Name = '${jobName}' and
ExecuteType='STREAMING' """
+ log.info("jobSucceedCount: " + jobSucceedCount)
+ jobSucceedCount.size() == 1 && '2' <=
jobSucceedCount.get(0).get(0)
Review Comment:
`jobs()` returns `SucceedTaskCount` as a string here, so this is a
lexicographic comparison. Once the count reaches two digits, `'10' <= '2'` is
false and the wait can time out even though the job already succeeded. Please
cast to `int` before comparing.
##########
fe/fe-core/src/main/java/org/apache/doris/job/offset/jdbc/JdbcSourceOffsetProvider.java:
##########
@@ -112,6 +112,15 @@ public JdbcSourceOffsetProvider(Long jobId, DataSourceType
sourceType, Map<Strin
DataSourceConfigKeys.SNAPSHOT_PARALLELISM_DEFAULT));
}
+ // Refresh fields that may be changed via ALTER JOB; called before each
use.
+ @Override
+ public void ensureInitialized(Long jobId, Map<String, String> newProps) {
Review Comment:
This only refreshes the FE-side `JdbcSourceOffsetProvider`. The BE
cdc_client still reuses a cached `SourceReader` per numeric job id
(`fs_brokers/cdc_client/.../Env.getOrCreateReader()`), and that reader only
runs `initialize()` once. So some ALTER-able source properties are still stale
at runtime even after this change: `DebeziumJsonDeserializer.init()` keeps old
`exclude_columns` / PG `target_table` caches, and
`JdbcIncrementalSourceReader.initialize()` keeps the old `snapshot_parallelism`
poll executor.
A paused job altered with `table.<tbl>.exclude_columns` will therefore
resume with the old column filter until the BE reader is recreated.
--
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]