WL#11678: Logging services: Add unique error-ids to the messages logged using error_log_printf()

Affects: Server-8.0   —   Status: Complete

Following methods uses error_log_printf() internally to log the error  
message,                                                              
                                                                      
  *) my_message_local                                                 
  *) my_getopt_error_reporter                                         
  *) my_charset_error_reporter                                        
  *) Query_log_table_intact::report_error                             
  *) Component_db_intact::report_error                                
  *) sql_plugin.cc: report_error()                                        
                                                                      
All the error messages logged with these methods gets the same error-id
"ER_LOG_PRINTF_MSG".                                                  
                                                                      
Goal of this WL is to log all those error messages with the unique    
error-id.
All the error messages logged from the methods listed below must have unique  
error-id. 

  *) my_message_local                                                 
  *) my_getopt_error_reporter                                         
  *) my_charset_error_reporter                                        
  *) Query_log_table_intact::report_error                             
  *) Component_db_intact::report_error                                
  *) sql_plugin.cc: report_error()  
Method error_log_printf() logs error message with the error-id
"ER_LOG_PRINTF_MSG" and the error message string passed to it.

Following method uses error_log_printf() to log the error message,

*) my_message_local:
--------------------
    error_log_printf() hook is used by the my_message_local() method
    in the MySQL server code. This method is called to log around 35
    error messages. In the current code, all these error messages are
    logged with the ER_LOG_PRINTF_MSG error id.

    By default, hook to log error messages to the stderr is used. 
    Default hook is used by the clients in the current code.

    my_message_local() is used by the mysys code. mysys static library
    is used with the both MySQL server and clients. Which also means
    that the error-ids for the error messages logged using the
    my_message_local() must be available to both. So to log error
    messages with unique error-id, error messages are added to the
    global list of errors "const char *globerrs"(mysys/errors.cc) and
    error message numbers are added for them (include/mysys_err.h).

    my_message_local, error_log_printf and hook used to log error
    message to stderr are modified to accept the global error number.
    Error format string is populated from the global error number. In
    the server, LogEvent methods used to log error message with global
    error number and error format string populated from the error
    number.

    Please note that error-ids for the messages added to the global
    error list starts from the 35. This deviates from the policy
    of error-id numbering (i.e error-ids >= 10000) for error messages
    but error-id of this range is accepted as exceptional case for the
    error messages logged with the my_message_local().


*) my_getopt_error_reporter: 
----------------------------
    error_log_printf() hook is used by the my_getopt_error_reporter
    method in the MySQL server code. This method is called to log
    around 15 error messages. In the current code, all these error
    messages are logged with the ER_LOG_PRINTF_MSG error id.

    By default, my_message_local() hook is used to log the message.
    Default hook is used by the clients in the current code.

    my_getopt_error_reporter() is used by the mysys code. mysys static
    library is used with the both MySQL server and clients. Which also
    means that the error-ids for the error messages logged using
    my_getopt_error_reporter() must be available to both. So to log
    error messages with unique error-id, error messages are added to
    the global list of errors "const char *globerrs"(mysys/errors.cc)
    and error message numbers are added for them (include/mysys_err.h).

    my_getopt_error_reporter, error_log_printf and default hook
    are modified to accept the global error number. Error format string
    is populated from the global error number. In the server, LogEvent
    methods used to log error message with global error number and
    error format string populated from the error number.

    Please note that error-ids for the messages added to the global
    error list starts from the 35. This deviates from the policy of
    error-id numbering (i.e error-ids >= 10000) for error messages
    but error-id of this range is accepted as exceptional case for the
    error messages logged with the my_getopt_error_reporter().


*) my_charset_error_reporter:
-----------------------------
    error_log_printf() hook is used by the my_charset_error_reporter
    method in the MySQL server code. This method is called to log around
    6 error messages. In the current code, these error messages are
    logged with the ER_LOG_PRINTF_MSG error id.

    By default, no error or warning is reported, NoOp(empty method)
    hook is used. Default hook is used by the clients in the current
    code.

    my_charset_error_reporter() is used by the mysys code. mysys static
    library is used with the both MySQL server and clients. Which also
    means that, the error-ids for the error messages logged using
    my_charset_error_reporter() must be available to both. So to log
    error messages with unique error-id, error messages are added to
    the global list of errors "const char *globerrs"(mysys/errors.cc)
    and error message numbers are added for them (include/mysys_err.h).

    my_charset_error_reporter, error_log_printf and default hook
    are modified to accept the global error number. Error format string
    is populated from the global error number. In the server, LogEvent
    methods used to log error message with global error number and
    error format string populated from the error number.

    Please note that error-ids for the messages added to the global
    error list starts from the 35. This deviates from the policy of
    error-id numbering (i.e error-ids >= 10000) for error messages but
    error-id of this range is accepted as exceptional case for the
    error messages logged with the my_charset_error_reporter().


*) Query_log_table_intact::report_error
*) Component_db_intact::report_error
-----------------------------------------
    error_log_printf() method is called by these to log an error
    reported from the Table_check_intact::check(). In the current code,
    error messages are logged with ER_LOG_PRINTF_MSG error id.

    We already have Acl_table_intact::report_error() code which maps
    the reported errors to error-ids and logs the error message.
    Similar mapping and error logging will be used to log the error message
    from these methods.


*) sql_plugin.cc: report_error()
-------------------------------
    error_log_printf() method is called by report_error() to log an error
    message. This method is called to log around 6 error messages
    in the sql_plugin.cc file. In the current code, these error messages
    are logged with ER_LOG_PRINTF_MSG error id.

    These error messages will be logged with unique error-ids by using
    LogEvent class methods.


Other changes: sql_print_*() 
===============================
    WL also replaces sql_print_*() calls in the storage/innobase/ut/ut0dbg.cc:
    ut_dbg_assertion_failed() and in other places(introduced after the
    tasks to replace sql_print_* methods).


Note: With the WL changes, permissible range for error-ids logged to the 
      error-log is:

          (error_id >= ER_SERVER_RANGE_START ||
           (error_id >= EE_ERROR_FIRST && error_id <= EE_ERROR_LAST))
    
       ER_SERVER_RANGE_START = 10000
       EE_ERROR_FIRST = 1
       EE_ERROR_LAST  = 90
Following methods uses error_log_printf() internally to log the error  
message,                                                              
                                                                      
  *) my_message_local                                                 
  *) my_getopt_error_reporter                                         
  *) my_charset_error_reporter                                        
  *) Query_log_table_intact::report_error                             
  *) Component_db_intact::report_error                                
  *) sql_plugin.cc: report_error()                                        
                                                                      
All the error messages logged with these methods gets the same error-id
"ER_LOG_PRINTF_MSG".

These methods and their hooks will be modified as discussed in the HLS.
Following error-ids will be added to the global error message list:

00035 EE_DISK_FULL_WITH_RETRY_MSG 
     "Disk is full writing '%s' (OS errno %d - %s). Waiting for someone to free 
"
     "space... Retry in %d secs. Message reprinted in %d secs.",

00036 EE_FAILED_TO_CREATE_TIMER 
     "Failed to create timer (OS errno %d).",

00037 EE_FAILED_TO_DELETE_TIMER 
     "Failed to delete timer (OS errno %d).",

00038 EE_FAILED_TO_CREATE_TIMER_QUEUE 
     "Failed to create timer queue (OS errno %d).",

00039 EE_FAILED_TO_START_TIMER_NOTIFY_THREAD 
     "Failed to start timer notify thread.",

00040 EE_FAILED_TO_CREATE_TIMER_NOTIFY_THREAD_INTERRUPT_EVENT 
     "Failed to create event to interrupt timer notifier thread (OS errno %d).",

00041 EE_EXITING_TIMER_NOTIFY_THREAD 
     "Failed to register timer event with queue (OS errno %d), exiting timer "
     "notifier thread.",

00042 EE_WIN_LIBRARY_LOAD_FAILED 
     "LoadLibrary(\"kernel32.dll\") failed: GetLastError returns %lu.",

00043 EE_WIN_RUN_TIME_ERROR_CHECK 
     "%s.",

00044 EE_FAILED_TO_DETERMINE_LARGE_PAGE_SIZE 
     "Failed to determine large page size.",

00045 EE_FAILED_TO_KILL_ALL_THREADS 
     "Error in my_thread_global_end(): %d thread(s) did not exit.",

00046 EE_FAILED_TO_CREATE_IO_COMPLETION_PORT 
     "Failed to create IO completion port (OS errno %d).",

00047 EE_FAILED_TO_OPEN_DEFAULTS_FILE 
     "Failed to open required defaults file: %s",

00048 EE_FAILED_TO_HANDLE_DEFAULTS_FILE 
     "Fatal error in defaults handling. Program aborted!",

00049 EE_WRONG_DIRECTIVE_IN_CONFIG_FILE 
     "Wrong '!%s' directive in config file %s at line %d.",

00050 EE_SKIPPING_DIRECTIVE_DUE_TO_MAX_INCLUDE_RECURSION 
     "Skipping '%s' directive as maximum include recursion level was"
     " reached in file %s at line %d.",

00051 EE_INCORRECT_GRP_DEFINITION_IN_CONFIG_FILE 
     "Wrong group definition in config file %s at line %d.",

00052 EE_OPTION_WITHOUT_GRP_IN_CONFIG_FILE 
     "Found option without preceding group in config file %s at line %d.",

00053 EE_CONFIG_FILE_PERMISSION_ERROR 
     "%s should be readable/writable only by current user.",

00054 EE_IGNORE_WORLD_WRITABLE_CONFIG_FILE 
     "World-writable config file '%s' is ignored.",

00055 EE_USING_DISABLED_OPTION 
     "%s: Option '%s' was used, but is disabled.",

00056 EE_USING_DISABLED_SHORT_OPTION 
     "%s: Option '-%c' was used, but is disabled.",

00057 EE_USING_PASSWORD_ON_CLI_IS_INSECURE 
     "Using a password on the command line interface can be insecure.",

00058 EE_UNKNOWN_SUFFIX_FOR_VARIABLE 
     "Unknown suffix '%c' used for variable '%s' (value '%s').",

00059 EE_SSL_ERROR_FROM_FILE 
     "SSL error: %s from '%s'.",

00060 EE_SSL_ERROR 
     "SSL error: %s.",

00061 EE_NET_SEND_ERROR_IN_BOOTSTRAP 
     "%d  %s.",

00062 EE_PACKETS_OUT_OF_ORDER 
     "Packets out of order (found %u, expected %u).",

00063 EE_UNKNOWN_PROTOCOL_OPTION 
     "Unknown option to protocol: %s.",

00064 EE_FAILED_TO_LOCATE_SERVER_PUBLIC_KEY 
     "Failed to locate server public key '%s'.",

00065 EE_PUBLIC_KEY_NOT_IN_PEM_FORMAT 
     "Public key is not in Privacy Enhanced Mail format: '%s'.",

00066 EE_DEBUG_INFO 
     "%s.",

00067 EE_UNKNOWN_VARIABLE 
     "unknown variable '%s'.",

00068 EE_UNKNOWN_OPTION 
     "unknown option '--%s'.",

00069 EE_UNKNOWN_SHORT_OPTION 
     "%s: unknown option '-%c'.",

00070 EE_OPTION_WITHOUT_ARGUMENT 
     "%s: option '--%s' cannot take an argument.",

00071 EE_OPTION_REQUIRES_ARGUMENT 
     "%s: option '--%s' requires an argument.",

00072 EE_SHORT_OPTION_REQUIRES_ARGUMENT 
     "%s: option '-%c' requires an argument.",

00073 EE_OPTION_IGNORED_DUE_TO_INVALID_VALUE 
     "%s: ignoring option '--%s' due to invalid value '%s'.",

00074 EE_OPTION_WITH_EMPTY_VALUE 
     "%s: Empty value for '%s' specified.",

00075 EE_FAILED_TO_ASSIGN_MAX_VALUE_TO_OPTION 
     "%s: Maximum value of '%s' cannot be set.",

00076 EE_INCORRECT_BOOLEAN_VALUE_FOR_OPTION 
     "option '%s': boolean value '%s' was not recognized. Set to OFF.",

00077 EE_FAILED_TO_SET_OPTION_VALUE 
     "%s: Error while setting value '%s' to '%s'.",

00078 EE_INCORRECT_INT_VALUE_FOR_OPTION 
     "Incorrect integer value: '%s'.",

00079 EE_INCORRECT_UINT_VALUE_FOR_OPTION 
     "Incorrect unsigned integer value: '%s'.",

00080 EE_ADJUSTED_SIGNED_VALUE_FOR_OPTION 
     "option '%s': signed value %s adjusted to %s.",

00081 EE_ADJUSTED_UNSIGNED_VALUE_FOR_OPTION 
     "option '%s': unsigned value %s adjusted to %s.",

00082 EE_ADJUSTED_ULONGLONG_VALUE_FOR_OPTION 
     "option '%s': value %s adjusted to %s.",

00083 EE_ADJUSTED_DOUBLE_VALUE_FOR_OPTION 
     "option '%s': value %g adjusted to %g.",

00084 EE_INVALID_DECIMAL_VALUE_FOR_OPTION 
     "Invalid decimal value for option '%s'.",

00085 EE_COLLATION_PARSER_ERROR 
     "%s.",

00086 EE_FAILED_TO_RESET_BEFORE_PRIMARY_IGNORABLE_CHAR 
     "Failed to reset before a primary ignorable character %s.",

00087 EE_FAILED_TO_RESET_BEFORE_TERTIARY_IGNORABLE_CHAR 
     "Failed to reset before a territory ignorable character %s.",

00088 EE_SHIFT_CHAR_OUT_OF_RANGE 
     "Shift character out of range: %s.",

00089 EE_RESET_CHAR_OUT_OF_RANGE 
     "Reset character out of range: %s.",

00090 EE_UNKNOWN_LDML_TAG 
     "Unknown LDML tag: '%.*s'."

Following error codes will be added to the errmsg-utf8.txt:

13177 ER_NO_PATH_FOR_SHARED_LIBRARY
     "No paths allowed for shared library."

13178 ER_UDF_ALREADY_EXISTS
     "Function '%-.192s' already exists."

13179 ER_SET_EVENT_FAILED
     "Got Error: %ld from SetEvent."

13180 ER_FAILED_TO_ALLOCATE_SSL_BIO
     "Error allocating SSL BIO."

13181 ER_IB_MSG_1273
     "%s"

13182 ER_PID_FILEPATH_LOCATIONS_INACCESSIBLE
     "One or several locations were inaccessible while checking PID filepath."

13183 ER_UNKNOWN_VARIABLE_IN_PERSISTED_CONFIG_FILE
     "Currently unknown variable '%s' was read from the persisted config file."

13184 ER_FAILED_TO_HANDLE_DEFAULTS_FILE
     "Fatal error in defaults handling. Program aborted!"

13185 ER_DUPLICATE_SYS_VAR
     "Duplicate variable name '%s'."

13186 ER_FAILED_TO_INIT_SYS_VAR
     "Failed to initialize system variables."

13187 ER_SYS_VAR_NOT_FOUND
     "Variable name '%s' not found."