Merge pull request 'feat(binlog): refs #4409 New function for binlog queue monitoring' (!2299) from 4409-binlogQueueFn into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2299 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
ba94bcdb19
|
@ -9,6 +9,10 @@ SET foreign_key_checks = 0;
|
|||
|
||||
INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled)
|
||||
VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE);
|
||||
|
||||
INSERT INTO util.binlogQueue (code,logName, `position`)
|
||||
VALUES ('mylogger', 'bin.000001', 4);
|
||||
|
||||
/* #5483
|
||||
INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk)
|
||||
VALUES(1, NULL, 1, 300, 1);
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`binlogQueue_getDelay`(vCode VARCHAR(255))
|
||||
RETURNS BIGINT
|
||||
NOT DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Returns the difference between the current position of the binary log and
|
||||
* the passed queue.
|
||||
*
|
||||
* @param vCode The queue code
|
||||
* @return The difference in MB
|
||||
*/
|
||||
DECLARE vCurLogName VARCHAR(255);
|
||||
DECLARE vCurPosition BIGINT;
|
||||
DECLARE vQueueLogName VARCHAR(255);
|
||||
DECLARE vQueuePosition BIGINT;
|
||||
DECLARE vDelay BIGINT;
|
||||
|
||||
SELECT VARIABLE_VALUE INTO vCurLogName
|
||||
FROM information_schema.GLOBAL_STATUS
|
||||
WHERE VARIABLE_NAME = 'BINLOG_SNAPSHOT_FILE';
|
||||
|
||||
SELECT VARIABLE_VALUE INTO vCurPosition
|
||||
FROM information_schema.GLOBAL_STATUS
|
||||
WHERE VARIABLE_NAME = 'BINLOG_SNAPSHOT_POSITION';
|
||||
|
||||
SELECT logName, `position`
|
||||
INTO vQueueLogName, vQueuePosition
|
||||
FROM binlogQueue
|
||||
WHERE code = vCode;
|
||||
|
||||
IF vQueuePosition IS NULL THEN
|
||||
RETURN NULL;
|
||||
END IF;
|
||||
|
||||
SET vDelay =
|
||||
vCurPosition - CAST(vQueuePosition AS SIGNED) +
|
||||
@@max_binlog_size * (
|
||||
CAST(REGEXP_SUBSTR(vCurLogName, '[0-9]+') AS SIGNED) -
|
||||
CAST(REGEXP_SUBSTR(vQueueLogName, '[0-9]+') AS SIGNED)
|
||||
);
|
||||
|
||||
RETURN ROUND(vDelay / POW(1024, 2));
|
||||
END$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue