Bug #44179 reset slave crashes in my_error when reset_logs returns non-zero
Submitted: 9 Apr 2009 7:10 Modified: 7 May 2009 13:23
Reporter: Andrei Elkin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.1+ OS:Any
Assigned to: Andrei Elkin
Triage: Triaged: D1 (Critical)

[9 Apr 2009 7:10] Andrei Elkin
Description:
The following piece of code in sql_repl.cc

1026      if ((error= purge_relay_logs(&mi->rli, thd,                      |
1027                                   1 /* just reset */,                 |
1028                                   &errmsg)))                          |
029        goto err;

does not set sql_errno that in combination with non-zero return from
purge_relay_logs() leads to 

#3  0xb7e0772e in __assert_fail () from /lib/tls/i686/cmov/libc.so.6
#4  0x082bdaeb in my_message_sql (error=0, str=0xb74babf4 "Unknown error 0", 
    MyFlags=0) at mysqld.cc:2846
#5  0x08703f44 in my_error (nr=0, MyFlags=0) at my_error.c:99
#6  0x0846cce6 in reset_slave (thd=0x91ae748, mi=0x91f5eb0) at sql_repl.cc:1066

How to repeat:
Invoke RESET SLAVE and simulate an error inside
my_delete_allow_opened() -> my_delete().
MYSQL_BIN_LOG::reset_logs() would register a warning
ER_BINLOG_PURGE_FATAL_ERR and return 1.
purge_relay_logs() the caller prepares 

  *errmsg = "Failed during log reset"

for reset_slave() eventual error generation. However, it does not
set the sql_errno like it's done in other branches in the function.

Suggested fix:
To introduce a new ER_ constant to set sql_errno for the case:

  if ((error= purge_relay_logs(mi->rli, thd,
			       1 /* just reset */,
			       &errmsg)))
  {
    sql_errno= ER_SLAVE_PURGE_RELAY_LOGS;
    goto err;
  }
[30 Apr 2009 12:30] 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/73142

2878 Andrei Elkin	2009-04-30
      Bug #44179 reset slave crashes in my_error when reset_logs returns non-zero
      
      my_error() was invoked in reset_slave()'s with purge_relay_logs()-failing branch
      without passing sql_errno to it.
      
      Fixed with setting sql_errno= ER_RELAY_LOG_FAIL in the purge_relay_logs()-failing branch.
[30 Apr 2009 12:47] 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/73146

2883 Andrei Elkin	2009-04-30 [merge]
      merge bug#44179 fixes to 5.1-bt
[5 May 2009 19:40] Bugs System
Pushed into 5.1.35 (revid:davi.arnaut@sun.com-20090505190206-9xmh7dlc6kom8exp) (version source revid:davi.arnaut@sun.com-20090505190206-9xmh7dlc6kom8exp) (merge vers: 5.1.35) (pib:6)
[6 May 2009 14:10] Bugs System
Pushed into 6.0.12-alpha (revid:svoj@sun.com-20090506125450-yokcmvqf2g7jhujq) (version source revid:joro@sun.com-20090430145106-gsb4j17nl4yf9htf) (merge vers: 6.0.12-alpha) (pib:6)
[7 May 2009 13:23] Jon Stephens
Documented bugfix in the 5.1.35 and 6.0.12 changelogs as follows:

        Unrelated errors occurring during the execution of RESET SLAVE 
        could cause the slave to crash.
[15 Jun 2009 8:27] Bugs System
Pushed into 5.1.35-ndb-6.3.26 (revid:jonas@mysql.com-20090615074202-0r5r2jmi83tww6sf) (version source revid:jonas@mysql.com-20090615070837-9pccutgc7repvb4d) (merge vers: 5.1.35-ndb-6.3.26) (pib:6)
[15 Jun 2009 9:06] Bugs System
Pushed into 5.1.35-ndb-7.0.7 (revid:jonas@mysql.com-20090615074335-9hcltksp5cu5fucn) (version source revid:jonas@mysql.com-20090615072714-rmfkvrbbipd9r32c) (merge vers: 5.1.35-ndb-7.0.7) (pib:6)
[15 Jun 2009 9:47] Bugs System
Pushed into 5.1.35-ndb-6.2.19 (revid:jonas@mysql.com-20090615061520-sq7ds4yw299ggugm) (version source revid:jonas@mysql.com-20090615054654-ebgpz7elwu1xj36j) (merge vers: 5.1.35-ndb-6.2.19) (pib:6)
[10 Jul 2009 11:21] Bugs System
Pushed into 5.4.4-alpha (revid:anozdrin@bk-internal.mysql.com-20090710111017-bnh2cau84ug1hvei) (version source revid:alfranio.correia@sun.com-20090709115409-5lav77omuqx8hc0n) (merge vers: 5.4.4-alpha) (pib:11)
[13 Jul 2009 17:49] Bugs System
Pushed into 5.1.37 (revid:joro@sun.com-20090713174543-cd2x7q1gi1hzoand) (version source revid:staale.smedseng@sun.com-20090710151930-6e6kq5tp7ux1rtbh) (merge vers: 5.1.37) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48] Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:33] Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)