Skip to content

Instantly share code, notes, and snippets.

@lefred
lefred / gist:07c9e1801ebdd5f7ff1b
Created March 1, 2016 13:28
galeraWaitUntilEmptyRecvQueue
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 ROUND(SUM(trx)/60) AS transactions_per_second FROM
(SELECT VARIABLE_VALUE * -1 AS trx
FROM information_schema.GLOBAL_STATUS
WHERE VARIABLE_NAME = 'wsrep_last_committed'
UNION ALL SELECT sleep(60) AS trx
UNION ALL SELECT VARIABLE_VALUE AS trx
FROM information_schema.GLOBAL_STATUS
WHERE VARIABLE_NAME = 'wsrep_last_committed') AS COUNTED;
SELECT ROUND(SUM(bytes)/1024/1024*60) AS megabytes_per_hour
FROM (
SELECT SUM(VARIABLE_VALUE) * -1 AS bytes
FROM information_schema.GLOBAL_STATUS
WHERE VARIABLE_NAME IN ('wsrep_received_bytes', 'wsrep_replicated_bytes')
UNION ALL SELECT sleep(60) AS bytes
UNION ALL SELECT SUM(VARIABLE_VALUE) AS bytes
FROM information_schema.GLOBAL_STATUS
WHERE VARIABLE_NAME IN ('wsrep_received_bytes',
'wsrep_replicated_bytes')
@lefred
lefred / Galera UUID
Last active November 17, 2015 07:23
From To Length Content
----- ---- ------- ---------------------------
0 31 32 Bits 0-31 of Coordinated Universal Time (UTC) as a count of 100-nanosecond
intervals since 00:00:00.00, 15 October 1582, encoded as big-endian 32-bit
number.
32 47 16 Bits 32-47 of UTC as a count of 100-nanosecond intervals since 00:00:00.00,
15 October 1582, encoded as big-endian 16-bit number.
48 59 12 Bits 48-59 of UTC as a count of 100-nanosecond intervals since 00:00:00.00,
15 October 1582, encoded as big-endian 16-bit number.
60 63 4 UUID version number: always equal to 1 (DCE UUID).
@lefred
lefred / gist:634463dff834e1933ad6
Last active August 29, 2015 14:13
HaProxy configuration
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
uid 99
gid 99
daemon
defaults
log global

Keybase proof

I hereby claim:

  • I am lefred on github.
  • I am lefred (https://keybase.io/lefred) on keybase.
  • I have a public key whose fingerprint is 3FC1 BFE9 6874 1F85 E9C1 6ACC 3330 C753 DD8A B51D

To claim this, I am signing this object: