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

*: support cgroup with systemd #48096

Merged
merged 4 commits into from
Oct 31, 2023
Merged

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Oct 30, 2023

What problem does this PR solve?

Issue Number: close #47442

Problem Summary:

What is changed and how it works?

Check List

Tests

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

1、with systemd

run tidb-server

[Unit]
Description=tidb

[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/tidb
StandardOutput=journal
MemoryMax=500M

[Install]
WantedBy=multi-user.target

you will see the log like this.

 [2023/10/30 11:00:49.325 +00:00] [INFO] [meminfo.go:188] ["use cgroup memory hook"] [cgroupMemorySize=524288000] [physicalMemorySize=32900468736]

2、without systemd

you will see.

[2023/10/30 10:47:16.154 +00:00] [INFO] [meminfo.go:190] ["use physical memory hook"] [cgroupMemorySize=9223372036854775807] [physicalMemorySize=32900468736]
  • 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.

*: support cgroup with systemd

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@ti-chi-bot ti-chi-bot bot added 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 30, 2023
@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Merging #48096 (b41b1f0) into master (f9f6bb3) will increase coverage by 1.3210%.
Report is 18 commits behind head on master.
The diff coverage is 18.5185%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48096        +/-   ##
================================================
+ Coverage   71.5801%   72.9011%   +1.3210%     
================================================
  Files          1401       1423        +22     
  Lines        405938     413328      +7390     
================================================
+ Hits         290571     301321     +10750     
+ Misses        95569      93120      -2449     
+ Partials      19798      18887       -911     
Flag Coverage Δ
integration 42.2787% <18.5185%> (?)
unit 71.7107% <0.0000%> (+0.1306%) ⬆️

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

Components Coverage Δ
dumpling 55.5260% <ø> (+1.4757%) ⬆️
parser ∅ <ø> (∅)
br 49.2243% <ø> (-3.6750%) ⬇️

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. and removed do-not-merge/needs-tests-checked do-not-merge/needs-linked-issue do-not-merge/needs-triage-completed labels Oct 30, 2023
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@hawkingrei
Copy link
Member Author

/test all

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 31, 2023
Copy link
Member

@YangKeao YangKeao 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

// so if we are not in the container, we compare the cgroup memory limit and the physical memory,
// the cgroup memory limit is smaller, we use the cgroup memory hook.
func InitMemoryHook() {
if !cgroup.InContainer() {
Copy link
Member

Choose a reason for hiding this comment

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

How about if cgroup.InContainer() {logxxxx; return}?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 31, 2023
Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 31, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tiancaiamao, 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,tiancaiamao]

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

Copy link
Member

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

Thanks!

pkg/util/memory/meminfo.go Outdated Show resolved Hide resolved
pkg/util/memory/meminfo.go Show resolved Hide resolved
@hawkingrei
Copy link
Member Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 31, 2023
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@Rustin170506
Copy link
Member

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 31, 2023
@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 4667ed9 into pingcap:master Oct 31, 2023
13 of 16 checks passed
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 31, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 31, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 31, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 31, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 31, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 31, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this pull request Nov 1, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Nov 6, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Nov 6, 2023
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-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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 cannot read resource limitation from cgroup with the systemd
5 participants