Created
March 1, 2016 13:28
-
-
Save lefred/07c9e1801ebdd5f7ff1b to your computer and use it in GitHub Desktop.
galeraWaitUntilEmptyRecvQueue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE test; DROP FUNCTION IF EXISTS galeraWaitUntilEmptyRecvQueue; | |
DELIMITER $$ | |
CREATE | |
DEFINER=root@localhost FUNCTION galeraWaitUntilEmptyRecvQueue() | |
RETURNS INT UNSIGNED READS SQL DATA | |
BEGIN | |
DECLARE queue INT UNSIGNED; | |
DECLARE starttime TIMESTAMP; | |
DECLARE blackhole INT UNSIGNED; | |
SET starttime = SYSDATE(); | |
SELECT VARIABLE_VALUE AS trx INTO queue | |
FROM information_schema.GLOBAL_STATUS | |
WHERE VARIABLE_NAME = 'wsrep_local_recv_queue'; | |
WHILE queue > 1 DO /* we allow the queue to be 1 */ | |
SELECT VARIABLE_VALUE AS trx INTO queue | |
FROM information_schema.GLOBAL_STATUS | |
WHERE VARIABLE_NAME = 'wsrep_local_recv_queue'; | |
SELECT SLEEP(1) into blackhole; | |
END WHILE; | |
RETURN SYSDATE() - starttime; | |
END$$ | |
DELIMITER ;[ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment