Skip to content

Conversation

@cenkore
Copy link

@cenkore cenkore commented May 8, 2021

related: #161 #247 #269 ..

This PR is to fix the data integrity problem in timestamp conversion datetime scenarios.

Env

Variable_name Value
system_time_zone CST
time_zone +08:00

Reason
The timestamp time_zone parsed from binlog is CST +08:00, go-sql-driver will convert it to UTC +00:00 by default, and finally when applying to the database, even though add session query set @@session.time_zone='+00:00', but because the column type has been changed to datetime, the time zone did not do conversion again, so the time zone was actually only converted by half, causing the data written to _xx_gho is 8 hours smaller.

Solution
In this case, change the time zone from +00:00 to the local system time zone, which is the opposite of datetime convert to timestamp.

Thank you !

@ghost
Copy link

ghost commented Jan 4, 2022

Fixed merge conflict for testing

@ghost ghost temporarily deployed to production January 4, 2022 14:46 Inactive
@ghost ghost temporarily deployed to production January 4, 2022 16:51 Inactive
ghost
ghost previously approved these changes Jul 6, 2022
@timvaillancourt timvaillancourt self-requested a review July 6, 2022 22:24
@timvaillancourt
Copy link
Collaborator

@cenkore / @dm-2 / @rashiq: as this converts data I'd like to be very sure it works now and in the future

Are there any tests that we can add to the localtests/ dir that would:

  1. Confirm master currently has a problem (test fails before changes in this PR)
  2. Confirm the logic in this PR resolves the problem?
    🤔

@timvaillancourt timvaillancourt self-requested a review July 6, 2022 22:29
Copy link
Collaborator

@timvaillancourt timvaillancourt left a comment

Choose a reason for hiding this comment

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

@cenkore see my previous comment 🙏

@ghost ghost modified the milestones: v1.1.5, v1.1.6 Jul 7, 2022
@cenkore
Copy link
Author

cenkore commented Jul 15, 2022

@cenkore see my previous comment 🙏

@timvaillancourt Sorry for taking a long time to reply you. PTAL.

@timvaillancourt timvaillancourt modified the milestones: v1.1.7, v1.1.8 Apr 8, 2024
@meiji163
Copy link
Contributor

@cenkore Is this still an issue? localtests/tz-ts-datetime test passes on the master branch. Also see #1322

@cenkore
Copy link
Author

cenkore commented Apr 29, 2025

@cenkore Is this still an issue? localtests/tz-ts-datetime test passes on the master branch. Also see #1322

It looks good. By the way, is this restriction still necessary?

@meiji163 meiji163 closed this May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants