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 wal may dump write diff type in same page_id #4850

Merged
merged 9 commits into from
May 11, 2022
Merged

Fix wal may dump write diff type in same page_id #4850

merged 9 commits into from
May 11, 2022

Conversation

jiaqizho
Copy link
Contributor

@jiaqizho jiaqizho commented May 9, 2022

What problem does this PR solve?

Issue Number: close #4849

Problem Summary:

  • WALStore may write two diff types in the same page_id. for example:
    • Do updates: E1, E2, X1, X2
    • shutdown and restore()
      • in this time, we still persist E1 and E2 into disk.
    • in restore(), we will call the gcInMemEntries() will clean up del id in MVCC
      • now MVCC will NOT have any entries in it, because gcInMemEntries() has cleaned them up.
    • DT call the getMaxId() will get 0.
    • Do updates: E1, Ref(2 -> 1)
    • shutdown and restore()(no dump happened, the disk data don't get compacted)
      • in this time, we will persist E1 and R2 into disk.
    • MVCC Try to restore. But found page_id 2 have two type(external and ref). it will be wrong.

What is changed and how it works?

  • we should call getMaxId() before MVCC GC. But we can't do that, Because MVCC will be ready after restore().

  • Changes

    • In V2, we will get max id from MVCC(in the end of restore()), it won't be a problem.
    • In V3, the basic idea is we record the max_ids of each namespace_ids before applying MVCC GC in memory.
    • Also after DT call the restore(), it never call the getMaxId(). So we removed getMaxId. Instead, we use restore() to return the max_ids.
  • Will disable rename in delta-merge-tests

    • rename in delta-merge-tests will make DeltaMergeStore shutdown and restore. But it won't make GlobalPathPool restore.
    • So after StrogaePool restore, max_id will be wrong.
    • It only affects tests, and won't affect online operations(different rename logical in DeltaMergeStore).
    • it will be fixed in the future

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 9, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JaySon-Huang
  • hehechen

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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 9, 2022
auto data_max_ids = data_storage->restore();
auto meta_max_ids = meta_storage->restore();

assert(log_max_ids.size() == 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use assert in normal logic besides test cases. Manually throw exceptions instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That make no sense if log_max_ids.size() != 1. And I don't think using exception replace assert is a good thing.
IMO:

  1. If it's logically clear and you do know it inited where. Then used assert to check .
  2. If some value changes a lot of time, Then the exception will replace the assert to avoid some problems.

So back to this assert, it's clear to know that log_max_ids from V2 must have size 1. So I think just adding an assert is ok to avoid logical error?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think assert is OK here

Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

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

LGTM with small comment

dbms/src/Storages/Page/V2/PageStorage.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/Page/PageStorage.h Outdated Show resolved Hide resolved
@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 May 10, 2022
@jiaqizho
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@jiaqizho: 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: 2300799

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

sre-bot commented May 10, 2022

Coverage for changed files

Filename                                 Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DeltaMerge/StoragePool.cpp                    77                24    68.83%          17                 6    64.71%         177                67    62.15%          40                18    55.00%
DeltaMerge/StoragePool.h                      29                10    65.52%          20                 7    65.00%          32                13    59.38%           6                 3    50.00%
Page/PageStorage.h                            28                 8    71.43%          28                 8    71.43%         107                22    79.44%           0                 0         -
Page/V2/PageStorage.cpp                      548               169    69.16%          37                 5    86.49%         936               218    76.71%         368               158    57.07%
Page/V2/PageStorage.h                         49                10    79.59%          20                 3    85.00%          48                 3    93.75%          22                10    54.55%
Page/V2/tests/gtest_page_storage.cpp        4918              1005    79.56%          34                 2    94.12%        1066                 5    99.53%        1514               721    52.38%
Page/V3/PageDirectoryFactory.cpp              42                 2    95.24%           4                 0   100.00%         125                 6    95.20%          48                 3    93.75%
Page/V3/PageDirectoryFactory.h                 3                 0   100.00%           3                 0   100.00%          11                 0   100.00%           0                 0         -
Page/V3/PageStorageImpl.cpp                  135                27    80.00%          22                 6    72.73%         292                58    80.14%          74                26    64.86%
Page/V3/PageStorageImpl.h                      8                 2    75.00%           8                 2    75.00%          22                 2    90.91%           0                 0         -
Page/V3/tests/gtest_page_storage.cpp        3503              1219    65.20%          44                 7    84.09%        1046               154    85.28%        1108               630    43.14%
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                       9340              2476    73.49%         237                46    80.59%        3862               548    85.81%        3180              1569    50.66%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18110      9880             45.44%    201593  98654        51.06%

full coverage report (for internal network access only)

@jiaqizho
Copy link
Contributor Author

/run-all-tests

@sre-bot
Copy link
Collaborator

sre-bot commented May 10, 2022

Coverage for changed files

Filename                                 Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DeltaMerge/StoragePool.cpp                    77                24    68.83%          17                 6    64.71%         177                67    62.15%          40                18    55.00%
DeltaMerge/StoragePool.h                      29                10    65.52%          20                 7    65.00%          32                13    59.38%           6                 3    50.00%
Page/PageStorage.h                            28                 8    71.43%          28                 8    71.43%         107                22    79.44%           0                 0         -
Page/V2/PageStorage.cpp                      548               169    69.16%          37                 5    86.49%         936               218    76.71%         368               158    57.07%
Page/V2/PageStorage.h                         49                10    79.59%          20                 3    85.00%          48                 3    93.75%          22                10    54.55%
Page/V2/tests/gtest_page_storage.cpp        4918              1005    79.56%          34                 2    94.12%        1066                 5    99.53%        1514               721    52.38%
Page/V3/PageDirectoryFactory.cpp              42                 2    95.24%           4                 0   100.00%         125                 6    95.20%          48                 3    93.75%
Page/V3/PageDirectoryFactory.h                 3                 0   100.00%           3                 0   100.00%          11                 0   100.00%           0                 0         -
Page/V3/PageStorageImpl.cpp                  135                27    80.00%          22                 6    72.73%         292                58    80.14%          74                26    64.86%
Page/V3/PageStorageImpl.h                      8                 2    75.00%           8                 2    75.00%          22                 2    90.91%           0                 0         -
Page/V3/tests/gtest_page_storage.cpp        3503              1219    65.20%          44                 7    84.09%        1046               154    85.28%        1108               630    43.14%
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                       9340              2476    73.49%         237                46    80.59%        3862               548    85.81%        3180              1569    50.66%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18110      9880             45.44%    201593  98638        51.07%

full coverage report (for internal network access only)

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

/run-all-tests

@JaySon-Huang
Copy link
Contributor

/run-integration-test

@sre-bot
Copy link
Collaborator

sre-bot commented May 11, 2022

Coverage for changed files

Filename                                 Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DeltaMerge/StoragePool.cpp                    77                24    68.83%          17                 6    64.71%         177                67    62.15%          40                18    55.00%
DeltaMerge/StoragePool.h                      29                10    65.52%          20                 7    65.00%          32                13    59.38%           6                 3    50.00%
Page/PageStorage.h                            28                 8    71.43%          28                 8    71.43%         107                22    79.44%           0                 0         -
Page/V2/PageStorage.cpp                      548               169    69.16%          37                 5    86.49%         936               218    76.71%         368               158    57.07%
Page/V2/PageStorage.h                         49                10    79.59%          20                 3    85.00%          48                 3    93.75%          22                10    54.55%
Page/V2/tests/gtest_page_storage.cpp        4918              1005    79.56%          34                 2    94.12%        1066                 5    99.53%        1514               721    52.38%
Page/V3/PageDirectoryFactory.cpp              42                 2    95.24%           4                 0   100.00%         125                 6    95.20%          48                 3    93.75%
Page/V3/PageDirectoryFactory.h                 3                 0   100.00%           3                 0   100.00%          11                 0   100.00%           0                 0         -
Page/V3/PageStorageImpl.cpp                  135                27    80.00%          22                 6    72.73%         292                58    80.14%          74                26    64.86%
Page/V3/PageStorageImpl.h                      8                 2    75.00%           8                 2    75.00%          22                 2    90.91%           0                 0         -
Page/V3/tests/gtest_page_storage.cpp        3503              1219    65.20%          44                 7    84.09%        1046               154    85.28%        1108               630    43.14%
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                       9340              2476    73.49%         237                46    80.59%        3862               548    85.81%        3180              1569    50.66%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18110      9880             45.44%    201593  98629        51.08%

full coverage report (for internal network access only)

@jiaqizho
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@jiaqizho: 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: b9c3e2e

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

@jiaqizho: 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.

@sre-bot
Copy link
Collaborator

sre-bot commented May 11, 2022

Coverage for changed files

Filename                                 Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DeltaMerge/StoragePool.cpp                    77                24    68.83%          17                 6    64.71%         177                67    62.15%          40                18    55.00%
DeltaMerge/StoragePool.h                      29                10    65.52%          20                 7    65.00%          32                13    59.38%           6                 3    50.00%
Page/PageStorage.h                            28                 8    71.43%          28                 8    71.43%         107                22    79.44%           0                 0         -
Page/V2/PageStorage.cpp                      548               169    69.16%          37                 5    86.49%         936               218    76.71%         368               158    57.07%
Page/V2/PageStorage.h                         49                10    79.59%          20                 3    85.00%          48                 3    93.75%          22                10    54.55%
Page/V2/tests/gtest_page_storage.cpp        4918              1005    79.56%          34                 2    94.12%        1066                 5    99.53%        1514               721    52.38%
Page/V3/PageDirectoryFactory.cpp              42                 2    95.24%           4                 0   100.00%         125                 6    95.20%          48                 3    93.75%
Page/V3/PageDirectoryFactory.h                 3                 0   100.00%           3                 0   100.00%          11                 0   100.00%           0                 0         -
Page/V3/PageStorageImpl.cpp                  135                27    80.00%          22                 6    72.73%         292                58    80.14%          74                26    64.86%
Page/V3/PageStorageImpl.h                      8                 2    75.00%           8                 2    75.00%          22                 2    90.91%           0                 0         -
Page/V3/tests/gtest_page_storage.cpp        3503              1219    65.20%          44                 7    84.09%        1046               154    85.28%        1108               630    43.14%
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                       9340              2476    73.49%         237                46    80.59%        3862               548    85.81%        3180              1569    50.66%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18118      9877             45.49%    201810  98608        51.14%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit ec4d058 into pingcap:master May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 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
Development

Successfully merging this pull request may close these issues.

Exception when PageStorage V3 restore
6 participants