Bug #40799 Can't change "table_open_cache" variable when setting it in the option file
Submitted: 17 Nov 2008 19:07 Modified: 8 Jul 2011 10:50
Reporter: jenny chen Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1.29, 5.1.57 OS:Solaris
Assigned to: CPU Architecture:Any

[17 Nov 2008 19:07] jenny chen
Description:
the "table_open_cache=2048" variable can't be changed if it is set in the option file: even though it was set in the /etc/my.cnf before starting the server, the table_open_cache was still the default 4, I'd have to change it from 4->2048 at runtime, or using command line option at server startup.

How to repeat:
set: /etc/my.cnf

[mysqld]
..
table_open_cache=2048
...

After starting the server,
mysql>show variables like 'table_open_cache';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| table_open_cache | 4  | 
+------------------+-------+
1 row in set (0.00 sec)
[18 Nov 2008 10:28] Valeriy Kravchuk
I can not repeat this with 5.1.30 on Windows.
[18 Nov 2008 16:31] jenny chen
No, I did't try it on Windows. Please reproduce it on Solaris.
[19 Nov 2008 22:04] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior in my environment. Please indicate if you start mysqld using mysqld_safe.
[19 Nov 2008 22:25] jenny chen
Yes, I start the server using mysqld_safe.

The reason that the table_open_cache can't be changed by the "/etc/my.cnf" is that on Solaris(opensolaris, solaris nevada version) there are bundled a few mysql configuration files at /etc/mysql/my.cnf, and /etc/mysql/5.0/my.cnf. Even though the "table_open_cache" was set in /etc/myc.nf, this setting was overided by the /etc/mysql/my.cnf. 

This problem is not available in MySQL 5.0 GA version.
[19 Nov 2008 23:02] Sveta Smirnova
Thank you for the feedback.

Please check if your case is same as bug #40368 and if start mysqld without help of mysqld_safe options are read.
[20 Dec 2008 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[29 Mar 2010 11:23] Eivind Moen
This is still a problem in 5.1.37 (win32) and 5.1.41 (win64).
[8 Jun 2011 7:14] Pavel Dobryakov
5.1.57 on Debian 6.01 setting this options in my.cnf no effect
[8 Jul 2011 10:52] Sveta Smirnova
jenny,

thank you for the feedback. I am sorry: I misread your comment. According to http://dev.mysql.com/doc/refman/5.1/en/option-files.html /etc/mysql/my.cnf read after /etc/my.cnf So your case is not a bug.

Pavel, check options order in your case too. Add a comment if they read in wrong order in your case.
[30 Mar 2012 20:58] Solomon Chang
I think I found out why.
I was having the same problem too.  I put in a line in my my.cnf:
table_cache = 256

...but upon restart, the database kept reverting to table_open_cache of 64.

In my.cnf, further down, there was the following line:
table_cache = 64

So, apparently, if you have two conflicting settings in the config file, the one that occurs last is the one that takes effect.
[27 Aug 2014 3:19] willliam dunlap
This happens in version 5.6 of mysql also of the lastest database.  if you set table_cache to whatever was the last setting with table_cache=whatever. Then you can't start your database no matter what.  I tried going into mysqlld_safe and using grant tables and that does not work you get a error when trying to start up the database no matter what options you use to start the mysql database. This is definitely a bug. Dude.  Do not flag it as other. and its broken in all versions...do fix it. it will keep the set variable no what you set it to. So someone did not use the correct code to set this variable in the database because it will keep the last value its set to....