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

PageStorage: Fix the WAL snapshot dumped into file may contains invalid "being_ref_count" #4987

Merged
merged 19 commits into from
May 24, 2022

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented May 24, 2022

What problem does this PR solve?

Issue Number: close #4957, close #4986

Problem Summary:

  • issue 4975:
    • We can not prevent being_ref_count to be modify unless we stop the write threads while dumping snapshot of WAL log files
  • issue 4986:
    • The encryption info of WAL log files are not removed after snapshot dumped

What is changed and how it works?

  • Create a reader for WAL log files and load the edit into another temporary PageDirectory instance, and dump it as a snapshot edit to the snapshot log file
  • Remove the encryption info of WAL log files after snapshot dumped

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

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented May 24, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • jiaqizho
  • lidezhu

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. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. labels May 24, 2022
@JaySon-Huang JaySon-Huang requested a review from jiaqizho May 24, 2022 07:00
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 24, 2022
Comment on lines +225 to +226
const auto log_fullname = filename.fullname(LogFileStage::Normal);
provider->deleteRegularFile(log_fullname, EncryptionPath(log_fullname, ""));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix #4986

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 24, 2022
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@JaySon-Huang
Copy link
Contributor Author

Addressed, PTAL again @jiaqizho

Copy link
Contributor

@jiaqizho jiaqizho 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 May 24, 2022
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label May 24, 2022
@JaySon-Huang
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@JaySon-Huang: 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: 158403c

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 24, 2022
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label May 24, 2022
@JaySon-Huang
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@JaySon-Huang: 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: 6bc27c0

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

sre-bot commented May 24, 2022

Coverage for changed files

Filename                                            Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Encryption/FileProvider.cpp                              82                12    85.37%          11                 0   100.00%         144                34    76.39%          62                16    74.19%
Encryption/FileProvider.h                                 2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
Encryption/MockKeyManager.cpp                            64                 6    90.62%           7                 0   100.00%          81                 9    88.89%          36                11    69.44%
Encryption/MockKeyManager.h                               1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
Storages/DeltaMerge/StoragePool.cpp                     224               108    51.79%          31                 8    74.19%         491               220    55.19%         146                85    41.78%
Storages/Page/PageStorage.h                              19                 1    94.74%          19                 1    94.74%          85                 3    96.47%           0                 0         -
Storages/Page/V3/PageDirectory.cpp                      565                89    84.25%          32                 1    96.88%        1132               173    84.72%         430                98    77.21%
Storages/Page/V3/PageDirectory.h                         25                 3    88.00%          25                 3    88.00%         104                10    90.38%           0                 0         -
Storages/Page/V3/PageDirectoryFactory.cpp                50                 3    94.00%           6                 0   100.00%         127                 6    95.28%          50                 4    92.00%
Storages/Page/V3/PageDirectoryFactory.h                   2                 0   100.00%           2                 0   100.00%           8                 0   100.00%           0                 0         -
Storages/Page/V3/PageStorageImpl.cpp                    134                28    79.10%          24                 7    70.83%         293                62    78.84%          72                25    65.28%
Storages/Page/V3/PageStorageImpl.h                        8                 2    75.00%           8                 2    75.00%          22                 2    90.91%           0                 0         -
Storages/Page/V3/WALStore.cpp                            80                 7    91.25%          10                 0   100.00%         154                10    93.51%          34                 8    76.47%
Storages/Page/V3/WALStore.h                              13                 4    69.23%           4                 0   100.00%          17                 3    82.35%          10                 8    20.00%
Storages/Page/V3/tests/entries_helper.h                  68                36    47.06%          10                 3    70.00%         242               112    53.72%          34                22    35.29%
Storages/Page/V3/tests/gtest_page_directory.cpp       10021              1821    81.83%          58                 0   100.00%        1859                 7    99.62%        3166              1603    49.37%
Storages/Page/V3/tests/gtest_page_storage.cpp          3683              1278    65.30%          45                 7    84.44%        1093               154    85.91%        1158               657    43.26%
Storages/Page/V3/tests/gtest_wal_store.cpp             2437               293    87.98%          13                 0   100.00%         546                13    97.62%         814               396    51.35%
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                 17478              3691    78.88%         308                32    89.61%        6401               818    87.22%        6012              2933    51.21%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18253      9784             46.40%    204240  98005        52.01%

full coverage report (for internal network access only)

@sre-bot
Copy link
Collaborator

sre-bot commented May 24, 2022

Coverage for changed files

Filename                                            Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Encryption/FileProvider.cpp                              82                12    85.37%          11                 0   100.00%         144                34    76.39%          62                16    74.19%
Encryption/FileProvider.h                                 2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
Encryption/MockKeyManager.cpp                            64                 6    90.62%           7                 0   100.00%          81                 9    88.89%          36                11    69.44%
Encryption/MockKeyManager.h                               1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
Storages/DeltaMerge/StoragePool.cpp                     224               108    51.79%          31                 8    74.19%         491               220    55.19%         146                85    41.78%
Storages/Page/PageStorage.h                              19                 1    94.74%          19                 1    94.74%          85                 3    96.47%           0                 0         -
Storages/Page/V3/PageDirectory.cpp                      565                89    84.25%          32                 1    96.88%        1132               173    84.72%         430                98    77.21%
Storages/Page/V3/PageDirectory.h                         25                 3    88.00%          25                 3    88.00%         104                10    90.38%           0                 0         -
Storages/Page/V3/PageDirectoryFactory.cpp                50                 3    94.00%           6                 0   100.00%         127                 6    95.28%          50                 4    92.00%
Storages/Page/V3/PageDirectoryFactory.h                   2                 0   100.00%           2                 0   100.00%           8                 0   100.00%           0                 0         -
Storages/Page/V3/PageStorageImpl.cpp                    134                28    79.10%          24                 7    70.83%         293                62    78.84%          72                25    65.28%
Storages/Page/V3/PageStorageImpl.h                        8                 2    75.00%           8                 2    75.00%          22                 2    90.91%           0                 0         -
Storages/Page/V3/WALStore.cpp                            80                 7    91.25%          10                 0   100.00%         154                10    93.51%          34                 8    76.47%
Storages/Page/V3/WALStore.h                              13                 4    69.23%           4                 0   100.00%          17                 3    82.35%          10                 8    20.00%
Storages/Page/V3/tests/entries_helper.h                  68                36    47.06%          10                 3    70.00%         242               112    53.72%          34                22    35.29%
Storages/Page/V3/tests/gtest_page_directory.cpp       10021              1821    81.83%          58                 0   100.00%        1859                 7    99.62%        3166              1603    49.37%
Storages/Page/V3/tests/gtest_page_storage.cpp          3683              1278    65.30%          45                 7    84.44%        1093               154    85.91%        1158               657    43.26%
Storages/Page/V3/tests/gtest_wal_store.cpp             2437               293    87.98%          13                 0   100.00%         546                13    97.62%         814               396    51.35%
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                 17478              3691    78.88%         308                32    89.61%        6401               818    87.22%        6012              2933    51.21%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18253      9784             46.40%    204240  98008        52.01%

full coverage report (for internal network access only)

@@ -140,7 +140,7 @@ class PageStorage : private boost::noncopyable
SettingUInt64 blob_block_alignment_bytes = 0;

SettingUInt64 wal_roll_size = PAGE_META_ROLL_SIZE;
SettingUInt64 wal_recover_mode = 0;
SettingUInt64 wal_recover_mode = 0x00; // WALRecoveryMode::TolerateCorruptedTailRecords
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simply

Suggested change
SettingUInt64 wal_recover_mode = 0x00; // WALRecoveryMode::TolerateCorruptedTailRecords
SettingUInt64 wal_recover_mode = WALRecoveryMode::TolerateCorruptedTailRecords;

@ti-chi-bot
Copy link
Member

@JaySon-Huang: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

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.

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 ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label May 24, 2022
@JaySon-Huang
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@JaySon-Huang: 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: 377d31c

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

sre-bot commented May 24, 2022

Coverage for changed files

Filename                                            Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Encryption/FileProvider.cpp                              82                12    85.37%          11                 0   100.00%         144                34    76.39%          62                16    74.19%
Encryption/FileProvider.h                                 2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
Encryption/MockKeyManager.cpp                            64                 6    90.62%           7                 0   100.00%          81                 9    88.89%          36                11    69.44%
Encryption/MockKeyManager.h                               1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
Storages/DeltaMerge/StoragePool.cpp                     224               108    51.79%          31                 8    74.19%         491               220    55.19%         146                85    41.78%
Storages/Page/PageStorage.h                              19                 1    94.74%          19                 1    94.74%          85                 3    96.47%           0                 0         -
Storages/Page/V3/PageDirectory.cpp                      565                89    84.25%          32                 1    96.88%        1132               173    84.72%         430                98    77.21%
Storages/Page/V3/PageDirectory.h                         25                 3    88.00%          25                 3    88.00%         104                10    90.38%           0                 0         -
Storages/Page/V3/PageDirectoryFactory.cpp                50                 3    94.00%           6                 0   100.00%         127                 6    95.28%          50                 4    92.00%
Storages/Page/V3/PageDirectoryFactory.h                   2                 0   100.00%           2                 0   100.00%           8                 0   100.00%           0                 0         -
Storages/Page/V3/PageStorageImpl.cpp                    134                28    79.10%          24                 7    70.83%         293                62    78.84%          72                25    65.28%
Storages/Page/V3/PageStorageImpl.h                        8                 2    75.00%           8                 2    75.00%          22                 2    90.91%           0                 0         -
Storages/Page/V3/WALStore.cpp                            80                 7    91.25%          10                 0   100.00%         154                10    93.51%          34                 8    76.47%
Storages/Page/V3/WALStore.h                              13                 4    69.23%           4                 0   100.00%          17                 3    82.35%          10                 8    20.00%
Storages/Page/V3/tests/entries_helper.h                  68                36    47.06%          10                 3    70.00%         242               112    53.72%          34                22    35.29%
Storages/Page/V3/tests/gtest_page_directory.cpp       10021              1821    81.83%          58                 0   100.00%        1859                 7    99.62%        3166              1603    49.37%
Storages/Page/V3/tests/gtest_page_storage.cpp          3683              1278    65.30%          45                 7    84.44%        1093               154    85.91%        1158               657    43.26%
Storages/Page/V3/tests/gtest_wal_store.cpp             2437               293    87.98%          13                 0   100.00%         546                13    97.62%         814               396    51.35%
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                 17478              3691    78.88%         308                32    89.61%        6401               818    87.22%        6012              2933    51.21%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18253      9784             46.40%    204242  98007        52.01%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit 1412c25 into pingcap:master May 24, 2022
ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request May 24, 2022
@ti-chi-bot
Copy link
Member

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

@JaySon-Huang JaySon-Huang deleted the fix_concurrent_dump_snapshot branch May 24, 2022 12:11
ti-chi-bot added a commit that referenced this pull request May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. 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. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
6 participants