[MDEV-31761] Timestamp is written into binary log incorrectly, causes discrepancy upon binlog replaying Created: 2023-07-21 Updated: 2023-11-28 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Replication, Temporal Types |
| Affects Version/s: | 10.4, 10.5, 10.6, 10.9, 10.10, 10.11, 11.0, 11.1 |
| Fix Version/s: | 10.4, 10.5, 10.6, 10.11, 11.0, 11.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Andrei Elkin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
When the current timestamp has microseconds below 100000, it loses leading zeros when written into the binary log. So, when the binlog is replayed, statements inserting into timestamp columns end up with wrong values. It also causes further, more obvious, errors, for example if the mixed replication switches to row format, row events on such tables can no longer be executed, as they refer to rows which aren't in the table.
In the test case above, the first INSERT inserts a row with timestamp 1689978980.012345:
However, in the binlog the query event looks like this:
So, upon binlog replaying, the inserted value is
The test case also does UPDATE, to demonstrate the second point. Since it's update with limit without order by, it switches to row format. So, the row event in the log is
But it cannot be executed, because there is no such value in the table, so at this point binlog replay fails with
Replication however works, at least in this case. I can only guess that the timestamp reading logic on the slave matches the timestamp writing on the master, so it ends up interpreting the value correctly. |