What problem does this issue solve?
When running sync-diff-inspector with --check-struct-only, it still outputs the warning:
[WARN] [report.go:166] ["fail to get the correct size of table, if you want to get the correct size, please analyze the corresponding tables"] [table=`futures_position`.`position_10`]
This warning is misleading because:
--check-struct-only means the user only wants to compare table structures, not data. Table size is irrelevant in this scenario.
- Even if the user does not use
--check-struct-only, when a table is genuinely empty (data_length = 0 in information_schema.tables), the warning is also incorrectly triggered. The code treats size == 0 the same as a query error, but an empty table is a perfectly valid case.
Root Cause
In sync_diff_inspector/report/report.go, CalculateTotalSize is unconditionally called in PrintSummary, regardless of whether --check-struct-only is set. The condition if size == 0 || err != nil conflates two different cases: a real error vs. a legitimately empty table.
What is the expected behavior?
- When
--check-struct-only is true, CalculateTotalSize should be skipped entirely, since table size is meaningless when only checking structure.
- When
size == 0 and err == nil (i.e., the table is empty), the warning should not be emitted. Only a real error (err != nil) should trigger the warning.
What problem does this issue solve?
When running sync-diff-inspector with
--check-struct-only, it still outputs the warning:This warning is misleading because:
--check-struct-onlymeans the user only wants to compare table structures, not data. Table size is irrelevant in this scenario.--check-struct-only, when a table is genuinely empty (data_length = 0 ininformation_schema.tables), the warning is also incorrectly triggered. The code treatssize == 0the same as a query error, but an empty table is a perfectly valid case.Root Cause
In
sync_diff_inspector/report/report.go,CalculateTotalSizeis unconditionally called inPrintSummary, regardless of whether--check-struct-onlyis set. The conditionif size == 0 || err != nilconflates two different cases: a real error vs. a legitimately empty table.What is the expected behavior?
--check-struct-onlyis true,CalculateTotalSizeshould be skipped entirely, since table size is meaningless when only checking structure.size == 0anderr == nil(i.e., the table is empty), the warning should not be emitted. Only a real error (err != nil) should trigger the warning.