Skip to content

Conversation

@Kamlesh72
Copy link

Description

Fail the setup if initial_wait_time is 0 or negative

Fixes #492

Screenshots or Recordings

UI
Screenshot 2025-10-05 at 1 34 01 AM

CLI
Screenshot 2025-10-05 at 1 38 52 AM

@CLAassistant
Copy link

CLAassistant commented Oct 4, 2025

CLA assistant check
All committers have signed the CLA.

@vaibhav-datazip
Copy link
Collaborator

similar check needs to be added in Postgres as well

@Kamlesh72
Copy link
Author

@vaibhav-datazip Currently in postgres if User provide initial_wait_time to 0, we set it to default value ( 1200 ).

Instead of that, If User provide initial_wait_time we validate it [ 120, 2400 ].
If User doesn't provide initial_wait_time then we set to 1200.

Does that works?

found, _ := utils.IsOfType(p.config.UpdateMethod, "replication_slot")
if found {
logger.Info("Found CDC Configuration")
cdc := &CDC{}
if err := utils.Unmarshal(p.config.UpdateMethod, cdc); err != nil {
return err
}
// set default value
cdc.InitialWaitTime = utils.Ternary(cdc.InitialWaitTime == 0, 1200, cdc.InitialWaitTime).(int)
// check if initial wait time is valid or not
if cdc.InitialWaitTime < 120 || cdc.InitialWaitTime > 2400 {
return fmt.Errorf("the CDC initial wait time must be at least 120 seconds and less than 2400 seconds")
}

@vaibhav-datazip
Copy link
Collaborator

@Kamlesh72 , one more check needs to be added here , if cdc config is selected and Olake mysql cdc setup permissions are missing or not granted, then too the check should fail when clicked next

@vaibhav-datazip vaibhav-datazip added the hacktoberfest Issues open for Hacktoberfest contributors label Oct 7, 2025
@Kamlesh72
Copy link
Author

@vaibhav-datazip Shouldn't we check cdcSupported only if user has provided initial_wait_time and fail setup if cdc is not supported ?

https://github.com/datazip-inc/olake/blob/a79f88af07fb97e3b9181d906585b7965e9172cf/drivers/mysql/internal/mysql.go#L121-130

@vaibhav-datazip
Copy link
Collaborator

@vaibhav-datazip Shouldn't we check cdcSupported only if user has provided initial_wait_time and fail setup if cdc is not supported ?

https://github.com/datazip-inc/olake/blob/a79f88af07fb97e3b9181d906585b7965e9172cf/drivers/mysql/internal/mysql.go#L121-130

exactly, if user has selected cdc mode instead of standalone mode (speaking in terms of UI), we should add a check that cdc conditions are met. If these condition checks fail then we should throw error, like binlog permissions alongwith correct cdc initial wait time.

@Kamlesh72
Copy link
Author

@vaibhav-datazip Added mysql permission check and postgres checks.

Comment on lines -258 to +278
return false, nil
return false, fmt.Errorf(warnMessage)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why Is this change done ??

Copy link
Author

Choose a reason for hiding this comment

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

// Enable CDC support if binlog is configured
cdcSupported, err := m.IsCDCSupported(ctx)
if err != nil {
return err
}

So if error occurs, user can see error like binlog_format is not set to ROW

Comment on lines -108 to +114
// set default value
cdc.InitialWaitTime = utils.Ternary(cdc.InitialWaitTime == 0, 1200, cdc.InitialWaitTime).(int)

// Set initial_wait_time to 1200 if not provided by user
userProvided, _ := utils.IsOfType(p.config.UpdateMethod, "initial_wait_time")
if !userProvided {
cdc.InitialWaitTime = 1200
logger.Infof("CDC initial wait time not provided by user, defaulting to %d", cdc.InitialWaitTime)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason for this change ?

Copy link
Author

Choose a reason for hiding this comment

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

If user leave Initial wait time field empty, we set to 1200.
If user enters any value ( including 0 ), then only we validate.

So if user enters 0, I thought we shouldn't silently change that to default value.

cdc.InitialWaitTime = utils.Ternary(cdc.InitialWaitTime == 0, 1200, cdc.InitialWaitTime).(int)

// Set initial_wait_time to 1200 if not provided by user
userProvided, _ := utils.IsOfType(p.config.UpdateMethod, "initial_wait_time")
Copy link
Collaborator

Choose a reason for hiding this comment

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

also why no query based check is added in postgres side.

you can visit the olake documentation on how to verify cdc configurations

SELECT name, setting FROM pg_settings 
WHERE name IN ('wal_level', 'max_replication_slots', 'max_wal_senders');

Copy link
Author

Choose a reason for hiding this comment

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

My mistake I didnt checked that. I will include it in code.

Copy link
Author

Choose a reason for hiding this comment

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

Will update this by tomorrow ( saturday ).

Copy link
Collaborator

Choose a reason for hiding this comment

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

any updates on this @Kamlesh72 ?

@vaibhav-datazip
Copy link
Collaborator

hi @Kamlesh72 , will be closing this PR if you are no longer working on this

@Kamlesh72
Copy link
Author

@vaibhav-datazip I will surely merge it this week. Sorry for the delay.

@vaibhav-datazip
Copy link
Collaborator

@vaibhav-datazip I will surely merge it this week. Sorry for the delay.

okay then, no problem . please resolve the merge conflicts and acknowledge the previous comments

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

Labels

hacktoberfest Issues open for Hacktoberfest contributors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants