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

api,config(ticdc): support update transaction-atomicity and protocol via config file #7980

Merged
merged 2 commits into from
Jan 5, 2023

Conversation

CharlesCheung96
Copy link
Contributor

@CharlesCheung96 CharlesCheung96 commented Dec 26, 2022

What problem does this PR solve?

Issue Number: close #7935

What is changed and how it works?

  1. For testing purposes, make blackhole compatible with any protocol.
  2. Replace defaultMqTxnAtomicity and defaultMysqlTxnAtomicity with defaultTxnAtomicity. Remove the logic for changing default value of TxnAtomicity) and simplify such logic in ShouldSplitTxn and validate.
  3. Check whether the sinkURI is compatible with the sink config when updating configs.

Note compatibility change: After this pr, transaction-atomicity will not be automatically changed when creating changefeed and an error will be returned when any incompatible configuration is encountered.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test api
  1. create changefeed use config: curl -X POST -H "'Content-type':'application/json'" http://127.0.0.1:8300/api/v1/changefeeds -d '{"changefeed_id":"test","sink_uri":"blackhole://root@10.1.1.1", "sink_config":{"protocol":"canal", "transaction-atomicity":"table"}}', then pause changefeed
  2. update via config file: curl -X PUT -H "'Content-type':'application/json'" http://127.0.0.1:8300/api/v1/changefeeds/test -d '{"sink_config":{"protocol":"canal-json", "transaction-atomicity":"none"}}', then query config:

./cdc cli changefeed query -c test --server=127.0.0.1:8300

  "sink_uri": "blackhole://root@10.1.1.1",
...
  "sink": {
      "protocol": "canal-json",
      "schema_registry": "",
      "csv": null,
      "column_selectors": null,
      "transaction_atomicity": "none",
      "encoder_concurrency": 0,
      "terminator": "\r\n",
      "date_separator": "",
      "enable_partition_separator": false
    }
...
  1. update both sinkuri and config file, the configuration in file will be ignored: curl -X PUT -H "'Content-type':'application/json'" http://127.0.0.1:8300/api/v1/changefeeds/test -d '{"sink_uri":"blackhole://root@10.1.1.1?protocol=canal&transaction-atomicity=table", "sink_config":{"protocol":"avro", "transaction-atomicity":"none"}}'

./cdc cli changefeed query -c test --server=127.0.0.1:8300

   "sink_uri": "blackhole://root@10.1.1.1?protocol=canal\u0026transaction-atomicity=table",
...
   "sink": {
      "protocol": "canal",
      "schema_registry": "",
      "csv": null,
      "column_selectors": null,
      "transaction_atomicity": "table",
      "encoder_concurrency": 0,
      "terminator": "\r\n",
      "date_separator": "",
      "enable_partition_separator": false
    },
...
  1. If set config in sinkuri, can not update via config file: curl -X PUT -H "'Content-type':'application/json'" http://127.0.0.1:8300/api/v1/changefeeds/test -d '{"sink_config":{"protocol":"avro", "transaction-atomicity":"none"}}'
{
    "error_msg": "[CDC:ErrChangefeedUpdateRefused]changefeed update error: [CDC:ErrIncompatibleSinkConfig]incompatible configuration in sink uri(transaction-atomicity=table, protocol=canal) and config file(transaction-atomicity=none, protocol=avro)",
    "error_code": "CDC:ErrChangefeedUpdateRefused"
}#
  • Manual test cli
  1. create changefeed use config:
cat > ./cfg.yaml <<  EOF                                                                            
sink.protocol="canal"
sink.transaction-atomicity="table"
EOF
./cdc cli changefeed create --sink-uri="blackhole://root@10.1.1.1" -c test --server=127.0.0.1:8300 --config cfg.y
aml
 then pause changefeed
  1. update via config file:
cat > ./cfg.yaml <<  EOF                                                                           
sink.protocol="canal-json"
sink.transaction-atomicity="none"
EOF
 ./cdc cli changefeed update -c test --server  http://127.0.0.1:8300/ --config ./cfg.yaml             
Diff of changefeed config:
{Type:update Path:[Config Sink Protocol] From:canal To:canal-json}
{Type:update Path:[Config Sink TxnAtomicity] From:table To:none}
Could you agree to apply changes above to changefeed [Y/N]
Y
Update changefeed config successfully!
ID: test
Info: {"upstream_id":7182840064097419647,"namespace":"default","id":"test","sink_uri":"blackhole://root@10.1.1.1","create_time":"2022-12-30T16:58:23.431511759+08:00","start_ts":438407188528496644,"admin_job_type":1,"engine":"unified","config":{"memory_quota":268435456,"case_sensitive":true,"enable_old_value":true,"force_replicate":false,"ignore_ineligible_table":false,"check_gc_safe_point":true,"enable_sync_point":false,"bdr_mode":false,"sync_point_interval":600000000000,"sync_point_retention":86400000000000,"filter":{"rules":["*.*"],"event_filters":null},"mounter":{"worker_num":16},"sink":{"protocol":"canal-json","schema_registry":"","csv":{"delimiter":",","quote":"\"","null":"\\N","include_commit_ts":false},"column_selectors":null,"transaction_atomicity":"none","encoder_concurrency":16,"terminator":"\r\n","date_separator":"none","enable_partition_separator":false},"consistent":{"level":"none","max_log_size":64,"flush_interval":2000,"storage":""}},"state":"stopped","creator_version":"v6.5.0-master"}
  1. update both sinkuri and config file, the configuration in file will be ignored:
cat > ./cfg.yaml <<  EOF                                                                         
sink.protocol="avro"
sink.transaction-atomicity="none"
EOF
./cdc cli changefeed update -c test --server  http://127.0.0.1:8300/ --sink-uri "blackhole://root@10.1.1.1?protocol=canal&transaction-atomicity=table" --config ./cfg.yaml
Diff of changefeed config:
{Type:update Path:[SinkURI] From:blackhole://root@10.1.1.1 To:blackhole://root@10.1.1.1?protocol=canal&transaction-atomicity=table}
{Type:update Path:[Config Sink Protocol] From:canal-json To:avro}
Could you agree to apply changes above to changefeed [Y/N]
Y
Update changefeed config successfully!
ID: test
Info: {"upstream_id":7182840064097419647,"namespace":"default","id":"test","sink_uri":"blackhole://root@10.1.1.1?protocol=canal\u0026transaction-atomicity=table","create_time":"2022-12-30T16:58:23.431511759+08:00","start_ts":438407188528496644,"admin_job_type":1,"engine":"unified","config":{"memory_quota":268435456,"case_sensitive":true,"enable_old_value":true,"force_replicate":false,"ignore_ineligible_table":false,"check_gc_safe_point":true,"enable_sync_point":false,"bdr_mode":false,"sync_point_interval":600000000000,"sync_point_retention":86400000000000,"filter":{"rules":["*.*"],"event_filters":null},"mounter":{"worker_num":16},"sink":{"protocol":"canal","schema_registry":"","csv":{"delimiter":",","quote":"\"","null":"\\N","include_commit_ts":false},"column_selectors":null,"transaction_atomicity":"table","encoder_concurrency":16,"terminator":"\r\n","date_separator":"none","enable_partition_separator":false},"consistent":{"level":"none","max_log_size":64,"flush_interval":2000,"storage":""}},"state":"stopped","creator_version":"v6.5.0-master"}
  1. If set config in sinkuri, can not update via file:
 ./cdc cli changefeed update -c test --server  http://127.0.0.1:8300/ --config ./cfg.yaml            
Diff of changefeed config:
{Type:update Path:[Config Sink Protocol] From:canal To:avro}
{Type:update Path:[Config Sink TxnAtomicity] From:table To:none}
Could you agree to apply changes above to changefeed [Y/N]
Y
Error: [CDC:ErrChangefeedUpdateRefused]changefeed update error: [CDC:ErrIncompatibleSinkConfig]incompatible configuration in sink uri(transaction-atomicity=table, protocol=canal) and config file(transaction-atomicity=none, protocol=avro)

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

`Fix the issue of transaction-atomicity and protocol can't be updated via config file`.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Dec 26, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • asddongmen
  • sdojjy

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.

@ti-chi-bot ti-chi-bot added do-not-merge/needs-triage-completed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed do-not-merge/needs-triage-completed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 26, 2022
@CharlesCheung96 CharlesCheung96 marked this pull request as ready for review December 27, 2022 15:09
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 27, 2022
@CharlesCheung96
Copy link
Contributor Author

/hold wait for test result

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 28, 2022
@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 3, 2023
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 3, 2023
@sdojjy
Copy link
Member

sdojjy commented Jan 3, 2023

/run-verify-test

@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Jan 4, 2023
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. label Jan 5, 2023
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 5, 2023
@CharlesCheung96
Copy link
Contributor Author

/run-all-tests

@CharlesCheung96
Copy link
Contributor Author

/run-all-tests

@CharlesCheung96
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: b30ad64

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 5, 2023
@amyangfei
Copy link
Contributor

/run-engine-integration-test

@ti-chi-bot ti-chi-bot merged commit 5b31ba1 into pingcap:master Jan 5, 2023
ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Jan 5, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.1: #8022.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #8023.

CharlesCheung96 added a commit to ti-chi-bot/tiflow that referenced this pull request Jan 10, 2023
CharlesCheung96 added a commit to ti-chi-bot/tiflow that referenced this pull request Jan 10, 2023
ti-chi-bot added a commit that referenced this pull request Jan 11, 2023
ti-chi-bot added a commit that referenced this pull request Jan 12, 2023
…via config file (#7980) (#8023)

* use CheckCompatibilityWithSinkURI

* address comment

Co-authored-by: CharlesCheung <xiaoshuaizx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can't update transaction-atomicity via configuration file
5 participants