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) #6079

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #6038

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

Signed-off-by: Wish <breezewish@outlook.com>
@ti-chi-bot ti-chi-bot mentioned this pull request Oct 5, 2022
13 tasks
@ti-chi-bot ti-chi-bot added 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. type/cherry-pick-for-release-6.3 labels Oct 5, 2022
@ti-chi-bot
Copy link
Member Author

[REVIEW NOTIFICATION]

This pull request has not been approved.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Cherry pick PR approved by release team. 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. type/cherry-pick-for-release-6.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants