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

Fix background_pool_size not take effect and BackgroundProcessingPool::getThreadIds may misses some thread_ids. #4686

Merged
merged 5 commits into from
Apr 18, 2022

Conversation

JinheLin
Copy link
Contributor

@JinheLin JinheLin commented Apr 16, 2022

What problem does this PR solve?

Issue Number: close #4684, close #4685

Problem Summary:

  1. Context::setDefaultProfiles should be called before Context::initializeRateLimiter. Because Context::initializeRateLimiter calls Context::getBackgroundPool and Context::getBlockableBackgroundPool inside to get background thread ids.
  2. BackgroundProcessingPool::getThreadIds and BackgroundProcessingPool::addThreadId are executing concurrently. BackgroundProcessingPool::getThreadIds may be called before all background threads executing ``BackgroundProcessingPool::addThreadId` completely.

What is changed and how it works?

  1. Adjust the initialization sequence of Context.
  2. Add absl::BlockingCounter to count all background threads executing BackgroundProcessingPool::addThreadId completely.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  1. Set configuration profiles.default.background_pool_size: 8.
  2. The expected log is found:
[2022/04/16 11:22:31.740 +08:00] [INFO] [BackgroundProcessingPool.cpp:90] ["BackgroundProcessingPool:Create BackgroundProcessingPool with 8 threads"] [thread_id=1]
[2022/04/16 11:22:31.763 +08:00] [INFO] [BackgroundProcessingPool.cpp:90] ["BackgroundProcessingPool:Create BackgroundProcessingPool with 8 threads"] [thread_id=1]
[2022/04/16 11:22:31.775 +08:00] [INFO] [RateLimiter.cpp:526] ["IORateLimiter:bg_thread_ids 16 => [9489, 9491, 9492, 9493, 9494, 9495, 9496, 9490, 9504, 9505, 9506, 9507, 9508, 9509, 9510, 9511]"] [thread_id=1]
  • 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

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Apr 16, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JaySon-Huang
  • Lloyd-Pottiger

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.0 Type: Need cherry pick to release-6.0 and removed do-not-merge/needs-triage-completed labels Apr 16, 2022
@JinheLin
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Apr 16, 2022

Coverage for changed files

Filename                                           Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dbms/src/Encryption/RateLimiter.cpp                    536               252    52.99%          46                13    71.74%         689               272    60.52%         292               139    52.40%
dbms/src/Storages/BackgroundProcessingPool.cpp          76                19    75.00%          10                 1    90.00%         175                31    82.29%          48                16    66.67%
dbms/src/Storages/BackgroundProcessingPool.h             2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
libs/libcommon/include/common/logger_useful.h           12                 0   100.00%           4                 0   100.00%          15                 3    80.00%           6                 0   100.00%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                  626               271    56.71%          62                14    77.42%         881               306    65.27%         346               155    55.20%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
17076      9516             44.27%    192377  96495        49.84%

full coverage report (for internal network access only)

Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger 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 ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 17, 2022
@JinheLin
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented Apr 18, 2022

Coverage for changed files

Filename                                           Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dbms/src/Encryption/RateLimiter.cpp                    536               252    52.99%          46                13    71.74%         689               272    60.52%         292               139    52.40%
dbms/src/Storages/BackgroundProcessingPool.cpp          88                31    64.77%          10                 1    90.00%         180                36    80.00%          54                22    59.26%
dbms/src/Storages/BackgroundProcessingPool.h             2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
libs/libcommon/include/common/logger_useful.h           12                 0   100.00%           4                 0   100.00%          15                 3    80.00%           6                 0   100.00%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                  638               283    55.64%          62                14    77.42%         886               311    64.90%         352               161    54.26%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
17076      9516             44.27%    192382  96485        49.85%

full coverage report (for internal network access only)

@JinheLin
Copy link
Contributor Author

/run-all-tests

@JinheLin
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 18, 2022
@sre-bot
Copy link
Collaborator

sre-bot commented Apr 18, 2022

Coverage for changed files

Filename                                           Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dbms/src/Encryption/RateLimiter.cpp                    536               252    52.99%          46                13    71.74%         689               272    60.52%         292               139    52.40%
dbms/src/Interpreters/Context.cpp                      492               323    34.35%         165                95    42.42%        1094               704    35.65%         254               192    24.41%
dbms/src/Interpreters/Context.h                         13                 8    38.46%          13                 8    38.46%          13                 8    38.46%           0                 0         -
dbms/src/Storages/BackgroundProcessingPool.cpp          88                31    64.77%          10                 1    90.00%         180                36    80.00%          54                22    59.26%
dbms/src/Storages/BackgroundProcessingPool.h             2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
libs/libcommon/include/common/logger_useful.h           12                 0   100.00%           4                 0   100.00%          15                 3    80.00%           6                 1    83.33%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                 1143               614    46.28%         240               117    51.25%        1993              1023    48.67%         606               354    41.58%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
17076      9516             44.27%    192382  96489        49.85%

full coverage report (for internal network access only)

@JinheLin
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@JinheLin: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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 ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 4a7a174

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 18, 2022
@sre-bot
Copy link
Collaborator

sre-bot commented Apr 18, 2022

Coverage for changed files

Filename                                           Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dbms/src/Encryption/RateLimiter.cpp                    536               252    52.99%          46                13    71.74%         689               272    60.52%         292               139    52.40%
dbms/src/Interpreters/Context.cpp                      492               323    34.35%         165                95    42.42%        1094               704    35.65%         254               192    24.41%
dbms/src/Interpreters/Context.h                         13                 8    38.46%          13                 8    38.46%          13                 8    38.46%           0                 0         -
dbms/src/Storages/BackgroundProcessingPool.cpp          88                31    64.77%          10                 1    90.00%         180                36    80.00%          54                22    59.26%
dbms/src/Storages/BackgroundProcessingPool.h             2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
libs/libcommon/include/common/logger_useful.h           12                 0   100.00%           4                 0   100.00%          15                 3    80.00%           6                 1    83.33%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                 1143               614    46.28%         240               117    51.25%        1993              1023    48.67%         606               354    41.58%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
17076      9516             44.27%    192382  96492        49.84%

full coverage report (for internal network access only)

@sre-bot
Copy link
Collaborator

sre-bot commented Apr 18, 2022

Coverage for changed files

Filename                                           Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dbms/src/Encryption/RateLimiter.cpp                    536               252    52.99%          46                13    71.74%         689               272    60.52%         292               139    52.40%
dbms/src/Interpreters/Context.cpp                      492               323    34.35%         165                95    42.42%        1094               704    35.65%         254               192    24.41%
dbms/src/Interpreters/Context.h                         13                 8    38.46%          13                 8    38.46%          13                 8    38.46%           0                 0         -
dbms/src/Storages/BackgroundProcessingPool.cpp          88                31    64.77%          10                 1    90.00%         180                36    80.00%          54                22    59.26%
dbms/src/Storages/BackgroundProcessingPool.h             2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
libs/libcommon/include/common/logger_useful.h           12                 1    91.67%           4                 0   100.00%          15                 3    80.00%           6                 2    66.67%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                 1143               615    46.19%         240               117    51.25%        1993              1023    48.67%         606               355    41.42%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
17131      9491             44.60%    192836  96252        50.09%

full coverage report (for internal network access only)

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #4696.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #4697.

@sre-bot
Copy link
Collaborator

sre-bot commented Apr 18, 2022

Coverage for changed files

Filename                                           Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
dbms/src/Encryption/RateLimiter.cpp                    536               252    52.99%          46                13    71.74%         689               272    60.52%         292               139    52.40%
dbms/src/Interpreters/Context.cpp                      492               323    34.35%         165                95    42.42%        1094               704    35.65%         254               192    24.41%
dbms/src/Interpreters/Context.h                         13                 8    38.46%          13                 8    38.46%          13                 8    38.46%           0                 0         -
dbms/src/Storages/BackgroundProcessingPool.cpp          88                31    64.77%          10                 1    90.00%         180                36    80.00%          54                22    59.26%
dbms/src/Storages/BackgroundProcessingPool.h             2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
libs/libcommon/include/common/logger_useful.h           12                 0   100.00%           4                 0   100.00%          15                 3    80.00%           6                 0   100.00%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                 1143               614    46.28%         240               117    51.25%        1993              1023    48.67%         606               353    41.75%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
17131      9491             44.60%    192836  96243        50.09%

full coverage report (for internal network access only)

ti-chi-bot added a commit that referenced this pull request Apr 27, 2022
…::getThreadIds may misses some thread_ids. (#4686) (#4696)

close #4684, ref #4685
@JinheLin JinheLin deleted the fix_bg_thread_pool branch August 4, 2022 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.0 Type: Need cherry pick to release-6.0 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. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
5 participants