Bug #13645 too small query_cache_size crashes the server
Submitted: 30 Sep 2005 9:56 Modified: 21 Oct 2005 17:51
Reporter: dan d Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.14-nt OS:Windows (Win XP Pro SP2)
Assigned to: Kent Boortz CPU Architecture:Any

[30 Sep 2005 9:56] dan d
Description:
To test the query_cache, I set the query_cache_size to a very low limit (eg. 49151).
The server accept this WITHOUT any warnings, but crashes with the next query  that hit the query_cache limit.

The crashes occur also under 4.1.13-nt 

How to repeat:
SET GLOBAL query_cache_size = 49151;

And then, some query that the server tries to cache.

Suggested fix:
Set a higher minimum limit of the query_cache_size, to issue a warning and disabling the query_cache if it's too small.
[30 Sep 2005 11:52] Valeriy Kravchuk
Thank you for a bug report. According to the manual (http://dev.mysql.com/doc/mysql/en/query-cache-configuration.html):

"When setting query_cache_size to a non-zero value keep in mind that the query cache needs a minimum size of about 40KB to allocate its structures. (The exact size depends on architecture.) If you set the value too small, you'll get a warning..."

But 4.1.14-nt server is simply crashed:

mysql> select version();
+-----------+
| version() |
+-----------+
| 4.1.14-nt |
+-----------+
1 row in set (0.06 sec)

mysql> SET GLOBAL query_cache_size = 49151;
Query OK, 0 rows affected (0.15 sec)

mysql> select * from test;
ERROR 2013 (HY000): Lost connection to MySQL server during query

without any information in the error log.

5.0.13-rc-nt works as described in the manual:

mysql> select version();
+--------------+
| version()    |
+--------------+
| 5.0.13-rc-nt |
+--------------+
1 row in set (0.00 sec)

mysql> set global query_cache_size = 49151;
Query OK, 0 rows affected (0.07 sec)

mysql> select * from test;
+--------+
| Field1 |
+--------+
| a      |
| b      |
| c      |
+--------+
3 rows in set (0.05 sec)

mysql> set global query_cache_size = 11151;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+-----------------------------------------------------------------+
| Level   | Code | Message
   |
+---------+------+-----------------------------------------------------------------+
| Warning | 1282 | Query cache failed to set size 10240; new query cache size is 0 |
+---------+------+-----------------------------------------------------------------+
1 row in set (0.02 sec)

As well as yesterday's 4.1.15-BK build on Linux:

mysql> select version();
+--------------+
| version()    |
+--------------+
| 4.1.15-debug |
+--------------+
1 row in set (0,00 sec)

mysql> SET GLOBAL query_cache_size = 49151;
Query OK, 0 rows affected (0,00 sec)

mysql> select * from test;
+-----+
| txt |
+-----+
| &   |
| a   |
| c   |
+-----+
3 rows in set (0,01 sec)

mysql> SET GLOBAL query_cache_size = 11151;
Query OK, 0 rows affected, 1 warning (0,00 sec)
[4 Oct 2005 18:06] Konstantin Osipov
This bug is repeatable under 4.1-bk
[21 Oct 2005 17:10] Kent Boortz
This problem can't be repeated in 4.1.15
[21 Oct 2005 17:51] Paul DuBois
No changelog entry needed.