修改FEDERATED引擎表数据引起的从库宕机,改表需谨慎

FEDERATED表不仅可以读,而且可以被修改。主从复制中如果用到了FEDERATED表,当在主库修改此表时,会引起从库宕机。宕机原因不太清楚。

测试mysql版本:percona server 5.6.29
主库:192.168.1.25:3306
从库:192.168.1.25:3307
单机:192.168.1.26:33060

在192.168.1.26:33060上建表
CREATE TABLE tt (
id int(11) NOT NULL AUTO_INCREMENT,
d date DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
插入两条数据:
insert into tt (d) select '2017-10-23';
insert into tt (d) select '2017-10-23';

在192.168.1.25:3306上建FEDERATED表
CREATE TABLE tt (
id int(11) NOT NULL AUTO_INCREMENT,
d date DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://dba:XXXXXXX@192.168.1.26:33060/ssq/tt'

在192.168.1.25:3306上执行update操作:

mysql> select * from tt;
idd
12017-10-23
22017-10-23

2 rows in set (0.00 sec)

mysql> update tt set d='2017-10-24';
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 0

此时,192.168.1.25:3307实例直接挂掉,日志如下:
03:14:23 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.
Please help us make Percona Server better by reporting any
bugs at http://bugs.percona.com/

key_buffer_size=67108864
read_buffer_size=2097152
max_used_connections=1
max_threads=1502
thread_count=3
connection_count=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 15466807 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7fa927c13000
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7fa928b61820 thread_stack 0x30000
/opt/mysql/bin/mysqld(my_print_stacktrace+0x2c)[0x8f8bbc]
/opt/mysql/bin/mysqld(handle_fatal_signal+0x461)[0x67de61]
/lib64/libpthread.so.0(+0xf7e0)[0x7faa0e19f7e0]
/opt/mysql/bin/mysqld(_ZN12ha_federated7rnd_posEPhS0_+0x2f)[0x95167f]
/opt/mysql/bin/mysqld(_ZN7handler10ha_rnd_posEPhS0_+0x65)[0x5c1f95]
/opt/mysql/bin/mysqld(_ZN14Rows_log_event24do_index_scan_and_updateEPK14Relay_log_info+0x1fb)[0x88f58b]
/opt/mysql/bin/mysqld(_ZN14Rows_log_event14do_apply_eventEPK14Relay_log_info+0x526)[0x88e906]
/opt/mysql/bin/mysqld(_ZN9Log_event11apply_eventEP14Relay_log_info+0x6a)[0x887eba]
/opt/mysql/bin/mysqld(_Z26apply_event_and_update_posPP9Log_eventP3THDP14Relay_log_info+0x25e)[0x8bf82e]
/opt/mysql/bin/mysqld(handle_slave_sql+0x11cb)[0x8c342b]
/opt/mysql/bin/mysqld(pfs_spawn_thread+0x143)[0x930853]
/lib64/libpthread.so.0(+0x7aa1)[0x7faa0e197aa1]
/lib64/libc.so.6(clone+0x6d)[0x7faa0c6a4bcd]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0): is an invalid pointer
Connection ID (thread ID): 3
Status: NOT_KILLED

You may download the Percona Server operations manual by visiting
http://www.percona.com/software/percona-server/. You may find information
in the manual which will help you identify the cause of the crash.

192.168.1.25:3306的binlog:
BINLOG '
j3XlWRPR/wEALQAAAIYJAAAAAJwAAAAAAAEAA3NzcQACdHQAAgMKAAK8YmJy
j3XlWR/R/wEARAAAAMoJAAAAAJwAAAAAAAEAAgAC///8AQAAAFfDD/wBAAAAWMMP/AIAAABXww/8
AgAAAFjDD0wm4Ys=
'/!/;

UPDATE ssq.tt

WHERE

@1=1 / INT meta=0 nullable=0 is_null=0 /

@2='2017:10:23' / DATE meta=0 nullable=1 is_null=0 /

SET

@1=1 / INT meta=0 nullable=0 is_null=0 /

@2='2017:10:24' / DATE meta=0 nullable=1 is_null=0 /

UPDATE ssq.tt

WHERE

@1=2 / INT meta=0 nullable=0 is_null=0 /

@2='2017:10:23' / DATE meta=0 nullable=1 is_null=0 /

SET

@1=2 / INT meta=0 nullable=0 is_null=0 /

@2='2017:10:24' / DATE meta=0 nullable=1 is_null=0 /

at 2506

171017 11:14:23 server id 1025 end_log_pos 2578 CRC32 0x42bf2f4a Query thread_id=61141 exec_time=0 error_code=0

SET TIMESTAMP=1508210063/!/;
COMMIT

192.168.1.25:3307的relay log,从show slave status可以看出,就是从库执行到下面这个事务时宕机了。
BINLOG '
j3XlWRPR/wEALQAAAIYJAAAAAJwAAAAAAAEAA3NzcQACdHQAAgMKAAK8YmJy
j3XlWR/R/wEARAAAAMoJAAAAAJwAAAAAAAEAAgAC///8AQAAAFfDD/wBAAAAWMMP/AIAAABXww/8
AgAAAFjDD0wm4Ys=
'/!/;

UPDATE ssq.tt

WHERE

@1=1 / INT meta=0 nullable=0 is_null=0 /

@2='2017:10:23' / DATE meta=0 nullable=1 is_null=0 /

SET

@1=1 / INT meta=0 nullable=0 is_null=0 /

@2='2017:10:24' / DATE meta=0 nullable=1 is_null=0 /

UPDATE ssq.tt

WHERE

@1=2 / INT meta=0 nullable=0 is_null=0 /

@2='2017:10:23' / DATE meta=0 nullable=1 is_null=0 /

SET

@1=2 / INT meta=0 nullable=0 is_null=0 /

@2='2017:10:24' / DATE meta=0 nullable=1 is_null=0 /

at 2068

171017 11:14:23 server id 1025 end_log_pos 2578 CRC32 0x42bf2f4a Query thread_id=61141 exec_time=0 error_code=0

SET TIMESTAMP=1508210063/!/;
COMMIT

总结:
主库192.168.1.25:3306执行 update tt set d='2017-10-24';
会修改192.168.1.26:33060原表数据
主库产生的binlog传到从库,当从库执行update时会导致从库宕机,
理论上来讲,从库执行update时候数据已经被主库修改,这会导致从库更新不到数据,服务挂掉原因尚不清楚。欢迎大家讨论。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值