<?xml version="1.0" encoding="utf-8"?>
<launchpad-bug id="860910">
  <date_last_updated>2011-10-24 14:25:00.566650+00:00</date_last_updated>
  <api_links>
    <bug_api_link>https://api.launchpad.net/1.0/bugs/860910</bug_api_link>
    <bug_owner_link>https://api.launchpad.net/1.0/~gryp</bug_owner_link>
    <milestone_link></milestone_link>
    <linked_branches_collection_link>https://api.launchpad.net/1.0/bugs/860910/linked_branches</linked_branches_collection_link>
    <activity_link>https://api.launchpad.net/1.0/bugs/860910/activity</activity_link>
  </api_links>
  <bug_web_link>https://bugs.launchpad.net/bugs/860910</bug_web_link>
  <owner>Kenny Gryp</owner>
  <assignee></assignee>
  <milestone_title></milestone_title>
  <duplicate_link></duplicate_link>
  <duplicate_bug_id></duplicate_bug_id>
  <title>SHOW SLAVE STATUS gives wrong output with master-master and using SET uservars</title>
  <status>New</status>
  <importance>Undecided</importance>
  <created>2011-09-27 21:05:39.491211+00:00</created>
  <description>
<![CDATA[Description:
In a master-master setup, a master can show a wrong 'SHOW SLAVE STATUS' output.

Requirements:
- master-master
- log_slave_updates

This is caused when using SET user-variables. and then using it to perform writes.
From then on the master that performed the insert will have a SHOW SLAVE STATUS that is
wrong and it will never update again until a write happens on the other master.

How to repeat:

### set up a masterA(serverid 1)<->masterB(serverid 2) with 2 way replication
### enable log-slave-updates on both databasegs
### execute on masterA:

create database test;
use test;
create table test3 (a int);
set @`test`:=0;
insert into test3 values (@test);

### To make it clearer, run the insert statement multiple times. You can even do any
other write you want! doesn't have to be related to test or use a variable.

### run 'show master status' on masterB
masterB> show master status;
+--------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| masterB .000004 | 540 | | |
+--------------------+----------+--------------+------------------+

### run 'show slave status' on masterA
masterA> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: localhost
Master_User: r
Master_Port: 3309
Connect_Retry: 60
Master_Log_File: masterB.000004
Read_Master_Log_Pos: 540
Relay_Log_File: masterA-relay.000011
Relay_Log_Pos: 255
Relay_Master_Log_File: masterB.000004
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 313
Relay_Log_Space: 606
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1

==> masterA displays that it's waiting for master to send events on an old
exec_master_log_pos

### cat relay-log.info and master.info on masterA
Example:

$ cat masterA/master.info
18
masterB.000004
5261
localhost
r
r
3309
60

0.000

$ cat masterA/relay-log.info
./masterB-relay.000011
255
masterB.000004
313

$ stat masterA/relay-log.info
File: `2/relay-log.info'
Size: 54 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 796981 Links: 1
Access: (0660/-rw-rw----) Uid: ( 1000/ gryp) Gid: ( 1000/ gryp)
Access: 2011-09-27 16:59:45.863435966 +0200
Modify: 2011-09-27 16:53:06.874040990 +0200
Change: 2011-09-27 16:53:06.874040990 +0200

$ stat masterA/master.info
File: `2/master.info'
Size: 67 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 796979 Links: 1
Access: (0660/-rw-rw----) Uid: ( 1000/ gryp) Gid: ( 1000/ gryp)
Access: 2011-09-27 16:59:44.222616027 +0200
Modify: 2011-09-27 16:58:06.323690973 +0200
Change: 2011-09-27 16:58:06.323690973 +0200

==> masterA it's relay-log.info file is not updated anymore but master.info is.

### select * from test.test3 and you can see that all writes will be in there.

masterA> select * from test3;
+------+
| a |
+------+
| 0 |
+------+
1 row in set (0.00 sec)

### Actually the relay log should be empty as it should filter out it's own writes, but
the SET commands are in there, with the masterB serverid: 1
#110927 16:53:06 server id 1 end_log_pos 418 User_var
SET @`test`:=0/*!*/;

### The binary log of masterB will contain something like this,you can see that the SET
commands have changed to it's own serverid:
DROP TABLE IF EXISTS `test3` /* generated by server */
/*!*/;
# at 224
#110927 16:53:06 server id 2 end_log_pos 313 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1317135186/*!*/;
create table test3 (a int)
/*!*/;
# at 313
#110927 16:53:06 server id 2 end_log_pos 372 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1317135186/*!*/;
BEGIN
/*!*/;
# at 372
#110927 16:53:06 server id 1 end_log_pos 418 User_var
SET @`test`:=0/*!*/;
# at 418
#110927 16:53:06 server id 2 end_log_pos 513 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1317135186/*!*/;
insert into test3 values (@test)
/*!*/;
# at 513
#110927 16:53:06 server id 2 end_log_pos 540 Xid = 22
COMMIT/*!*/;
# at 540
#110927 16:57:56 server id 2 end_log_pos 599 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1317135476/*!*/;
BEGIN
/*!*/;
# at 599
#110927 16:57:56 server id 1 end_log_pos 645 User_var
SET @`test`:=0/*!*/;
# at 645
#110927 16:57:56 server id 2 end_log_pos 740 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1317135476/*!*/;
insert into test3 values (@test)
/*!*/;
# at 740
#110927 16:57:56 server id 2 end_log_pos 767 Xid = 30
COMMIT/*!*/;

I have verified this under the following mysql versions:
- mysql-5.1.59
- mysql-5.5.16
- Percona Server 5.1.57-rel12.8
- MariaDB 5.2.7
- MariaDB 5.2.8

I also reported this @ bugs.mysql.com: http://bugs.mysql.com/bug.php?id=62557]]>  </description>
  <activities>
    <activity datechanged="2011-09-27T21:05:06.046433+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Kenny Gryp</person>
      <message>added bug</message>
    </activity>
    <activity datechanged="2011-09-27T21:05:39.491211+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[maria]]>      </newvalue>
      <whatchanged>bug task added</whatchanged>
      <person>Kenny Gryp</person>
      <message></message>
    </activity>
    <activity datechanged="2011-09-28T06:44:40.489827+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Kristian Nielsen</person>
      <message>added subscriber Kristian Nielsen</message>
    </activity>
    <activity datechanged="2011-09-28T07:36:38.505939+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Frederic Descamps</person>
      <message>added subscriber Frederic Descamps</message>
    </activity>
    <activity datechanged="2011-10-02T02:47:21.099755+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Aurimas Mikalauskas</person>
      <message>added subscriber Aurimas Mikalauskas</message>
    </activity>
    <activity datechanged="2011-10-12T09:47:26.826368+00:00">
      <oldvalue>
<![CDATA[New]]>      </oldvalue>
      <newvalue>
<![CDATA[In Progress]]>      </newvalue>
      <whatchanged>percona-server: status</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-12T09:47:30.139973+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Alexey Kopytov (akopytov)]]>      </newvalue>
      <whatchanged>percona-server: assignee</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-12T09:47:48.742277+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.1.60-13.1]]>      </newvalue>
      <whatchanged>percona-server: milestone</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-12T10:11:58.246571+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[http://bugs.mysql.com/bug.php?id=62557]]>      </newvalue>
      <whatchanged>bug watch added</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-12T10:11:58.246571+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[mysql-server]]>      </newvalue>
      <whatchanged>bug task added</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-13T09:43:10.286446+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[lp:~akopytov/percona-server/bug860910-5.1]]>      </newvalue>
      <whatchanged>branch linked</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-13T09:43:22.355342+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[lp:~akopytov/percona-server/bug860910-5.5]]>      </newvalue>
      <whatchanged>branch linked</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-13T09:43:25.870817+00:00">
      <oldvalue>
<![CDATA[In Progress]]>      </oldvalue>
      <newvalue>
<![CDATA[Fix Committed]]>      </newvalue>
      <whatchanged>percona-server: status</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-14T10:03:05.930610+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[percona-server/5.1]]>      </newvalue>
      <whatchanged>nominated for series</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-14T10:03:05.930610+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[percona-server/5.1]]>      </newvalue>
      <whatchanged>bug task added</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-14T10:03:05.930610+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[percona-server/5.5]]>      </newvalue>
      <whatchanged>nominated for series</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-14T10:03:05.930610+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[percona-server/5.5]]>      </newvalue>
      <whatchanged>bug task added</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-14T10:03:22.057152+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Alexey Kopytov (akopytov)]]>      </newvalue>
      <whatchanged>percona-server/5.1: assignee</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-14T10:03:30.689147+00:00">
      <oldvalue>
<![CDATA[New]]>      </oldvalue>
      <newvalue>
<![CDATA[Fix Committed]]>      </newvalue>
      <whatchanged>percona-server/5.1: status</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-14T10:03:41.949496+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.1.60-13.1]]>      </newvalue>
      <whatchanged>percona-server/5.1: milestone</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-14T10:04:02.442155+00:00">
      <oldvalue>
<![CDATA[5.1.60-13.1]]>      </oldvalue>
      <newvalue>
<![CDATA[5.5.17-23.0]]>      </newvalue>
      <whatchanged>percona-server/5.5: milestone</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-24T14:24:55.214003+00:00">
      <oldvalue>
<![CDATA[Fix Committed]]>      </oldvalue>
      <newvalue>
<![CDATA[Fix Released]]>      </newvalue>
      <whatchanged>percona-server/5.1: status</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
    <activity datechanged="2011-10-24T14:24:58.788122+00:00">
      <oldvalue>
<![CDATA[Fix Committed]]>      </oldvalue>
      <newvalue>
<![CDATA[Fix Released]]>      </newvalue>
      <whatchanged>percona-server/5.5: status</whatchanged>
      <person>Alexey Kopytov</person>
      <message></message>
    </activity>
  </activities>
  <branches>
    <branch>lp:~akopytov/percona-server/bug860910-5.1</branch>
    <branch>lp:~akopytov/percona-server/bug860910-5.5</branch>
  </branches>
</launchpad-bug>
