May 12, 2025

Why Does MySQL Error MY-013129 Display Inconsistent Messages?

Resolve MySQL Error MY-013129's variable messages. Learn root causes, code logic in MySQL 8.0+, and suppression tactics via log_filter_dragnet. Optimize troubleshooting.

An Error with Dynamic Content

​Are you familiar with MySQL Error MY-013129?​

This error stands out due to its ​​variable messages​​, which can range from critical permission issues to non-critical warnings.

Example 1 (Critical Permission Error):

2025-03-03T15:38:08.918103+08:00 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-000001 - Can't create/write to file '/opt/mysql/data/3307/mysqld.pid' (OS errno 13 - Permission denied)

Example 2 (Non-Critical Warning):

2024-11-28T14:51:09.590102Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-004031 - The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.

Official Definition

The official MySQL documentation defines the error format but lacks context:

Error number: MY-013129; Symbol: ER_SERVER_NO_SESSION_TO_SEND_TO; SQLSTATE: HY000  
Message: A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-%06d - %s  

Code Logic Analysis

Trigger Scenarios (MySQL 8.0.28 Example)

​Code File​​: mysql-8.0.28\share\messages_to_error_log.txt

ER_SERVER_NO_SESSION_TO_SEND_TO  
  eng "A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-%06d - %s"

Output Logic (C++ Snippet)​​:

else if (!thd) {
    LogEvent()
        .type(LOG_TYPE_ERROR)
        .subsys(LOG_SUBSYSTEM_TAG)
        .prio(ERROR_LEVEL)
        .errcode((error < ER_SERVER_RANGE_START)
                     ? ER_SERVER_NO_SESSION_TO_SEND_TO
                     : error)
        .lookup(ER_SERVER_NO_SESSION_TO_SEND_TO, error, str);
}

Key Takeaways:

  1. ​Version-Specific​​: MY-013129 only appears in ​​MySQL 8.0+​​.
  2. ​Session Dependency​​: Errors occur when the server attempts to send client messages without an active session (!thd check).
  3. ​Log Severity​​: Despite some warnings, MySQL flags these as ERROR level to prevent oversight during critical failures.

Recommended Solutions

1. Keyword-Based Filtering

Modify log monitoring tools to suppress MY-013129 entries. Prioritize analyzing the ​​secondary error code​​ (e.g., MY-000001 or MY-004031) for appropriate action.

2. Configure log_filter_dragnet (MySQL 8.0+)

Suppress specific error levels without altering global settings:

-- Enable log_filter_dragnet  
INSTALL COMPONENT 'file://component_log_filter_dragnet';  
SET GLOBAL log_error_services = 'log_filter_dragnet; log_sink_internal';  

-- Drop MY-013129 errors  
SET GLOBAL dragnet.log_error_filter_rules = 'IF prio == ERROR and err_code == ER_SERVER_NO_SESSION_TO_SEND_TO THEN drop.';  

-- Reset configuration  
SET GLOBAL log_error_services = 'log_filter_internal; log_sink_internal';  
UNINSTALL COMPONENT 'file://component_log_filter_dragnet';  

You will get best features of ChatDBA