Bug #51215 log-error partially works with version 5.5
Submitted: 16 Feb 2010 18:15 Modified: 14 Mar 2010 1:32
Reporter: Sveta Smirnova Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.5.99 OS:Any
Assigned to: Guilhem Bichot CPU Architecture:Any
Tags: regression

[16 Feb 2010 18:15] Sveta Smirnova
Description:
According to our manual at http://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_log-error syntax for log-error is:

--log-error[=file_name]
....
Log errors and startup messages to this file. See Section 5.2.2, “The Error Log”. If you omit the file name, MySQL uses host_name.err. If the file name has no extension, the server adds an extension of .err. 

But since version 5.5 if one not specified file_name error messages are written to stdout, not to the log file.

How to repeat:
$./libexec/mysqld --defaults-file=./support-files/my-small.cnf --basedir=. --datadir=./data --port=33051 --log-error --socket=/tmp/mysql_ssmirnova.sock &
[1] 14240

$100216 18:56:54 [Note] Buffered information: Performance schema disabled (reason: start parameters).

100216 18:56:54 [Note] Plugin 'FEDERATED' is disabled.
100216 18:56:54 [Note] Plugin 'ndbcluster' is disabled.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
100216 18:56:54  InnoDB: highest supported file format is Barracuda.
100216 18:56:55 InnoDB Plugin 1.0.6 started; log sequence number 44358

$100216 18:56:55 [Note] Event Scheduler: Loaded 0 events
100216 18:56:55 [Note] ./libexec/mysqld: ready for connections.
Version: '5.5.99-m3-debug'  socket: '/tmp/mysql_ssmirnova.sock'  port: 33051  Source distribution

$./bin/mysqladmin shutdown -uroot  --socket=/tmp/mysql_ssmirnova.sock
100216 18:57:16 [Note] Got signal 15 to shutdown mysqld
100216 18:57:16 [Note] ./libexec/mysqld: Normal shutdown

100216 18:57:16 [Note] Event Scheduler: Purging the queue. 0 events
100216 18:57:16  InnoDB: Starting shutdown...
100216 18:57:17  InnoDB: Shutdown completed; log sequence number 44368
100216 18:57:17 [Note] ./libexec/mysqld: Shutdown complete

[1]+  Done                    ./libexec/mysqld --defaults-file=./support-files/my-small.cnf --basedir=. --datadir=./data --port=33051 --log-error --socket=/tmp/mysql_ssmirnova.sock

$./libexec/mysqld --defaults-file=./support-files/my-small.cnf --basedir=. --datadir=./data --port=33051 --log-error=./error --socket=/tmp/mysql_ssmirnova.sock &
[1] 13808

$./bin/mysqladmin shutdown -uroot  --socket=/tmp/mysql_ssmirnova.sock
[1]+  Done                    ./libexec/mysqld --defaults-file=./support-files/my-small.cnf --basedir=. --datadir=./data --port=33051 --log-error=./error --socket=/tmp/mysql_ssmirnova.sock

Suggested fix:
Return old behavior.
[25 Feb 2010 14:00] Guilhem Bichot
I have verified that this was introduced by WL#4738 (re-engineering of server variables):
revision-id:serg@mysql.com-20091222093556-8aocy9n92pdp0rwr
It seems that this had made --log-error(no argument) equivalent to not specifying --log-error at all.
[26 Feb 2010 16:18] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/101692

2993 Guilhem Bichot	2010-02-26
      Fix for BUG#51215 "log-error partially works with version 5.5": WL 4738 (reengineering of server variables)
      had broken the 5.1 behaviour of --log-error: --log-error without argument sent to stderr instead of writing
      to a file with an autogenerated name.
     @ mysql-test/t/log_error.test
        test that error log is created and shown in SHOW VARIABLES.
        Interestingly the error log's path is apparently relative if --log-error=argument is used, but
        may be absolute or relative if --log-error(no argument) is used (because then the path is derived from
        that of pidfile_name, which can be absolute or relative, depending on if autogenerated or not).
     @ mysql-test/t/log_error2.test
        test that error log is created and shown in SHOW VARIABLES
     @ mysql-test/t/log_error3.test
        test that error log is empty in SHOW VARIABLES
     @ sql/mysql_priv.h
        id for option --log-error
     @ sql/mysqld.cc
        No --log-error means "write errors to stderr", whereas --log-error
        without argument means "write errors to a file". So we cannot use the default logic
        of class sys_var_charptr, which treats "option not used" the same as "option used
        without argument" and uses the same default for both. We need to catch "option used",
        in mysqld_get_one_option(), and then "without argument". Setting to "" makes sure
        that init_server_components() will create the log, with an autogenerated name.
     @ sql/sys_vars.cc
        need to give the option a numeric id so that we can catch it in mysqld_get_one_option()
[5 Mar 2010 14:04] Guilhem Bichot
tests moved to sys_vars as advised by Gluh.
Pushed to next-mr-bugfixing and 6.0-codebase-bugfixing.
[5 Mar 2010 14:05] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/102442

3111 Guilhem Bichot	2010-03-05
      Fix for BUG#51215 "log-error partially works with version 5.5": WL 4738 (reengineering of server variables)
      had broken the 5.1 behaviour of --log-error: --log-error without argument sent to stderr instead of writing
      to a file with an autogenerated name.
     @ mysql-test/suite/sys_vars/t/log_error_func.test
        test that error log is created and shown in SHOW VARIABLES.
        Interestingly the error log's path is apparently relative if --log-error=argument is used, but
        may be absolute or relative if --log-error(no argument) is used (because then the path is derived from
        that of pidfile_name, which can be absolute or relative, depending on if autogenerated or not).
     @ mysql-test/suite/sys_vars/t/log_error_func2.test
        test that error log is created and shown in SHOW VARIABLES
     @ mysql-test/suite/sys_vars/t/log_error_func3.test
        test that error log is empty in SHOW VARIABLES
     @ sql/mysql_priv.h
        id for option --log-error
     @ sql/mysqld.cc
        No --log-error means "write errors to stderr", whereas --log-error
        without argument means "write errors to a file". So we cannot use the default logic
        of class sys_var_charptr, which treats "option not used" the same as "option used
        without argument" and uses the same default for both. We need to catch "option used",
        in mysqld_get_one_option(), and then "without argument". Setting to "" makes sure
        that init_server_components() will create the log, with an autogenerated name.
     @ sql/sys_vars.cc
        need to give the option a numeric id so that we can catch it in mysqld_get_one_option()
[6 Mar 2010 10:30] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100306102742-yw9zzgw9ac5r65m5) (version source revid:guilhem@mysql.com-20100305140001-d0unm437s8uzz4hq) (merge vers: 6.0.14-alpha) (pib:16)
[6 Mar 2010 10:30] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100306102638-qna09hbjb5gm940h) (version source revid:guilhem@mysql.com-20100305130821-02n9vd5e42toro05) (pib:16)
[6 Mar 2010 10:59] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:guilhem@mysql.com-20100305130821-02n9vd5e42toro05) (merge vers: 5.5.99-m3) (pib:16)
[14 Mar 2010 1:32] Paul DuBois
Does not appear in any released version. No changelog entry needed.