LoginSignup
0
0

More than 1 year has passed since last update.

mysql レプリケーションでエラーコード 1535

Posted at

はじめに

mysql レプリケーションの、サブ(スレーブ)でエラーコード 1535 が出て更新が止まりました。
(ER_BINLOG_ROW_WRONG_TABLE_DEF)

yymmdd hh:mi:ss [ERROR] Slave SQL: Table definition on master and slave does not match: Column 9 type mismatch - received type 17, dddd.tttttttt has type 7, Error_code: 1535

レアケースと思いますが、ウチの原因を記述します。

発生条件

●条件1
メイン(マスタ)とサブ(スレーブ)で mysql のバージョンが異なり、サブが古い。
しかもウチは MariaDB(メイン)と MySQL(サブ)の組み合わせ・・・。

●条件2
バイナリログが混合形式。(binlog_format = mixed)

●条件3
datetime か timestamp を含む新規テーブルを create する。
(見た目はメインもサブも同じテーブル定義ですが、細かいところで異なるのでしょうね。)

●条件4
条件3のテーブルにデータ更新する際、何かしら一時テーブル(CREATE TEMPORARY TABLE)を開いている。

以上の条件が重なると、サブにバイナリログが行ベースで渡り、エラーコード 1535 が発生します。

暫定対応

データ更新前に一時テーブルを drop します。
これでバイナリログがステートメント形式で渡るので、エラーは起きません。

条件2で binlog_format = statement にしてもよいはずですが、試してません。

余談ですが、ウチではデータ削除(delete)なのにバイナリログが行ベースでした。
行ベースって insert, update だけと勝手に思ってましたが関係ないんですね。

参考

https://dev.mysql.com/doc/refman/5.6/ja/replication-features-temptables.html
https://dev.mysql.com/doc/refman/5.6/ja/binary-log-setting.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0