Bug #37132 Logging to slow_log table fails with very slow queries
Submitted: 2 Jun 2008 3:48 Modified: 19 Jun 2019 1:23
Reporter: Omer Barnir (OCA) Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.1.25 OS:Any
Assigned to: Assigned Account CPU Architecture:Any

[2 Jun 2008 3:48] Omer Barnir
While running the 'large_test' observed that the two slowest queries were not logged to the slow log table and the following errors were recorded in the master.err file:
  080601  5:45:55 [ERROR] Failed to write to mysql.slow_log:
  080601  6:19:32 [ERROR] Failed to write to mysql.slow_log:
The queries were logged correctly to the slow log file:
# Time: 080601  5:45:55
# User@Host: root[root] @ localhost []
# Query_time: 901.996373  Lock_time: 0.000085 Rows_sent: 0  
  Rows_examined: 2147483648
SET timestamp=1212288355;
insert into t1 select * from t1;
# Time: 080601  6:19:32
# User@Host: root[root] @ localhost []
# Query_time: 2017.081880  Lock_time: 0.000102 Rows_sent: 0  
  Rows_examined: 4294967294
SET timestamp=1212290372;
insert into t1 select * from t1 limit 2147483647;

How to repeat:
mysql-test-run.pl --suite=large_tests --big-test --suite-timeout=6360 --testcase-timeout=795
Note: the test runs for around 5 hours and requires around 60GB of disk before the problems shows

Suggested fix:
Log the entries in the slow-log table
[1 Oct 2008 17:16] Konstantin Osipov
You may fail to write into the log table due to many reasons: out of memory, out of disk space, etc.
We should change the code to print the error message into the error log, then re-run the test.
Medium effort since the test case is so big.
[22 Mar 2019 16:22] Yael Goldberg
We see the same issue in MySQL 5.6.  Will this bug get fixed?
[19 Jun 2019 1:23] Paul Dubois
Posted by developer:
Fixed in 8.0.17.

Logging to the mysql.slow_log system table could fail when values
were to large for table columns. Now logging proceeds on a
best-effort basis, writing what information can be provided.
Otherwise, the row is discarded and a message is written to the error