feat: refs #7144 DiagnoseProducionFailure first commit
This commit is contained in:
parent
9cba2be00d
commit
14068085d1
|
@ -0,0 +1,22 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`diagnoseProductionFailure`(
|
||||
vWarehouseFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Comprueba si hay fallos en producción.
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.diagnoseProductionFailure (
|
||||
`message` TEXT NOT NULL,
|
||||
hasError TINYINT(1) NOT NULL
|
||||
);
|
||||
|
||||
CALL vn.diagnoseProductionFailure_dbFreeze();
|
||||
|
||||
CALL vn.diagnoseProductionFailure_dbGetLock();
|
||||
|
||||
SELECT * FROM tmp.diagnoseProductionFailure;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.diagnoseProductionFailure;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,19 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`diagnoseProductionFailure_dbFreeze`()
|
||||
BEGIN
|
||||
/**
|
||||
* Comprueba si la db está congelada.
|
||||
*
|
||||
* @table tmp.diagnoseProductionFailure(message, hasError)
|
||||
*/
|
||||
DECLARE vHasError BOOL;
|
||||
|
||||
SELECT IF(COUNT(ID) > 5, TRUE, FALSE) INTO vHasError # Variable en tabla
|
||||
FROM information_schema.PROCESSLIST
|
||||
WHERE COMMAND = 'Query'
|
||||
AND `time` > 60; # Variable en tabla
|
||||
|
||||
INSERT INTO tmp.diagnoseProductionFailure
|
||||
SELECT 'Base de datos congelada', vHasError;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,20 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`diagnoseProductionFailure_dbGetLock`()
|
||||
BEGIN
|
||||
/**
|
||||
* Comprueba si la db está congelada.
|
||||
*
|
||||
* @table tmp.diagnoseProductionFailure(message, hasError)
|
||||
*/
|
||||
DECLARE vHasError BOOL;
|
||||
|
||||
SELECT COUNT(*) INTO vHasError
|
||||
FROM information_schema.METADATA_LOCK_INFO mli
|
||||
JOIN information_schema.PROCESSLIST pl ON pl.ID = mli.THREAD_ID
|
||||
WHERE mli.LOCK_MODE = 'MDL_SHARED_NO_WRITE'
|
||||
AND pl.`time` > 30; # Variable en tabla
|
||||
|
||||
INSERT INTO tmp.diagnoseProductionFailure
|
||||
SELECT 'Get lock bloqueando para asignar colecciones', vHasError;
|
||||
END$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue