Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

*: add etcd key for start-relay without worker name #2249

Closed
wants to merge 4 commits into from

Conversation

lance6716
Copy link
Collaborator

@lance6716 lance6716 commented Oct 21, 2021

What problem does this PR solve?

part of #2241. The rest work will be done in another PR after #2219 is merged to reduce conflict.

What is changed and how it works?

as title, this key is just a marker like enable-relay in source config. But we'll dynamically change the value, and we should not modify the original input source config, so I persist it in etcd.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has persistent data change

Side effects

  • Breaking backward compatibility (this etcd key can not be recgonized when downgrade, but I think that is expected)

Related changes

  • Need to cherry-pick to the release branch

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Oct 21, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Ehco1996

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@@ -275,3 +275,5 @@ func upgradeToVer3(ctx context.Context, cli *clientv3.Client) error {
func upgradeToVer4(cli *clientv3.Client, uctx Context) error {
return nil
}

// TODO: should we set UpstreamEnableRelayKeyAdapter when upgrading from <2.0.2
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I prefer not, user will not aware of this behaviour if we automatically do for him, so when he adds new sources he will not meet expectation.

Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe it's OK if we automatically start-relay for source added before upgrading. And for newly added sources, operate-source will return a message to notify user 🤔

@sunzhaoyang

Choose a reason for hiding this comment

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

If a source with enable-relay: true has to be automatically start-relayed after the upgrade.
If the source is added later, the enable-relay configuration is no longer valid, so you should give him an error and indicate that the configuration has been replaced with the start-relay command. Tell him to remove enable-relay from the configuration and create it again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please check the expected behaviour:

case 1)

  1. in v2.0.1, user creates enable-relay: true source
  2. upgrade to v2.1.0. That source should automatically turn on relay log when bound to any workers
  3. newly added sources should has an ERROR message failing operate-source create (QuestionA: WARN message and not failing the command is enough?)

case 2)

  1. in v2.0.1, user creates enable-relay: true source
  2. upgrade to v2.0.7. That source has not automatically turn on relay log
  3. further upgrade to v2.1.0. That source should also not automatically turn on relay log. And dmctl export will write enable-relay: true when exporting. (QuestionB: should we write enable-relay: false, so that these source config files can be used for this version?)

case 3)

  1. in v2.0.1, user creates enable-relay: true source
  2. upgrade to v2.0.7. That source has not automatically turn on relay log
  3. user turns on relay log by start-relay -s <source-id> workerA
  4. upgrade to v2.1.0. That source should only turn on relay log when bound to workerA

please check if this is expected, and check we don't choose behaviour of questions.

@sunzhaoyang

Choose a reason for hiding this comment

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

case 1) QuestionA: report a warning is enough, consider changing to error in future versions
case 2) QuestionB: exported source config should not include enable-relay, it is invalid.

rest LGTM

Copy link
Collaborator Author

@lance6716 lance6716 Oct 26, 2021

Choose a reason for hiding this comment

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

QuestionB: exported source config should not include enable-relay, it is invalid.

dmctl export is mainly used for downgrading, if we don't write enable-relay, user will have to adjust the content of every files when downgrading to v2.0.1 to keep relay enabled

Choose a reason for hiding this comment

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

I did not consider this scenario, but I still find it strange that the new version of the software exports the currently obsolete parameters, and there are very few degradations, which may not be a big problem.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, i'll implement it in next PR.

@lance6716 lance6716 added the needs-cherry-pick-release-2.0 This PR should be cherry-picked to release-2.0. Remove this label after cherry-picked to release-2.0 label Oct 21, 2021
@Ehco1996
Copy link
Contributor

we should not modify the original input source config

can you tell me the reason ? actually we already update the user input source-cfg when they start-relay through openapi😅

if err := s.scheduler.UpdateSourceCfg(sourceCfg); err != nil {

@lance6716
Copy link
Collaborator Author

lance6716 commented Oct 25, 2021

we should not modify the original input source config

can you tell me the reason ? actually we already update the user input source-cfg when they start-relay through openapi😅

currently we don't want to start relay for enable-relay in source config. If we write enable-relay to source config, after a new master elected leader, it will not distinguish the two scenarios only from one field.

Copy link
Contributor

@Ehco1996 Ehco1996 left a comment

Choose a reason for hiding this comment

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

i am not sure if we need to add some adapter logic with this key when pause/resume relay ?

rest LGTM

@@ -275,3 +275,5 @@ func upgradeToVer3(ctx context.Context, cli *clientv3.Client) error {
func upgradeToVer4(cli *clientv3.Client, uctx Context) error {
return nil
}

// TODO: should we set UpstreamEnableRelayKeyAdapter when upgrading from <2.0.2
Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm

func (s *Scheduler) recoverRelayConfigs(cli *clientv3.Client) error {
relayWorkers, _, err := ha.GetAllRelayConfig(cli)
if err != nil {
return err
}
s.relayWorkers = relayWorkers
sources, _, err := ha.GetAllEnabledRelaySources(cli)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a test when Scheduler start ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in next PR, when this field can really take effect

Copy link
Collaborator Author

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

i am not sure if we need to add some adapter logic with this key when pause/resume relay ?

The pause/resume action will change the status of all relay workers, and this key helps to create relay worker, not sure what logic you want to add

func (s *Scheduler) recoverRelayConfigs(cli *clientv3.Client) error {
relayWorkers, _, err := ha.GetAllRelayConfig(cli)
if err != nil {
return err
}
s.relayWorkers = relayWorkers
sources, _, err := ha.GetAllEnabledRelaySources(cli)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in next PR, when this field can really take effect

@@ -275,3 +275,5 @@ func upgradeToVer3(ctx context.Context, cli *clientv3.Client) error {
func upgradeToVer4(cli *clientv3.Client, uctx Context) error {
return nil
}

// TODO: should we set UpstreamEnableRelayKeyAdapter when upgrading from <2.0.2
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe it's OK if we automatically start-relay for source added before upgrading. And for newly added sources, operate-source will return a message to notify user 🤔

@sunzhaoyang

@ti-chi-bot ti-chi-bot added the status/LGT1 One reviewer already commented LGTM label Oct 26, 2021
@lance6716
Copy link
Collaborator Author

/run-integration-test

@lance6716
Copy link
Collaborator Author

/run-unit-test

@lance6716
Copy link
Collaborator Author

/cc @GMHDBJD

@lance6716
Copy link
Collaborator Author

replaced by https://github.com/pingcap/ticdc/pull/3190

@lance6716 lance6716 closed this Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-cherry-pick-release-2.0 This PR should be cherry-picked to release-2.0. Remove this label after cherry-picked to release-2.0 size/L status/LGT1 One reviewer already commented LGTM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants