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

ttl: fix potential go leak for ttl in test #46953

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

lcwangchao
Copy link
Collaborator

@lcwangchao lcwangchao commented Sep 13, 2023

What problem does this PR solve?

Issue Number: close #46948

What is changed and how it works?

In the previous code, the ttlJobManager is created and started in a background goroutine:

tidb/domain/domain.go

Lines 2917 to 2929 in a7e3176

func (do *Domain) StartTTLJobManager() {
do.wg.Run(func() {
defer func() {
logutil.BgLogger().Info("ttlJobManager exited.")
}()
ttlJobManager := ttlworker.NewJobManager(do.ddl.GetID(), do.sysSessionPool, do.store, do.etcdClient, do.ddl.OwnerManager().IsOwner)
do.ttlJobManager.Store(ttlJobManager)
ttlJobManager.Start()
<-do.exit
}, "ttlJobManager")
}

It has a probability that if a test runs very fast and domain.Close will be called before do.ttlJobManager.Store(ttlJobManager) . The ttlJobManager will not stop anymore.

In this PR, we just move ttlJobManager's create and start out of the goroutine.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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 Sep 13, 2023
@ti-chi-bot ti-chi-bot bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 13, 2023
domain/domain.go Outdated Show resolved Hide resolved
Co-authored-by: Weizhen Wang <[email protected]>
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 13, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 13, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, YangKeao

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:
  • OWNERS [YangKeao,hawkingrei]

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 Sep 13, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 13, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-09-13 10:24:31.446272725 +0000 UTC m=+81037.413860776: ☑️ agreed by hawkingrei.
  • 2023-09-13 10:27:52.246041741 +0000 UTC m=+81238.213629791: ☑️ agreed by YangKeao.

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #46953 (665763a) into master (c7f5781) will decrease coverage by 0.4507%.
Report is 16 commits behind head on master.
The diff coverage is 76.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #46953        +/-   ##
================================================
- Coverage   73.2870%   72.8363%   -0.4507%     
================================================
  Files          1331       1352        +21     
  Lines        397358     407243      +9885     
================================================
+ Hits         291212     296621      +5409     
- Misses        87541      92048      +4507     
+ Partials      18605      18574        -31     
Flag Coverage Δ
integration 28.3850% <15.4285%> (?)
unit 73.5495% <76.0000%> (+0.2624%) ⬆️

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

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 85.0019% <ø> (ø)
br 48.6139% <100.0000%> (-4.2997%) ⬇️

@hawkingrei
Copy link
Member

/test all

@hawkingrei
Copy link
Member

/retest

2 similar comments
@lcwangchao
Copy link
Collaborator Author

/retest

@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot merged commit 1675fde into pingcap:master Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

goleak ttl/ttlworker in the planner/cascades
3 participants