[MDEV-25325] built-in documentation for performance_schema tables Created: 2021-04-01  Updated: 2021-10-26  Resolved: 2021-10-26

Status: Closed
Project: MariaDB Server
Component/s: Performance Schema
Fix Version/s: 10.2.41, 10.3.32, 10.4.22, 10.5.13, 10.6.5, 10.7.1

Type: Task Priority: Critical
Reporter: Sergei Golubchik Assignee: Vicențiu Ciorbaru
Resolution: Fixed Votes: 0
Labels: beginner-friendly


 Description   

Document all performance schema tables using per-column COMMENT, like in

--- a/storage/perfschema/table_file_instances.cc
+++ b/storage/perfschema/table_file_instances.cc
@@ -49,9 +49,9 @@ table_file_instances::m_share=
   sizeof(PFS_simple_index),
   &m_table_lock,
   { C_STRING_WITH_LEN("CREATE TABLE file_instances("
-                      "FILE_NAME VARCHAR(512) not null,"
-                      "EVENT_NAME VARCHAR(128) not null,"
-                      "OPEN_COUNT INTEGER unsigned not null)") },
+                      "FILE_NAME VARCHAR(512) not null comment 'File name',"
+                      "EVENT_NAME VARCHAR(128) not null comment 'Instrument name associated with the file',"
+                      "OPEN_COUNT INTEGER unsigned not null comment 'Open handles on the file. A value of greater than zero means that the file is currently open')") },
   false  /* perpetual */
 };
 

After that one can see the built-in documentation with

show create table performance_schema.file_instances

or, better, with

select column_name, column_comment from information_schema.columns where table_schema='performance_schema' and table_name='file_instances'

returning

+-------------+----------------------------------------------------------------------------------------------+
| column_name | column_comment                                                                               |
+-------------+----------------------------------------------------------------------------------------------+
| FILE_NAME   | File name                                                                                    |
| EVENT_NAME  | Instrument name associated with the file                                                     |
| OPEN_COUNT  | Open handles on the file. A value of greater than zero means that the file is currently open |
+-------------+----------------------------------------------------------------------------------------------+

The documentation text is taken from https://mariadb.com/kb/en/performance-schema-file_instances-table/



 Comments   
Comment by Haidong Ji [ 2021-05-01 ]

Hi Sergei,

I'd like to work on this, if that is ok. I've checked the page here on https://mariadb.com/kb/en/performance-schema-tables/ . I think I know what to do.

Haidong

Comment by Haidong Ji [ 2021-05-02 ]

I did some development work over the weekend:

1. The kb articles don't always have the complete columns defined in the cc files. I'll keep note of this.
2. When comment has single quote, the way to escape it is to double it. Backslash escaping doesn't work.
3. I've built the binary a few times after making changes in my local branch. I see the changes correctly reflected using the 2 method Sergei mentioned above.

I'm pretty sure I can finish this task. Any tips/suggestions welcome. Thanks!

Comment by Sergei Golubchik [ 2021-05-05 ]

haidong, yes, thanks. Please, list here all columns that you find not documented in the KB

Comment by Haidong Ji [ 2021-05-12 ]

I have finished editing the cc files for all performance schema tables listed. I've tested every one of them by building and then running `select column_name, column_comment from information_schema.columns where table_schema='performance_schema' and table_name='file_instances'`. They look good.

I've checked in the code to my forked branch here: https://github.com/haidong/server/tree/MDEV-25325 I plan to work on writing tests next. I've never done that before. So if you have suggestions/tips, that would be welcome. I may not be able to get to it until the weekend.

PS. I have noted the inconsistencies between the documentation and code files, and will report them also.

Comment by Haidong Ji [ 2021-05-16 ]

I have finished all coding tasks, including test cases, at least for the first go-round. I have also just submitted a PR: https://github.com/MariaDB/server/pull/1830

  • Documentation typo
  1. "memory_global_by_event_name" should have been "memory_summary_global_by_event_name" on https://mariadb.com/kb/en/performance-schema-memory_global_by_event_name-table/
  2. "LISTENw" should have been "LISTEN" on https://mariadb.com/kb/en/performance-schema-socket_summary_by_event_name-table/
  • The following tables don't have comments defined like others:
    events_statements_summary_by_program
    events_transactions_current
    events_transactions_history
    events_transactions_history_long
    events_transactions_summary_by_account_by_event_name
    events_transactions_summary_by_host_by_event_name
    events_transactions_summary_by_thread_by_event_name
    events_transactions_summary_by_user_by_event_name
    events_transactions_summary_global_by_event_name
    prepared_statements_instances
    replication_applier_configuration
    replication_applier_status
  • For "events_stages_current", "events_stages_history", and "events_stages_history_long", they all miss comment for "WORK_COMPLETED" and "WORK_ESTIMATED" columns;
  • For the same tables above, the ENUM of "NESTING_EVENT_TYPE" misses "TRANSACTION", I don't know if that's intentional or a mistake.
  • For "events_statements_current", "events_statements_history", and "events_statements_history_long", they all miss comment for the "NESTING_EVENT_LEVEL" column;
  • "setup_actors" misses comment for columns "ENABLED", "HISTORY"
  • "threads" misses comment for columns "HISTORY", "CONNECTION_TYPE", "THREAD_OS_ID"
Comment by Sergei Golubchik [ 2021-05-20 ]

great, thanks!

Generated at Thu Feb 08 09:36:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.