Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-6630

Fail to insert when timestamp col value is 1970-01-01 00:00:00 in mysql

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a Bug
    • Icon: Major Major
    • None
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      When source mysql table is constructed with timestamp column with default value `0000-00-00 00:00:00`, debezium mysql connector emits message converting to `1970-01-01 00:00:00` into topic.

      Maybe it's converted here

      But it's out of range in mysql timestamp type in both 5.7 and 8.0.

      https://dev.mysql.com/doc/refman/5.7/en/datetime.html

      The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

      Then, the query with this value is failed in jdbc sink connector.

      ...
      Caused by: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect datetime value: '1970-01-01 00:00:00' for column '<column>' at row 1 

      the following is test in mysql console.

      mysql> INSERT INTO timestamp_test (with_default) VALUES ('1970-01-01 00:00:01');
      Query OK, 1 row affected (0.00 sec)
      
      mysql> INSERT INTO timestamp_test (with_default) VALUES ('1970-01-01 00:00:00');
      Query OK, 1 row affected, 1 warning (0.01 sec)
      mysql> show warnings;
      +---------+------+-------------------------------------------------------+
      | Level   | Code | Message                                               |
      +---------+------+-------------------------------------------------------+
      | Warning | 1264 | Out of range value for column 'with_default' at row 1 |
      +---------+------+-------------------------------------------------------+
      1 row in set (0.01 sec) 

      I think it would be better to make the mysql connector emit `1970-01-01 00:00:01` UTC

      What do you think? 

              rh-ee-mvitale Mario Fiore Vitale
              hwang031451 Inki Hwang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: