본문 바로가기
MySQL별책부록

26. MySQL Ver. 5.7 show slave status 기능 개선

by 모모레 2016. 5. 3.

겪어본 사람은 겪어 봤을 거고, 못 겪어본 사람은 못 겪어봤을 현상. 

show slave status 로 인해 MySQL에 lock 경합이 유발되는 현상이 있다. 


show slave status는 상태 정보 확인을 위해 실행 시 해당 정보에 대한 lock을 획득하여 정보를 보여준다. 

그래서, 다른 세션에서 stop slave를 실행하여 완료가 되지 못한 상황인 경우,  show slave status 구문을 실행하면 결과값을 보여주지 못한 현상을 경험할 수 있다. 


그런데 이 현상이 MySQL Ver. 5.7.9 부터는 사라지게 되는데.....

MySQL Ver. 5.7.9 부터 락을 획득하지 않은 상태에서 상태 정보를 보여주게 변경되었기 때문이다. 


해당 내용은 다음의 url에서 확인할 수 있다. 


https://dev.mysql.com/doc/refman/5.7/en/show-slave-status.html



Between MySQL 5.7.1 and MySQL 5.7.5, an optional NONBLOCKING clause could be used. The NONBLOCKING clause caused SHOW SLAVE STATUS, when run concurrently with STOP SLAVE, to return without waiting for STOP SLAVE to finish shutting down the slave SQL thread or slave I/O thread (or both). This option was intended for use in monitoring and other applications where getting an immediate response from SHOW SLAVE STATUS was more important than ensuring that it returned the latest data. This option was removed in MySQL 5.7.6 due to locking changes in replication administrative statements. As of MySQL 5.7.9 the non-blocking behavior of SHOW SLAVE STATUS is fixed and the option became unnecessary.