Bug #108673 Error log information was provided during mysql initialization
Submitted: 3 Oct 2022 17:20 Modified: 4 Oct 2022 1:47
Reporter: xichao li (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0,5.7 OS:Any
Assigned to: CPU Architecture:Any

[3 Oct 2022 17:20] xichao li
Description:
The mysql database instance fails to be initialized due to some reasons. Procedure Mysql ERROR logs always print ERROR level information:
"The newly created data directory /mysql/data by --initialize is unusable. You can remove it."

As a result, users think that it is due to the existence of files in the /mysql/data directory, and ignore the real cause of failure.

How to repeat:
This confirmation is a review of past case summary findings, please simulate a database instance initialization failure scenario, and then confirm the error log file.

Suggested fix:
We can see that the mysql code contains the following code snippet:

static void unireg_abort(int exit_code) {
  ...
  if (opt_initialize && exit_code && !opt_validate_config)
    LogErr(ERROR_LEVEL,
           mysql_initialize_directory_freshly_created
               ? ER_DATA_DIRECTORY_UNUSABLE_DELETABLE
               : ER_DATA_DIRECTORY_UNUSABLE,
           mysql_real_data_home);
  ...
}

ji
[3 Oct 2022 17:25] xichao li
That is, when the initial state is satisfied, when an exception occurs, unireg is triggered_ Abort (), the above exception logs will be printed directly. It is recommended to optimize this logic.
[3 Oct 2022 17:26] xichao li
That is, when the initial state is satisfied, when an exception occurs, unireg_abort(), the above exception logs will be printed directly. It is recommended to optimize this logic.
[4 Oct 2022 1:47] xichao li
The bug has been resubmitted to:
https://bugs.mysql.com/bug.php?id=108675
[4 Oct 2022 11:57] MySQL Verification Team
Hi Mr. li,

Please, do not submit the same report twice .....