Skip to content

DNM: Release 6.5.12 Hotfix 20260420#12616

Open
Debra-He wants to merge 10 commits into
pingcap:release-6.5-20250717-v6.5.12from
Debra-He:release-6.5.12-hotfix-20260420
Open

DNM: Release 6.5.12 Hotfix 20260420#12616
Debra-He wants to merge 10 commits into
pingcap:release-6.5-20250717-v6.5.12from
Debra-He:release-6.5.12-hotfix-20260420

Conversation

@Debra-He
Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: close #xxx

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

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

Release note

Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

If you don't think this PR needs a release note then fill it with `None`.

wlwilliamx and others added 10 commits February 2, 2026 00:46
This reverts commit 6ae60b0.
<!--
Thank you for contributing to TiFlow!
Please read MD's [CONTRIBUTING](https://github.com/pingcap/tiflow/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.
-->

<!--
Please create an issue first to describe the problem.

There MUST be one line starting with "Issue Number:  " and
linking the relevant issues via the "close" or "ref".

For more info, check https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/contribute-code.html#referring-to-an-issue.
 -->

Issue Number: close #xxx

 - Unit test
 - Integration test
 - Manual test (add detailed scripts or steps below)
 - No code

```release-note
Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

If you don't think this PR needs a release note then fill it with `None`.
```

Reviewed-on: https://git.pingcap.net/pingkai/tiflow/pulls/17
Reviewed-by: zhaoyilin <zhaoyilin@pingcap.cn>
Co-authored-by: 何芊蔚 <qianwei.he@pingcap.cn>
Co-committed-by: 何芊蔚 <qianwei.he@pingcap.cn>
@ti-chi-bot ti-chi-bot Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Apr 21, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 21, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign asddongmen 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 contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. labels Apr 21, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 21, 2026

Hi @Debra-He. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot Bot added the needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. label Apr 21, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 21, 2026

Welcome @Debra-He!

It looks like this is your first PR to pingcap/tiflow 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tiflow. 😃

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 21, 2026
@pingcap-cla-assistant
Copy link
Copy Markdown

pingcap-cla-assistant Bot commented Apr 21, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

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

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 enhances DDL synchronization by tracking partition IDs during truncation, ensuring DDL ordering via sequence numbers, and implementing session timestamp management in the MySQL sink to preserve upstream CURRENT_TIMESTAMP values. It also adds logic to wait for source table DDLs during CREATE TABLE ... LIKE operations. Review feedback identifies a potential nil pointer dereference in partition info retrieval, incomplete parsing logic for specific ALTER TABLE statements, lack of support for numeric timezone offsets, and precision loss issues when converting nanosecond timestamps to float64.

Comment on lines +794 to +796
newPi := tbInfo.GetPartitionInfo()
oldPi := old.GetPartitionInfo()
newPartitionIDMap := make(map[int64]struct{}, len(newPi.Definitions))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Potential panic if newPi is nil. While TRUNCATE TABLE on a partitioned table should normally result in a new partitioned table, tbInfo is derived from the DDL job's metadata which might be incomplete or malformed in certain edge cases. A safety check for newPi is necessary before accessing its fields.

Suggested change
newPi := tbInfo.GetPartitionInfo()
oldPi := old.GetPartitionInfo()
newPartitionIDMap := make(map[int64]struct{}, len(newPi.Definitions))
newPi := tbInfo.GetPartitionInfo()
if newPi == nil {
return cerror.ErrSnapshotTableNotFound.GenWithStack("table %d is not a partition table", tbInfo.ID)
}
oldPi := old.GetPartitionInfo()
newPartitionIDMap := make(map[int64]struct{}, len(newPi.Definitions))

Comment on lines +109 to +116
case ast.AlterTableAddColumns, ast.AlterTableModifyColumn, ast.AlterTableChangeColumn, ast.AlterTableAlterColumn:
for _, col := range spec.NewColumns {
if hasCurrentTimestampDefault(col) {
cols[col.Name.Name.L] = struct{}{}
}
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The logic for AlterTableStmt is incomplete. It includes ast.AlterTableAlterColumn in the case list but then only iterates over spec.NewColumns, which is typically empty for AlterTableAlterColumn. This case is used for ALTER TABLE ... ALTER COLUMN ... SET DEFAULT ..., and the column name and options should be extracted from spec.Column and spec.Options respectively.

			case ast.AlterTableAddColumns, ast.AlterTableModifyColumn, ast.AlterTableChangeColumn:
				for _, col := range spec.NewColumns {
					if hasCurrentTimestampDefault(col) {
						cols[col.Name.Name.L] = struct{}{}
					}
				}
			case ast.AlterTableAlterColumn:
				for _, opt := range spec.Options {
					if opt.Tp == ast.ColumnOptionDefaultValue && isCurrentTimestampExpr(opt.Expr) {
						cols[spec.Column.Name.L] = struct{}{}
					}
				}

return time.UTC, nil
}
tz := strings.Trim(timezone, "\"")
return time.LoadLocation(tz)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

time.LoadLocation only works for named timezones (e.g., "UTC", "Asia/Shanghai"). If the timezone string is a numeric offset (e.g., "+08:00"), which is a valid value for TiDB's @@time_zone, it will return an error. Consider using a more robust utility that handles both named zones and numeric offsets.

for _, f := range formats {
t, err := time.ParseInLocation(f, val, loc)
if err == nil {
return float64(t.UnixNano()) / float64(time.Second), nil
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using float64 to represent Unix timestamps in nanoseconds leads to precision loss. A float64 has 53 bits of mantissa, which can only represent about 15-17 significant decimal digits, while a Unix timestamp in nanoseconds requires 19 digits. This will likely corrupt the microsecond part of the timestamp when setting @@timestamp. It is recommended to use time.Time throughout these helper functions and format it directly to a string using fmt.Sprintf("%d.%06d", t.Unix(), t.Nanosecond()/1000) to preserve microsecond precision.

@haiboumich
Copy link
Copy Markdown
Contributor

/test pull-verify

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

Labels

contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants