pt-table-sync does print floating point numbers in SQL statements with insufficient precision
General
Escalation
General
Escalation
Description
Environment
None
Activity
Show:

Aaditya Dubey September 13, 2024 at 10:11 AMEdited
Hi
Thank you for the report and contribution.
Verified as described.

Aaditya Dubey September 13, 2024 at 10:10 AM
Hi
Thank you for the report.
Verified as described.

Henning Pöttker September 12, 2024 at 9:19 AM
There is a typo in the title of the issue: It should be insufficient
, not sufficient
. Sorry for that.
Unfortunately, I can’t edit the title myself after creating the issue.
Done
Created September 12, 2024 at 8:29 AM
Updated January 14, 2025 at 3:27 PM
Resolved January 14, 2025 at 3:27 PM
Bug description
When
pt-table-sync
generates SQL statements to be executed, it uses Perl’s default mechanism for serializing floating point numbers into strings, i.e. it uses 15 decimal digits.This leads to unwanted changes when using
pt-table-sync
as 15 decimal digits are not sufficient to represent aDOUBLE
value uniquely.The number of printed decimal digits should be increased to 17.
There is a relevant issue in the Perl bug tracker about this:
Reproducing steps
Start a fresh sandbox with the tools from the git repository:
In the source database with port 12345, execute
In the replica database with port 12346, execute
Executing
on the command line will yield on the source (12345):
And on the replica (12346) it yields:
Using
pt-table-sync
to fix the difference gives the following output (with traces omitted):Now, both databases are in sync but the floating point numbers have changed unexpectedly. Executing the
SELECT
query again yields the following on both instaces:Both floating point numbers are now serialized by MySQL with exactly 15 decimal digits, while it used 16 for
value1
and 17 forvalue2
before. Thus, the data has changed.