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

storage: add more store statistics #6038

Merged
merged 9 commits into from
Oct 5, 2022

Conversation

breezewish
Copy link
Member

@breezewish breezewish commented Sep 27, 2022

What problem does this PR solve?

Issue Number: ref #5975

Problem Summary: In #5975 we discovered a GC issue that is related with logical split. In order to make life easier when debugging such issues, we can enhance and provide more information in the system table.

What is changed and how it works?

  1. Moved DeltaMergeStore::getStat to be DeltaMergeStore::getStoreStats in DeltaMergeStore_Statistics.cpp. The items of statistics are not changed.

  2. Added some statistics items to DeltaMergeStore::getSegmentsStats.

Note: As we have removed some fields in this PR, during upgrading the TIFLASH_SEGMENTS table will be not queryable. This problem has been resolved in pingcap/tidb#38191 so that in future when we have other field removals no error will be thrown.

Check List

Tests

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

Manually tested with SELECT * FROM INFORMATION_SCHEMA.TIFLASH_SEGMENTS.

New TiFlash + New TiDB
*************************** 36. row ***************************
                     DATABASE: db_1
                        TABLE: t_8
                TIDB_DATABASE: mysql
                   TIDB_TABLE: db
                     TABLE_ID: 8
                 IS_TOMBSTONE: 0
                   SEGMENT_ID: 1
                        RANGE: [-9223372036854775808,9223372036854775807)
                        EPOCH: 0
                         ROWS: 0
                         SIZE: 0
                   DELTA_RATE: NULL
          DELTA_MEMTABLE_ROWS: 0
          DELTA_MEMTABLE_SIZE: 0
  DELTA_MEMTABLE_COLUMN_FILES: 0
 DELTA_MEMTABLE_DELETE_RANGES: 0
      DELTA_PERSISTED_PAGE_ID: 110
         DELTA_PERSISTED_ROWS: 0
         DELTA_PERSISTED_SIZE: 0
 DELTA_PERSISTED_COLUMN_FILES: 0
DELTA_PERSISTED_DELETE_RANGES: 0
             DELTA_CACHE_SIZE: 0
             DELTA_INDEX_SIZE: 2032
               STABLE_PAGE_ID: 111
                  STABLE_ROWS: 0
                  STABLE_SIZE: 0
               STABLE_DMFILES: 1
          STABLE_DMFILES_ID_0: 38
          STABLE_DMFILES_ROWS: 0
          STABLE_DMFILES_SIZE: 0
  STABLE_DMFILES_SIZE_ON_DISK: 0
         STABLE_DMFILES_PACKS: 0
             TIFLASH_INSTANCE: 127.0.0.1:3930
*************************** 37. row ***************************
                     DATABASE: db_2
                        TABLE: t_70
                TIDB_DATABASE: test
                   TIDB_TABLE: segment
                     TABLE_ID: 70
                 IS_TOMBSTONE: 0
                   SEGMENT_ID: 1
                        RANGE: [01,013030303033303530FF36616533372D3162FF30302D343935652DFF383061652D326264FF3164346632623235FF3100000000000000F8)
                        EPOCH: 5
                         ROWS: 4
                         SIZE: 6674
                   DELTA_RATE: 1
          DELTA_MEMTABLE_ROWS: 0
          DELTA_MEMTABLE_SIZE: 0
  DELTA_MEMTABLE_COLUMN_FILES: 0
 DELTA_MEMTABLE_DELETE_RANGES: 0
      DELTA_PERSISTED_PAGE_ID: 2
         DELTA_PERSISTED_ROWS: 4
         DELTA_PERSISTED_SIZE: 6674
 DELTA_PERSISTED_COLUMN_FILES: 2
DELTA_PERSISTED_DELETE_RANGES: 1
             DELTA_CACHE_SIZE: 0
             DELTA_INDEX_SIZE: 2032
               STABLE_PAGE_ID: 3
                  STABLE_ROWS: 0
                  STABLE_SIZE: 0
               STABLE_DMFILES: 1
          STABLE_DMFILES_ID_0: 5
          STABLE_DMFILES_ROWS: 0
          STABLE_DMFILES_SIZE: 0
  STABLE_DMFILES_SIZE_ON_DISK: 0
         STABLE_DMFILES_PACKS: 0
             TIFLASH_INSTANCE: 127.0.0.1:3930
*************************** 38. row ***************************
                     DATABASE: db_2
                        TABLE: t_70
                TIDB_DATABASE: test
                   TIDB_TABLE: segment
                     TABLE_ID: 70
                 IS_TOMBSTONE: 0
                   SEGMENT_ID: 11
                        RANGE: [013030303033303530FF36616533372D3162FF30302D343935652DFF383061652D326264FF3164346632623235FF3100000000000000F8,013039393938323137FF63643366382D3466FF62312D343330302DFF383665612D383433FF3362366463656231FF3100000000000000F9)
                        EPOCH: 2
                         ROWS: 5184
                         SIZE: 8633959
                   DELTA_RATE: 0
          DELTA_MEMTABLE_ROWS: 0
          DELTA_MEMTABLE_SIZE: 0
  DELTA_MEMTABLE_COLUMN_FILES: 0
 DELTA_MEMTABLE_DELETE_RANGES: 0
      DELTA_PERSISTED_PAGE_ID: 12
         DELTA_PERSISTED_ROWS: 0
         DELTA_PERSISTED_SIZE: 0
 DELTA_PERSISTED_COLUMN_FILES: 0
DELTA_PERSISTED_DELETE_RANGES: 0
             DELTA_CACHE_SIZE: 0
             DELTA_INDEX_SIZE: 2032
               STABLE_PAGE_ID: 10
                  STABLE_ROWS: 5184
                  STABLE_SIZE: 8633959
               STABLE_DMFILES: 1
          STABLE_DMFILES_ID_0: 6
          STABLE_DMFILES_ROWS: 5184
          STABLE_DMFILES_SIZE: 8633959
  STABLE_DMFILES_SIZE_ON_DISK: 2231901
         STABLE_DMFILES_PACKS: 1
             TIFLASH_INSTANCE: 127.0.0.1:3930
*************************** 39. row ***************************
                     DATABASE: db_2
                        TABLE: t_70
                TIDB_DATABASE: test
                   TIDB_TABLE: segment
                     TABLE_ID: 70
                 IS_TOMBSTONE: 0
                   SEGMENT_ID: 14
                        RANGE: [013039393938323137FF63643366382D3466FF62312D343330302DFF383665612D383433FF3362366463656231FF3100000000000000F9,013230303034323065FF32366561392D3033FF32342D343633302DFF396265642D626434FF3865363434353763FF3500000000000000F8)
                        EPOCH: 0
                         ROWS: 4
                         SIZE: 6674
                   DELTA_RATE: 1
          DELTA_MEMTABLE_ROWS: 0
          DELTA_MEMTABLE_SIZE: 0
  DELTA_MEMTABLE_COLUMN_FILES: 0
 DELTA_MEMTABLE_DELETE_RANGES: 0
      DELTA_PERSISTED_PAGE_ID: 15
         DELTA_PERSISTED_ROWS: 4
         DELTA_PERSISTED_SIZE: 6674
 DELTA_PERSISTED_COLUMN_FILES: 5
DELTA_PERSISTED_DELETE_RANGES: 4
             DELTA_CACHE_SIZE: 0
             DELTA_INDEX_SIZE: 2032
               STABLE_PAGE_ID: 13
                  STABLE_ROWS: 0
                  STABLE_SIZE: 0
               STABLE_DMFILES: 1
          STABLE_DMFILES_ID_0: 5
          STABLE_DMFILES_ROWS: 0
          STABLE_DMFILES_SIZE: 0
  STABLE_DMFILES_SIZE_ON_DISK: 0
         STABLE_DMFILES_PACKS: 0
             TIFLASH_INSTANCE: 127.0.0.1:3930
*************************** 40. row ***************************
                     DATABASE: db_2
                        TABLE: t_70
                TIDB_DATABASE: test
                   TIDB_TABLE: segment
                     TABLE_ID: 70
                 IS_TOMBSTONE: 0
                   SEGMENT_ID: 5
                        RANGE: [013230303034323065FF32366561392D3033FF32342D343633302DFF396265642D626434FF3865363434353763FF3500000000000000F8,013239393939303038FF30303764342D3733FF33632D346239352DFF623231362D383961FF6665323563306237FF3000000000000000F9)
                        EPOCH: 2
                         ROWS: 10315
                         SIZE: 17179742
                   DELTA_RATE: 0.49297140087251573
          DELTA_MEMTABLE_ROWS: 0
          DELTA_MEMTABLE_SIZE: 0
  DELTA_MEMTABLE_COLUMN_FILES: 0
 DELTA_MEMTABLE_DELETE_RANGES: 0
      DELTA_PERSISTED_PAGE_ID: 6
         DELTA_PERSISTED_ROWS: 5085
         DELTA_PERSISTED_SIZE: 8468595
 DELTA_PERSISTED_COLUMN_FILES: 2
DELTA_PERSISTED_DELETE_RANGES: 0
             DELTA_CACHE_SIZE: 0
             DELTA_INDEX_SIZE: 63992
               STABLE_PAGE_ID: 4
                  STABLE_ROWS: 5230
                  STABLE_SIZE: 8711147
               STABLE_DMFILES: 1
          STABLE_DMFILES_ID_0: 4
          STABLE_DMFILES_ROWS: 5230
          STABLE_DMFILES_SIZE: 8711147
  STABLE_DMFILES_SIZE_ON_DISK: 2251784
         STABLE_DMFILES_PACKS: 1
             TIFLASH_INSTANCE: 127.0.0.1:3930
*************************** 41. row ***************************
                     DATABASE: db_2
                        TABLE: t_70
                TIDB_DATABASE: test
                   TIDB_TABLE: segment
                     TABLE_ID: 70
                 IS_TOMBSTONE: 0
                   SEGMENT_ID: 8
                        RANGE: [013239393939303038FF30303764342D3733FF33632D346239352DFF623231362D383961FF6665323563306237FF3000000000000000F9,FA)
                        EPOCH: 0
                         ROWS: 2
                         SIZE: 3344
                   DELTA_RATE: 1
          DELTA_MEMTABLE_ROWS: 0
          DELTA_MEMTABLE_SIZE: 0
  DELTA_MEMTABLE_COLUMN_FILES: 0
 DELTA_MEMTABLE_DELETE_RANGES: 0
      DELTA_PERSISTED_PAGE_ID: 9
         DELTA_PERSISTED_ROWS: 2
         DELTA_PERSISTED_SIZE: 3344
 DELTA_PERSISTED_COLUMN_FILES: 3
DELTA_PERSISTED_DELETE_RANGES: 2
             DELTA_CACHE_SIZE: 0
             DELTA_INDEX_SIZE: 2032
               STABLE_PAGE_ID: 7
                  STABLE_ROWS: 0
                  STABLE_SIZE: 0
               STABLE_DMFILES: 1
          STABLE_DMFILES_ID_0: 5
          STABLE_DMFILES_ROWS: 0
          STABLE_DMFILES_SIZE: 0
  STABLE_DMFILES_SIZE_ON_DISK: 0
         STABLE_DMFILES_PACKS: 0
             TIFLASH_INSTANCE: 127.0.0.1:3930
Old TiFlash + New TiDB
*************************** 36. row ***************************
                     DATABASE: db_1
                        TABLE: t_8
                TIDB_DATABASE: mysql
                   TIDB_TABLE: db
                     TABLE_ID: 8
                 IS_TOMBSTONE: 0
                   SEGMENT_ID: 1
                        RANGE: [-9223372036854775808,9223372036854775807)
                        EPOCH: NULL
                         ROWS: 0
                         SIZE: 0
                   DELTA_RATE: NULL
          DELTA_MEMTABLE_ROWS: NULL
          DELTA_MEMTABLE_SIZE: NULL
  DELTA_MEMTABLE_COLUMN_FILES: NULL
 DELTA_MEMTABLE_DELETE_RANGES: NULL
      DELTA_PERSISTED_PAGE_ID: NULL
         DELTA_PERSISTED_ROWS: NULL
         DELTA_PERSISTED_SIZE: NULL
 DELTA_PERSISTED_COLUMN_FILES: NULL
DELTA_PERSISTED_DELETE_RANGES: NULL
             DELTA_CACHE_SIZE: 0
             DELTA_INDEX_SIZE: 2032
               STABLE_PAGE_ID: NULL
                  STABLE_ROWS: NULL
                  STABLE_SIZE: NULL
               STABLE_DMFILES: NULL
          STABLE_DMFILES_ID_0: NULL
          STABLE_DMFILES_ROWS: NULL
          STABLE_DMFILES_SIZE: NULL
  STABLE_DMFILES_SIZE_ON_DISK: NULL
         STABLE_DMFILES_PACKS: NULL
             TIFLASH_INSTANCE: 127.0.0.1:3930
*************************** 37. row ***************************
                     DATABASE: db_2
                        TABLE: t_70
                TIDB_DATABASE: test
                   TIDB_TABLE: segment
                     TABLE_ID: 70
                 IS_TOMBSTONE: 0
                   SEGMENT_ID: 1
                        RANGE: [01,FA)
                        EPOCH: NULL
                         ROWS: 102000
                         SIZE: 169872351
                   DELTA_RATE: 0.19880392156862745
          DELTA_MEMTABLE_ROWS: NULL
          DELTA_MEMTABLE_SIZE: NULL
  DELTA_MEMTABLE_COLUMN_FILES: NULL
 DELTA_MEMTABLE_DELETE_RANGES: NULL
      DELTA_PERSISTED_PAGE_ID: NULL
         DELTA_PERSISTED_ROWS: NULL
         DELTA_PERSISTED_SIZE: NULL
 DELTA_PERSISTED_COLUMN_FILES: NULL
DELTA_PERSISTED_DELETE_RANGES: NULL
             DELTA_CACHE_SIZE: 0
             DELTA_INDEX_SIZE: 423560
               STABLE_PAGE_ID: NULL
                  STABLE_ROWS: NULL
                  STABLE_SIZE: NULL
               STABLE_DMFILES: NULL
          STABLE_DMFILES_ID_0: NULL
          STABLE_DMFILES_ROWS: NULL
          STABLE_DMFILES_SIZE: NULL
  STABLE_DMFILES_SIZE_ON_DISK: NULL
         STABLE_DMFILES_PACKS: NULL
             TIFLASH_INSTANCE: 127.0.0.1:3930
37 rows in set (0.01 sec)
Old TiDB + New TiFlash (This happens during upgrading)
mysql> select * from INFORMATION_SCHEMA.TIFLASH_SEGMENTS;
ERROR 1105 (HY000): Record from tiflash doesn't match schema [Code: 47, e.displayText() = DB::Exception: Unknown identifier: stable_size_on_disk, e.what() = DB::Exception]
  • 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 Sep 27, 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. needs-cherry-pick-release-6.3 labels Sep 27, 2022
@ti-chi-bot ti-chi-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 27, 2022
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 29, 2022
@breezewish breezewish requested a review from lidezhu October 1, 2022 01:05
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.

Others LGTM

namespace DM
{

static inline DB::PS::V2::PageEntriesVersionSetWithDelta::Snapshot *
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use auto as return type here?

}
else
{
LOG_FMT_ERROR(log, "Can't get any version from current snapshot, type=data");
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use LOG_XXX instead of LOG_FMT_XXX, we will remove all LOG_FMT_XXX later.

Comment on lines 144 to 145
const auto * concrete_snap = toConcreteSnapshot(log_snapshot);
if (concrete_snap)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe combine the two lines.

if (const auto * concrete_snap = toConcreteSnapshot(log_snapshot); concrete_snap)

@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 Oct 5, 2022
Signed-off-by: Wish <[email protected]>
@breezewish
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

@breezewish: 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: b8f3bad

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

@breezewish: 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 Oct 5, 2022

Coverage for changed files

Filename                                              Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DeltaMerge/DeltaMergeStore.cpp                            830               107    87.11%          44                 2    95.45%        1153               182    84.22%         436               131    69.95%
DeltaMerge/DeltaMergeStore.h                               17                 2    88.24%          16                 2    87.50%          46                 7    84.78%           0                 0         -
DeltaMerge/DeltaMergeStore_Statistics.cpp                  59                44    25.42%           3                 0   100.00%         172                46    73.26%          30                19    36.67%
DeltaMerge/Segment.h                                       42                 3    92.86%          27                 2    92.59%          38                 3    92.11%           4                 2    50.00%
DeltaMerge/tests/gtest_dm_delta_merge_store.cpp           904               335    62.94%          68                 1    98.53%        2822                69    97.55%         264               183    30.68%
DeltaMerge/tests/gtest_dm_storage_delta_merge.cpp         198                43    78.28%          18                 0   100.00%         684                12    98.25%          56                28    50.00%
StorageDeltaMerge.cpp                                     713               269    62.27%          59                20    66.10%        1297               537    58.60%         364               196    46.15%
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                    2763               803    70.94%         235                27    88.51%        6212               856    86.22%        1154               559    51.56%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18384      7481             59.31%    215288  77055        64.21%

full coverage report (for internal network access only)

@sre-bot
Copy link
Collaborator

sre-bot commented Oct 5, 2022

Coverage for changed files

Filename                                              Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DeltaMerge/DeltaMergeStore.cpp                            830               107    87.11%          44                 2    95.45%        1158               182    84.28%         436               131    69.95%
DeltaMerge/DeltaMergeStore.h                               17                 2    88.24%          16                 2    87.50%          46                 7    84.78%           0                 0         -
DeltaMerge/DeltaMergeStore_Statistics.cpp                  59                44    25.42%           3                 0   100.00%         172                46    73.26%          30                19    36.67%
DeltaMerge/Segment.h                                       42                 3    92.86%          27                 2    92.59%          38                 3    92.11%           4                 2    50.00%
DeltaMerge/tests/gtest_dm_delta_merge_store.cpp           904               335    62.94%          68                 1    98.53%        2822                69    97.55%         264               183    30.68%
DeltaMerge/tests/gtest_dm_storage_delta_merge.cpp         198                43    78.28%          18                 0   100.00%         684                12    98.25%          56                28    50.00%
StorageDeltaMerge.cpp                                     713               269    62.27%          59                20    66.10%        1297               537    58.60%         364               196    46.15%
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                    2763               803    70.94%         235                27    88.51%        6217               856    86.23%        1154               559    51.56%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18386      7481             59.31%    215364  77101        64.20%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit 5e6f620 into pingcap:master Oct 5, 2022
@ti-chi-bot
Copy link
Member

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

@breezewish breezewish deleted the wenxuan/segment_info branch October 15, 2022 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.3 release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ 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.

5 participants