Bug #100601 Not all PFS keys are registered when initializing the mysql server
Submitted: 21 Aug 2020 12:32 Modified: 22 Aug 2020 3:15
Reporter: Cheng Zhou Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0.18 OS:Red Hat
Assigned to: CPU Architecture:Any

[21 Aug 2020 12:32] Cheng Zhou
Description:
Compiling a debug version without some particular types of Performance Schema instrumentation.
When initialized the mysql server, error occurred and the mysqld process exited.

error log:
[ERROR] [MY-012369] [InnoDB] You have created new InnoDB PFS key(s) but 2 key(s) is/are not registered with PFS. Please register the keys in PFS arrays in ha_innodb.cc.
[ERROR] [MY-010202] [Server] Plugin 'InnoDB' init function returned error.
[ERROR] [MY-010734] [Server] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] [MY-010168] [Server] Failed to initialize builtin plugins.
[ERROR] [MY-013236] [Server] The designated data directory /home/xxx/data/data/ is unusable. You can remove all files that the server added to it.
[ERROR] [MY-010119] [Server] Aborting

How to repeat:
1. Compiled with the CMake options including the following:
            -DDISABLE_PSI_COND=1 \
            -DDISABLE_PSI_DATA_LOCK=1 \
            -DDISABLE_PSI_ERROR=1 \
            -DDISABLE_PSI_FILE=1 \
            -DDISABLE_PSI_IDLE=1 \
            -DDISABLE_PSI_MEMORY=1 \
            -DDISABLE_PSI_METADATA=1 \
            -DDISABLE_PSI_MUTEX=1 \
            -DDISABLE_PSI_PS=1 \
            -DDISABLE_PSI_RWLOCK=1 \
            -DDISABLE_PSI_SOCKET=1 \
            -DDISABLE_PSI_SP=1 \
            -DDISABLE_PSI_STAGE=1 \
            -DDISABLE_PSI_STATEMENT=1 \
            -DDISABLE_PSI_STATEMENT_DIGEST=1 \
            -DDISABLE_PSI_TABLE=1 \
            -DDISABLE_PSI_THREAD=1 \
            -DDISABLE_PSI_TRANSACTION=1 \
            -DWITH_DEBUG=1 

2. make and make install;
3. initialize the mysql server:
~/bin/mysqld --defaults-file=/home/xxx/etc/my.cnf --initialize-insecure --user=xxx

Suggested fix:
mysql-8.0.18\storage\innobase\log\log0meb.cc:

--- a/storage/innobase/log/log0meb.cc
+++ b/storage/innobase/log/log0meb.cc
@@ -51,8 +51,14 @@ namespace meb {
 const std::string logmsgpfx("innodb_redo_log_archive: ");
 constexpr size_t QUEUE_BLOCK_SIZE = 4096;
 constexpr size_t QUEUE_SIZE_MAX = 16384;
+
+#ifdef UNIV_PFS_THREAD
 mysql_pfs_key_t redo_log_archive_consumer_thread_key;
+#endif
+
+#ifdef UNIV_PFS_IO
 mysql_pfs_key_t redo_log_archive_file_key;
+#endif
[21 Aug 2020 13:02] Cheng Zhou
After fixed the bug as the suggested fix, another error occurred as reported in http://bugs.mysql.com/100602
[21 Aug 2020 13:05] MySQL Verification Team
Hi Mr. Zhou,

Thank you for your bug report.

However, this is not a bug. Simply, some of the keys are necessary in order for InnoDB SE to function properly.

We shall try to find out which keys are those ......
[21 Aug 2020 13:17] MySQL Verification Team
Do try enabling PSI FILE and THREAD keys and see if it helps.
[21 Aug 2020 13:19] MySQL Verification Team
Also, try not disabling RWLOCK index in PFS.
[21 Aug 2020 13:19] MySQL Verification Team
Seems that MUTEX key is also required.
[22 Aug 2020 3:15] Cheng Zhou
Well, <MySQL 8.0 Reference Manual> '2.9.7 MySQL Source-Configuration Options ' mentioned:
"Note
It is not possible to compile without Performance Schema support. If it is desired to compile without particular types of instrumentation, that can be done with the following CMake options:
DISABLE_PSI_COND
...
DISABLE_PSI_TRANSACTION

For example, to compile without mutex instrumentation, configure MySQL using the -DDISABLE_PSI_MUTEX=1 option."

Aren't all of DISABLE_PSI_XXXs available?
I just tried to disable any unnecessary functions to improve the test performance as much as possible.
[24 Aug 2020 12:18] MySQL Verification Team
Hi Mr. Zhou,

We had an internal discussion and concluded that our documentation is clear enough.

Performance Schema indexes are predefined and cannot be dropped, added, or altered. 

https://dev.mysql.com/doc/refman/8.0/en/performance-schema-optimization.html

Hence, what you are attempting is not supported.