Skip to content

config: make minSyncPointInterval configurable via debug config#5271

Closed
pingyu wants to merge 5 commits into
pingcap:masterfrom
pingyu:debug-min-sync-point-interval
Closed

config: make minSyncPointInterval configurable via debug config#5271
pingyu wants to merge 5 commits into
pingcap:masterfrom
pingyu:debug-min-sync-point-interval

Conversation

@pingyu

@pingyu pingyu commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #5270

What is changed and how it works?

Make minSyncPointInterval configurable through the existing DebugConfig in pkg/config/debug.go, instead of being hardcoded to 30 seconds.

Changes:

  • pkg/config/debug.go: Add DebugReplicaConfig with MinSyncPointInterval field under debug.replica-config. The configurable range is [5s, 30s]. Add getMinSyncPointInterval() to read the value from global server config with fallback to 30s default.
  • pkg/config/replica_config.go: Replace hardcoded minSyncPointInterval constant with minSyncPointIntervalDefault (30s) and minConfigurableSyncPointInterval (5s). Split ValidateAndAdjust into ValidateAndAdjust (server-side, uses debug config minimum) and ValidateAndAdjustForCLI (client-side, uses absolute minimum 5s).
  • pkg/config/server.go: Add ReplicaConfig: NewDefaultDebugReplicaConfig() to default server config.
  • cmd/cdc/cli/cli_changefeed_create.go: Add --sync-point and --sync-interval CLI flags. Use ValidateAndAdjustForCLI for CLI-side validation.
  • tests/integration_tests/syncpoint/: Replace changefeed.toml (which set sync-point-interval=30s) with server.toml debug config (min-sync-point-interval=5s), and use --sync-point --sync-interval 10s flags instead.

This allows integration tests to set a smaller minimum (e.g., 5s) via the debug config, significantly reducing test execution time while keeping the 30s safety guard for production.

Check List

Tests

  • Unit test
  • Integration test

Questions

Will it cause performance regression or break compatibility?

No. The default minimum remains 30s. Only when explicitly configured via debug config (unexposed/internal) does the minimum change.

Do you need to update user documentation, design documentation or monitoring documentation?

No. This is purely a debug/internal configuration with no user-facing changes.

Release note

config: minSyncPointInterval is configurable via debug config

Summary by CodeRabbit

  • New Features

    • CLI flags to enable sync points and set sync-point interval during changefeed creation.
    • New debug replica configuration to allow a lower, configurable minimum sync-point interval.
  • Validation

    • Enforced distinct minimums for sync-point intervals: stricter global default and a more permissive CLI/debug minimum with clear validation errors.
  • Tests

    • Added unit and integration tests covering flags, interval limits, config decoding, and end-to-end sync-point behavior.

pingyu added 2 commits June 9, 2026 22:13
Signed-off-by: Ping Yu <yuping@pingcap.com>
Signed-off-by: Ping Yu <yuping@pingcap.com>
@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed labels Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 402bca93-88cb-4da7-b448-f1db76b4f400

📥 Commits

Reviewing files that changed from the base of the PR and between 4643a7b and ba52696.

📒 Files selected for processing (1)
  • pkg/config/debug.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/config/debug.go

📝 Walkthrough

Walkthrough

Adds a debug-configurable minimum sync-point interval, splits replica validation for CLI usage, exposes --sync-point/--sync-interval CLI flags wired into replica config completion, and updates tests and integration scripts to use the new settings.

Changes

Configurable Sync Point Interval

Layer / File(s) Summary
Debug replica configuration foundation
pkg/config/debug.go
Add DebugReplicaConfig with MinSyncPointInterval, integrate into DebugConfig, add defaulting and validation, and provide getMinSyncPointInterval() helper.
Server default initialization
pkg/config/server.go
Initialize Debug.ReplicaConfig in defaultServerConfig.
Validation path split with separate minimums
pkg/config/replica_config.go
Introduce minSyncPointIntervalDefault and minConfigurableSyncPointInterval, refactor validation into a shared helper, and add ValidateAndAdjustForCLI that uses the smaller CLI/debug minimum.
Configuration validation tests
pkg/config/server_config_test.go, pkg/config/replica_config_test.go
Add tests for debug replica config boundaries, TOML decoding, and that replica validation uses the debug-configured minimum when applicable.
CLI sync point flags
cmd/cdc/cli/cli_changefeed_create.go
Add --sync-point and --sync-interval flags, extend createChangefeedOptions, apply flags in completeReplicaCfg, and call ValidateAndAdjustForCLI() for final validation.
CLI and integration test updates
cmd/cdc/cli/cli_changefeed_create_test.go, tests/integration_tests/syncpoint/conf/server.toml, tests/integration_tests/syncpoint/run.sh
Add unit test validating sync-interval flag constraints, set [debug.replica-config] min-sync-point-interval = "5s" in server TOML, enable failpoint and start server with config, and create changefeed via CLI flags --sync-point --sync-interval 10s.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

lgtm, approved

Suggested reviewers

  • asddongmen
  • flowbehappy
  • wk989898

Poem

🐰 A rabbit hops into the code tonight,
Whispering intervals short and light.
From thirty to five the sync points leap,
Tests wake up from their long, long sleep.
CLI flags dance — the changefeed’s bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making minSyncPointInterval configurable via debug config, which is the core objective of the PR.
Description check ✅ Passed The description includes the required sections: Issue Number (close #5270), What is changed and how it works, Tests (unit and integration), Questions answered, and Release note. All key information is present and complete.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #5270: adds MinSyncPointInterval to DebugConfig [debug.go], implements separate validation paths (ValidateAndAdjust server-side, ValidateAndAdjustForCLI client-side) [replica_config.go], adds CLI flags [cli_changefeed_create.go], and includes both unit and integration tests.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #5270's objective: making minSyncPointInterval configurable via debug config. Test configurations and CLI updates support this goal without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ti-chi-bot ti-chi-bot Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 9, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces --sync-point and --sync-interval CLI flags for creating changefeeds, allowing users to configure sync points directly from the command line. It also adds a new debug configuration option min-sync-point-interval to allow overriding the minimum sync point interval (defaulting to 30s, but configurable down to 5s for testing/debugging). Feedback suggests automatically enabling the sync point feature if a non-zero sync interval is provided to prevent silent misconfigurations.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread cmd/cdc/cli/cli_changefeed_create.go Outdated
Signed-off-by: Ping Yu <yuping@pingcap.com>

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jun 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/integration_tests/syncpoint/run.sh`:
- Line 162: The run_cdc_server invocation uses unquoted variable expansions
which can cause word-splitting/globbing; update the command that calls
run_cdc_server to quote all expanded variables (e.g., change run_cdc_server
--workdir $WORK_DIR --binary $CDC_BINARY --config $CUR/conf/server.toml to use
"$WORK_DIR", "$CDC_BINARY", and "$CUR/conf/server.toml") and apply the same
quoting fix to the other run_cdc_server invocation referenced in the same
script.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b12c8655-6c62-422e-82a0-9382aac8a9c2

📥 Commits

Reviewing files that changed from the base of the PR and between c37f85f and 936e3c7.

📒 Files selected for processing (10)
  • cmd/cdc/cli/cli_changefeed_create.go
  • cmd/cdc/cli/cli_changefeed_create_test.go
  • pkg/config/debug.go
  • pkg/config/replica_config.go
  • pkg/config/replica_config_test.go
  • pkg/config/server.go
  • pkg/config/server_config_test.go
  • tests/integration_tests/syncpoint/conf/changefeed.toml
  • tests/integration_tests/syncpoint/conf/server.toml
  • tests/integration_tests/syncpoint/run.sh
💤 Files with no reviewable changes (1)
  • tests/integration_tests/syncpoint/conf/changefeed.toml

export GO_FAILPOINTS='github.com/pingcap/ticdc/utils/dynstream/InjectDeadlock=10%return(true)'
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --config $CUR/conf/server.toml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Quote variable expansions in command arguments to avoid word-splitting edge cases.

Use quotes for expanded shell vars in these commands to prevent accidental splitting/globbing in CI paths or env-specific workdirs.

Suggested patch
-run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --config $CUR/conf/server.toml
+run_cdc_server --workdir "$WORK_DIR" --binary "$CDC_BINARY" --config "$CUR/conf/server.toml"

-cdc_cli_changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" --sync-point --sync-interval 10s
+cdc_cli_changefeed create --start-ts="$start_ts" --sink-uri="$SINK_URI" --sync-point --sync-interval "10s"

Also applies to: 167-167

🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 162-162: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 162-162: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration_tests/syncpoint/run.sh` at line 162, The run_cdc_server
invocation uses unquoted variable expansions which can cause
word-splitting/globbing; update the command that calls run_cdc_server to quote
all expanded variables (e.g., change run_cdc_server --workdir $WORK_DIR --binary
$CDC_BINARY --config $CUR/conf/server.toml to use "$WORK_DIR", "$CDC_BINARY",
and "$CUR/conf/server.toml") and apply the same quoting fix to the other
run_cdc_server invocation referenced in the same script.

Source: Linters/SAST tools

pingyu added 2 commits June 10, 2026 00:12
Signed-off-by: Ping Yu <yuping@pingcap.com>
…nto debug-min-sync-point-interval

Signed-off-by: Ping Yu <yuping@pingcap.com>
@pingyu

pingyu commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

/cc @tenfyzhong

@ti-chi-bot ti-chi-bot Bot requested a review from tenfyzhong June 10, 2026 02:57
@ti-chi-bot

ti-chi-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tenfyzhong
Once this PR has been reviewed and has the lgtm label, please assign flowbehappy for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 10, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-06-10 03:00:28.803278259 +0000 UTC m=+928929.873595639: ☑️ agreed by tenfyzhong.

@pingyu

pingyu commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

/cc @lidezhu

@ti-chi-bot ti-chi-bot Bot requested a review from lidezhu June 10, 2026 03:03
@tenfyzhong

Copy link
Copy Markdown
Collaborator

/check-issue-triage-complete

@lidezhu

lidezhu commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

I think adding this configuration just for testing is not a good idea—it introduces unnecessary complexity. You might as well just hack the value directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: make minSyncPointInterval configurable via debug config

3 participants