From cca347f4b311f74ef4dcebf9073f69607dd3cad3 Mon Sep 17 00:00:00 2001 From: tenfyzhong Date: Thu, 2 Apr 2026 10:15:58 +0800 Subject: [PATCH 1/2] tests: isolate next gen upstream TiKV wal-sync dirs Fixes flaky next-gen integration startup where upstream TiKV instances shared one rfengine wal-sync-dir path. Generate per-instance upstream TiKV configs with isolated wal-sync-dir and add a regression test. Ref #4684 Signed-off-by: tenfyzhong --- .../_utils/start_tidb_cluster_nextgen | 18 ++++++---- .../_utils/start_tidb_cluster_nextgen_test.go | 34 +++++++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go diff --git a/tests/integration_tests/_utils/start_tidb_cluster_nextgen b/tests/integration_tests/_utils/start_tidb_cluster_nextgen index 76fdfd6ea1..78ef4dd017 100755 --- a/tests/integration_tests/_utils/start_tidb_cluster_nextgen +++ b/tests/integration_tests/_utils/start_tidb_cluster_nextgen @@ -218,12 +218,6 @@ s3-secret-key = "$MINIO_ROOT_PASSWORD" s3-bucket = "cse-test-up" s3-region = "local" -[rfengine] -wal-sync-dir = "$TEST_DATA_DIR/wal-sync/upstream/tikv/raft-wal" -lightweight-backup = true -target-file-size = "512MB" -wal-chunk-target-file-size = "128MB" - [cdc] enable = true EOF @@ -262,13 +256,23 @@ for idx in $(seq 1 3); do host="UP_TIKV_HOST_$idx" port="UP_TIKV_PORT_$idx" status_port="UP_TIKV_STATUS_PORT_$idx" + upstream_tikv_config="$OUT_DIR/upstream-tikv$idx.toml" + cp "$OUT_DIR/upstream-tikv.toml" "$upstream_tikv_config" + cat >>"$upstream_tikv_config" <"$OUT_DIR/log/upstream/tikv/tikv$idx-stdout.log" \ 2>"$OUT_DIR/log/upstream/tikv/tikv$idx-stderr.log" & diff --git a/tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go b/tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go new file mode 100644 index 0000000000..d89c15d8e2 --- /dev/null +++ b/tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go @@ -0,0 +1,34 @@ +package utils_test + +import ( + "os" + "path/filepath" + "runtime" + "strings" + "testing" +) + +func TestNextGenUpstreamTiKVWalSyncDirIsPerInstance(t *testing.T) { + _, currentFile, _, ok := runtime.Caller(0) + if !ok { + t.Fatal("failed to get test file path") + } + + scriptPath := filepath.Join(filepath.Dir(currentFile), "start_tidb_cluster_nextgen") + content, err := os.ReadFile(scriptPath) + if err != nil { + t.Fatalf("failed to read %s: %v", scriptPath, err) + } + + script := string(content) + + sharedWalDir := `wal-sync-dir = "$TEST_DATA_DIR/wal-sync/upstream/tikv/raft-wal"` + if strings.Contains(script, sharedWalDir) { + t.Fatalf("upstream TiKV instances must not share rfengine wal-sync-dir: %q", sharedWalDir) + } + + perInstanceWalDir := `wal-sync-dir = "$TEST_DATA_DIR/wal-sync/upstream/tikv$idx/raft-wal"` + if !strings.Contains(script, perInstanceWalDir) { + t.Fatalf("expected per-instance rfengine wal-sync-dir snippet: %q", perInstanceWalDir) + } +} From d7d730e646cbcb00ba0902cbf404418af2f37d19 Mon Sep 17 00:00:00 2001 From: tenfyzhong Date: Thu, 2 Apr 2026 10:25:09 +0800 Subject: [PATCH 2/2] tests: drop next gen startup wait and remove helper test Signed-off-by: tenfyzhong --- .../_utils/start_tidb_cluster_nextgen | 8 ----- .../_utils/start_tidb_cluster_nextgen_test.go | 34 ------------------- 2 files changed, 42 deletions(-) delete mode 100644 tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go diff --git a/tests/integration_tests/_utils/start_tidb_cluster_nextgen b/tests/integration_tests/_utils/start_tidb_cluster_nextgen index 78ef4dd017..0a13ae885b 100755 --- a/tests/integration_tests/_utils/start_tidb_cluster_nextgen +++ b/tests/integration_tests/_utils/start_tidb_cluster_nextgen @@ -353,14 +353,6 @@ tikv-worker --addr "$DOWN_TIKV_WORKER_HOST:$DOWN_TIKV_WORKER_PORT" \ check_port_available "$UP_TIKV_WORKER_HOST" "$UP_TIKV_WORKER_PORT" "Upstream TiKV-Worker is not ready yet" check_port_available "$DOWN_TIKV_WORKER_HOST" "$DOWN_TIKV_WORKER_PORT" "Downstream TiKV-Worker is not ready yet" -####################start TiDB#################### -# TODO: replace this fixed delay with an explicit keyspace readiness check. -# PD health only guarantees the service is up. In next-gen bootstrap we also -# rely on PD finishing keyspace pre-allocation before the SYSTEM TiDB starts. -# Giving PD a short quiet window here reduces flaky startup failures in CI. -echo "Waiting for next-gen keyspace pre-allocation to settle..." -sleep 30 - touch "$OUT_DIR/upstream-tidb-system.toml" if [ -f "$tidb_config" ]; then cat "$tidb_config" >>"$OUT_DIR/upstream-tidb-system.toml" diff --git a/tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go b/tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go deleted file mode 100644 index d89c15d8e2..0000000000 --- a/tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package utils_test - -import ( - "os" - "path/filepath" - "runtime" - "strings" - "testing" -) - -func TestNextGenUpstreamTiKVWalSyncDirIsPerInstance(t *testing.T) { - _, currentFile, _, ok := runtime.Caller(0) - if !ok { - t.Fatal("failed to get test file path") - } - - scriptPath := filepath.Join(filepath.Dir(currentFile), "start_tidb_cluster_nextgen") - content, err := os.ReadFile(scriptPath) - if err != nil { - t.Fatalf("failed to read %s: %v", scriptPath, err) - } - - script := string(content) - - sharedWalDir := `wal-sync-dir = "$TEST_DATA_DIR/wal-sync/upstream/tikv/raft-wal"` - if strings.Contains(script, sharedWalDir) { - t.Fatalf("upstream TiKV instances must not share rfengine wal-sync-dir: %q", sharedWalDir) - } - - perInstanceWalDir := `wal-sync-dir = "$TEST_DATA_DIR/wal-sync/upstream/tikv$idx/raft-wal"` - if !strings.Contains(script, perInstanceWalDir) { - t.Fatalf("expected per-instance rfengine wal-sync-dir snippet: %q", perInstanceWalDir) - } -}