Database/MySQL, MariaDB

MariaDB 버전에 따른 mysql DB 스키마 관련 오류 ([Error] Query caused different errors on mast

BabyTT 2023. 3. 6. 22:25

 

이슈 상황

Database Drop 문 실행 시, MySQL Slave에서 Error 발생
 
mysql.proc 관련
[Error] Query caused different errors on master and slave. Error on master: message (format)='Column count of %s.%s is wrong. Expected %d, found %d. The table is probably corrupted' error code=1805 " Error on slave: actual message='no error', error code=0. 
 
mysql.event 관련
Incorrect definition of table mysql.event: expected column 'sql_mode' at position 14 to have type set('REAL_AS_FOAT',.....
 
Google 검색 시 거의 대부분의 오류 대처법은 오류가 나는 binlog 포지션을 skip 해서 복제를 해결하라고 하지만 근본적인 원인을 해결하는 방법이 아님.
stop slave;
set global sql_slave_skip_counter =1;
start slave;
 
 

장애 사유

근본적 원인은 MariaDB 10.3 이전 버전과 MariaDB 10.8로 업그레이드 한 버전에서의 mysql.proc/ mysql.event 등의 테이블 스키마가 변경되면서 메타데이터 정보를 확인할 때 오류가 발생해서였다.
(새로운 master에 mysql DB 백업 본까지 복원하면서 master는 10.3 이전 버전의, slave는 10.8 버전의 mysql 스키마로 구성되어 있었다.)
 
The mysql.event table contains information about MariaDB events. Similar information can be obtained by viewing the INFORMATION_SCHEMA.EVENTS table, or with the SHOW EVENTS and SHOW CREATE EVENT statements.
The table is upgraded live, and there is no need to restart the server if the table has changed.

MariaDB starting with 10.4

In MariaDB 10.4 and later, this table uses the Aria storage engine.

MariaDB until 10.3

In MariaDB 10.3 and before, this table uses the MyISAM storage engine.

 
 

해결 방법:

MariaDB 10.8 버전의 mysql.proc, mysql.event 테이블을 백업해서 master에 복원
(여기서 master에는 mysql DB에 대해 ignore replication 상태였다.)
 
 

연관 에러

에러로그에 column_stats 테이블 관련 에러도 있었는데 이도 같은 mysql 버전에 따른 mysql DB의 테이블 스키마 변경과 연관이 있었고, 동일한 방법으로 해결하였다.
Incoreect definition of table mysql.column_stats: expected column 'hist_type' at position 9 to have type enum('SINGLE_REPC_HB'....)
Incoreect definition of table mysql.column_stats: expected column 'histogram' at position 10 to have type longblob, found type varbinary(255)