Skip to content

Conversation

@wjhuang2016
Copy link
Member

@wjhuang2016 wjhuang2016 commented Nov 28, 2025

What problem does this PR solve?

Issue Number: close #64666

Problem Summary:
In the generateAndSendJob function, we previously referenced one region job at a time and immediately sent it to jobToWorkerCh. If a job (especially an empty job) finished before the next job was referenced, the reference count could drop to 0, causing memoryIngestData to be cleaned unexpectedly. This prevented other jobs still being processed from accessing the data, leading to data inconsistency.
In tidb-x scenarios, where region sizes are larger than the configured SplitRegionSize, some regions' jobs are empty. These empty jobs are processed quickly, which makes this issue more likely to occur.

What changed and how does it work?

We modified the logic in generateAndSendJob to reference all jobs before sending them to jobToWorkerCh. Specifically, we first call job.ref(jobWg) for all generated jobs in a loop, and then send them to the channel one by one in a separate loop.

This ensures all jobs have their reference counts incremented before any of them are sent to the channel. Even if some jobs (like empty jobs) finish quickly and call done(), as long as other jobs still hold references, ingestData will not be cleaned prematurely. Only when all jobs complete and call done() will the reference count reach 0, at which point ingestData can be safely cleaned, preventing data inconsistency issues.

Check List

Tests

  • Unit test
  • Integration test
    Pass the tidb-x HA add index test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/invalid-title do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 28, 2025
Signed-off-by: wjhuang2016 <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 30, 2025
@codecov
Copy link

codecov bot commented Nov 30, 2025

Codecov Report

❌ Patch coverage is 35.00000% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.1059%. Comparing base (d4c1408) to head (baf0d54).
⚠️ Report is 72 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #64767        +/-   ##
================================================
+ Coverage   72.6813%   74.1059%   +1.4246%     
================================================
  Files          1866       1889        +23     
  Lines        506188     525035     +18847     
================================================
+ Hits         367904     389082     +21178     
+ Misses       115892     112156      -3736     
- Partials      22392      23797      +1405     
Flag Coverage Δ
integration 46.8408% <35.0000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.8700% <ø> (ø)
parser ∅ <ø> (∅)
br 58.1288% <ø> (+11.9752%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joechenrh
Copy link
Contributor

/retest

Signed-off-by: wjhuang2016 <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 1, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Dec 1, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign gmhdbjd for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: wjhuang2016 <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 1, 2025
Signed-off-by: wjhuang2016 <[email protected]>
@wjhuang2016 wjhuang2016 changed the title lightning: ref all the jobs before sending to jobToWorkerCh *: ref all the jobs before sending to jobToWorkerCh Dec 1, 2025
@wjhuang2016
Copy link
Member Author

/retest

Signed-off-by: wjhuang2016 <[email protected]>
@tiprow
Copy link

tiprow bot commented Dec 2, 2025

@wjhuang2016: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow baf0d54 link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

Instructions 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. I understand the commands that are listed here.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Dec 2, 2025

@wjhuang2016: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-unit-test-next-gen baf0d54 link true /test pull-unit-test-next-gen
idc-jenkins-ci-tidb/check_dev_2 baf0d54 link true /test check-dev2
idc-jenkins-ci-tidb/unit-test baf0d54 link true /test unit-test
pull-unit-test-ddlv1 baf0d54 link true /test pull-unit-test-ddlv1
pull-lightning-integration-test baf0d54 link true /test pull-lightning-integration-test
pull-integration-realcluster-test-next-gen baf0d54 link true /test pull-integration-realcluster-test-next-gen
pull-br-integration-test baf0d54 link true /test pull-br-integration-test

Full PR test history. Your PR dashboard.

Instructions 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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[next-gen] data inconsistency in table after simulated kill tikv-worker repeatedly

2 participants