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

Handle zeroed out time when seconds are :00 #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nadflinn
Copy link

It looks like the datetime type for MySQL does not return the correct value when the seconds part of the datetime is :00. For example, the datetime 2023-04-15T12:34:00 in MySQL will end up as 2023-04-15T00:00:00 after being processed by this converter.

I have narrowed this behavior down to the fact that a Java LocalDateTime object is passed to the converter here for datetime:
https://github.com/debezium/debezium/blob/main/debezium-connector-mysql/src/main/java/io/debezium/connector/mysql/RowDeserializers.java#L406

The issue is that when the seconds parameter is :00 the string that is returned omits the seconds piece.

So if you run something like:

import java.time.LocalDateTime;

public class Program
{
    public static void main(String[] args) {
	System.out.println(LocalDateTime.of(2023, 4, 15, 12, 34, 5, 0).toString());
        System.out.println(LocalDateTime.of(2023, 4, 15, 12, 34, 0, 0).toString());
	}
}

You get:

2023-04-15T12:34:05
2023-04-15T12:34

The second example comes back without a seconds portion of the datetime string and this doesn't match the time portion of the existing regex for this converter. This results in the entire time portion being zeroed out to -> 2023-04-15T00:00:00.

The result is that roughly 1 out of 60 timestamps will be wrong (assuming a random distribution of events).

This PR updates the regex to match the time group with just hour and minute portions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant