sync-diff-inspector: --check-struct-only should not warn 'fail to get the correct size of table'

Open Beginner friendly
#12,821 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
Half a day
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
go
Domain
backend, databases

Research direction

In sync-diff-inspector/report/report.go, start at PrintSummary and trace how it calls CalculateTotalSize and handles size and err. Verify the behavior with --check-struct-only and with an empty table. Done means size calculation is skipped for structure-only checks and warnings occur only when err is non-nil.

Written by the indexing model from the issue text.

Description

contribution first-time-contributor
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:

  1. --check-struct-only means the user only wants to compare table structures, not data. Table size is irrelevant in this scenario.
  2. 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?
  1. When --check-struct-only is true, CalculateTotalSize should be skipped entirely, since table size is meaningless when only checking structure.
  2. 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.
Dominant language
Go
Stars
464
Forks
313
Avg merge
4d 7h
Merged PRs (30d)
14

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pingcap/tiflow

All issues in pingcap/tiflow

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.