sync_diff_inspector: check rows.Err in TiDB iterator#901
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @banerjeeadrish. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Welcome @banerjeeadrish! |
77b07ad to
fc123bd
Compare
What problem does this PR solve?
Issue Number: close #900
sync-diff-inspectorcan silently swallow TiDB row-stream errors during row comparison.When
TiDBRowsIterator.Next()seesrows.Next() == false, it currently returns(nil, nil)directly. However, per thedatabase/sqlcontract,rows.Next() == falsecan mean either clean EOF or an iteration error. The caller must checkrows.Err()to distinguish the two cases.If the TiDB-side query is cancelled mid-stream, for example due to
tidb_mem_quota_query,sync-diff-inspectorcan incorrectly treat the TiDB iterator as exhausted. This may produce false+N/-0diffs and bogusREPLACE INTOfix SQL instead of surfacing the original TiDB query error.What is changed and how it works?
This PR updates
TiDBRowsIterator.Next()to checks.rows.Err()afters.rows.Next()returns false.If
rows.Err()is non-nil, the iterator now returns the error instead of treating it as clean EOF. The existing row comparison flow already propagates non-nil iterator errors, so the table comparison fails with the real TiDB error instead of generating false fix SQL.A unit test was added to cover the row-stream error case and verify that
TiDBRowsIterator.Next()returns the underlyingdatabase/sqlerror.Check List
Tests
Code changes
Side effects
Related changes