Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli(ticdc): fix create changefeed failure when enable-old-value is set to true #10731

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions cdc/api/v2/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,16 @@ func (d *JSONDuration) UnmarshalJSON(b []byte) error {

// ReplicaConfig is a duplicate of config.ReplicaConfig
type ReplicaConfig struct {
MemoryQuota uint64 `json:"memory_quota"`
CaseSensitive bool `json:"case_sensitive"`
ForceReplicate bool `json:"force_replicate"`
IgnoreIneligibleTable bool `json:"ignore_ineligible_table"`
CheckGCSafePoint bool `json:"check_gc_safe_point"`
EnableSyncPoint *bool `json:"enable_sync_point,omitempty"`
EnableTableMonitor *bool `json:"enable_table_monitor,omitempty"`
BDRMode *bool `json:"bdr_mode,omitempty"`
MemoryQuota uint64 `json:"memory_quota"`
CaseSensitive bool `json:"case_sensitive"`
// Deprecated: we don't use this field since v7.5.0.
EnableOldValue bool `json:"-"`
ForceReplicate bool `json:"force_replicate"`
IgnoreIneligibleTable bool `json:"ignore_ineligible_table"`
CheckGCSafePoint bool `json:"check_gc_safe_point"`
EnableSyncPoint *bool `json:"enable_sync_point,omitempty"`
EnableTableMonitor *bool `json:"enable_table_monitor,omitempty"`
BDRMode *bool `json:"bdr_mode,omitempty"`

SyncPointInterval *JSONDuration `json:"sync_point_interval,omitempty" swaggertype:"string"`
SyncPointRetention *JSONDuration `json:"sync_point_retention,omitempty" swaggertype:"string"`
Expand Down Expand Up @@ -220,6 +222,7 @@ func (c *ReplicaConfig) toInternalReplicaConfigWithOriginConfig(
) *config.ReplicaConfig {
res.MemoryQuota = c.MemoryQuota
res.CaseSensitive = c.CaseSensitive
res.EnableOldValue = c.EnableOldValue
res.ForceReplicate = c.ForceReplicate
res.CheckGCSafePoint = c.CheckGCSafePoint
res.EnableSyncPoint = c.EnableSyncPoint
Expand Down Expand Up @@ -518,6 +521,7 @@ func ToAPIReplicaConfig(c *config.ReplicaConfig) *ReplicaConfig {
res := &ReplicaConfig{
MemoryQuota: cloned.MemoryQuota,
CaseSensitive: cloned.CaseSensitive,
EnableOldValue: cloned.EnableOldValue,
ForceReplicate: cloned.ForceReplicate,
IgnoreIneligibleTable: cloned.IgnoreIneligibleTable,
CheckGCSafePoint: cloned.CheckGCSafePoint,
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/cli/cli_changefeed_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ func (o *createChangefeedOptions) validate(cmd *cobra.Command) error {
if o.timezone != "SYSTEM" {
cmd.Printf(color.HiYellowString("[WARN] --tz is deprecated in changefeed settings.\n"))
}
if o.cfg != nil && o.cfg.EnableOldValue {
cmd.Printf("[WARN] `enable-old-value` is deprecated in changefeed config files. " +
"And it is the default behaviour of cdc now. You don't need to specify it manually.\n")
}

// user is not allowed to set sort-dir at changefeed level
if o.commonChangefeedOptions.sortDir != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/cli_changefeed_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestChangefeedCreateCli(t *testing.T) {
cmd := newCmdCreateChangefeed(f)
dir := t.TempDir()
configPath := filepath.Join(dir, "cf.toml")
err := os.WriteFile(configPath, []byte("enable-sync-point=true\r\nsync-point-interval='20m'"), 0o644)
err := os.WriteFile(configPath, []byte("enable-sync-point=true\r\nenable-old-value=true\r\nsync-point-interval='20m'"), 0o644)
require.Nil(t, err)
os.Args = []string{
"create",
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/cli_changefeed_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func confirmOverwriteCheckpointTs(
// If ignore it will return true.
func confirmIgnoreIneligibleTables(cmd *cobra.Command) (bool, error) {
cmd.Printf("Could you agree to ignore those tables, and continue to replicate [Y/N]\n" +
"Note: If you don't want to ignore those tables, please set `force-replicate to` true " +
"Note: If you don't want to ignore those tables, please set `force-replicate` to true " +
"in the changefeed config file.\n")
confirmed := readYOrN(cmd)
if !confirmed {
Expand Down
10 changes: 6 additions & 4 deletions pkg/config/replica_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ func (d *Duration) UnmarshalText(text []byte) error {
type ReplicaConfig replicaConfig

type replicaConfig struct {
MemoryQuota uint64 `toml:"memory-quota" json:"memory-quota"`
CaseSensitive bool `toml:"case-sensitive" json:"case-sensitive"`
ForceReplicate bool `toml:"force-replicate" json:"force-replicate"`
CheckGCSafePoint bool `toml:"check-gc-safe-point" json:"check-gc-safe-point"`
MemoryQuota uint64 `toml:"memory-quota" json:"memory-quota"`
CaseSensitive bool `toml:"case-sensitive" json:"case-sensitive"`
// Deprecated: we don't use this field since v7.5.0.
EnableOldValue bool `toml:"enable-old-value" json:"-"`
ForceReplicate bool `toml:"force-replicate" json:"force-replicate"`
CheckGCSafePoint bool `toml:"check-gc-safe-point" json:"check-gc-safe-point"`
// EnableSyncPoint is only available when the downstream is a Database.
EnableSyncPoint *bool `toml:"enable-sync-point" json:"enable-sync-point,omitempty"`
EnableTableMonitor *bool `toml:"enable-table-monitor" json:"enable-table-monitor"`
Expand Down
Loading