Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infoschema: avoid panic when updating infoschema v2 btree conflicts #58815

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #58712

Problem Summary:

What changed and how does it work?

I check the code again.
If Reload() is thread-safe, the possible write conflict should come from GCOldVersion()

In this commit, I avoid the panic and add more logs for it.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

This kind of case is really difficult to test, this is a guess at the best of my effort.

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 the release-note-none Denotes a PR that doesn't merit a release note. label Jan 9, 2025
@tiancaiamao tiancaiamao requested a review from lance6716 January 9, 2025 04:41
@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 9, 2025
Copy link

tiprow bot commented Jan 9, 2025

Hi @tiancaiamao. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

Copy link
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest lgtm

t2.ReplaceOrInsert(item)
succ = ptr.CompareAndSwap(t, t2)
if !succ {
logutil.BgLogger().Info("infoschema v2 btree concurrently multiple writes detected, this should be rare")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it frequent, maybe use SampleLogger, see SampleLoggerFactory

below too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From @lilinghai 's report, the is rare.
And the gcOldVersion() check interval is 1min, and the check not always trigger a real gcOldVersion(), and even it is triggered, it may not always trigger the concurrent write.
@D3Hunter

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 57.89474% with 8 lines in your changes missing coverage. Please review.

Project coverage is 75.1210%. Comparing base (8390fc4) to head (da2de44).
Report is 45 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58815        +/-   ##
================================================
+ Coverage   73.4645%   75.1210%   +1.6564%     
================================================
  Files          1676       1722        +46     
  Lines        464424     475176     +10752     
================================================
+ Hits         341187     356957     +15770     
+ Misses       102397      96030      -6367     
- Partials      20840      22189      +1349     
Flag Coverage Δ
integration 49.0191% <57.8947%> (?)
unit 72.6606% <31.5789%> (+0.3768%) ⬆️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 61.6778% <ø> (+15.9575%) ⬆️

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 9, 2025
Copy link

ti-chi-bot bot commented Jan 9, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, wjhuang2016

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

The pull request process is described 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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 9, 2025
Copy link

ti-chi-bot bot commented Jan 9, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-01-09 06:36:15.6285979 +0000 UTC m=+421918.917429616: ☑️ agreed by D3Hunter.
  • 2025-01-09 08:53:20.673333558 +0000 UTC m=+430143.962165263: ☑️ agreed by wjhuang2016.

@ti-chi-bot ti-chi-bot bot merged commit 43d9298 into pingcap:master Jan 9, 2025
26 checks passed
@tiancaiamao tiancaiamao deleted the issue58712-re branch January 16, 2025 02:30
@tiancaiamao tiancaiamao added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Jan 16, 2025
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jan 16, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #58966.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TiDB crash for concurrently multiple writes are not allowed when lighting/br import
4 participants