Compare commits

...

1 Commits

Author SHA1 Message Date
Guillermo Bonet b457da31e5 feat: refs #7486 Fix no DO_RELEASE
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-18 12:33:35 +02:00
7 changed files with 28 additions and 61 deletions

View File

@ -20,13 +20,36 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
const [, , [{collectionFk}]] =
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
let threadId;
try {
const result =
await Self.rawSql(`
CALL vn.collection_assign(?, @vCollectionFk);
SELECT @vCollectionFk collectionFk,
CONNECTION_ID() threadId
`,
[userId], myOptions);
threadId = result[2][0].threadId;
const collectionFk = result[2][0].collectionFk;
if (!collectionFk) throw new UserError('There are not picking tickets');
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
return collectionFk;
} catch (e) {
// Error deadlock refs #7486
if (e.code === 'ER_LOCK_DEADLOCK') {
const [hasLock] = await Self.rawSql(`
SELECT COUNT(*) FROM INFORMATION_SCHEMA.METADATA_LOCK_INFO
WHERE LOCK_MODE = 'MDL_SHARED_NO_WRITE'
AND THREAD_ID = ?
`,
[threadId], myOptions);
if (hasLock) await Self.rawSql(`KILL ?`, [threadId], myOptions);
}
throw e;
}
};
};

View File

@ -17,22 +17,9 @@ BEGIN
DECLARE vWarehouseFk INT;
DECLARE vLockName VARCHAR(215);
DECLARE vLockTime INT DEFAULT 30;
DECLARE vErrorNumber INT;
DECLARE vErrorMsg TEXT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1
vErrorNumber = MYSQL_ERRNO,
vErrorMsg = MESSAGE_TEXT;
CALL util.debugAdd('collection_assign', JSON_OBJECT(
'errorNumber', vErrorNumber,
'errorMsg', vErrorMsg,
'lockName', vLockName,
'userFk', vUserFk
)); -- Tmp
IF vLockName IS NOT NULL THEN
DO RELEASE_LOCK(vLockName);
END IF;

View File

@ -7,11 +7,6 @@ BEGIN
* @param vWorkerFk id del worker.
* @table Devuelve tabla temporal con las colecciones pendientes
*/
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
RESIGNAL;
END;
CREATE OR REPLACE TEMPORARY TABLE tmp.collection
ENGINE = MEMORY
SELECT c.id collectionFk,

View File

@ -28,8 +28,6 @@ BEGIN
DECLARE vLockName VARCHAR(215);
DECLARE vLockTime INT DEFAULT 30;
DECLARE vFreeWagonFk INT;
DECLARE vErrorNumber INT;
DECLARE vErrorMsg TEXT;
DECLARE c1 CURSOR FOR
SELECT ticketFk, `lines`, m3
@ -49,18 +47,6 @@ BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1
vErrorNumber = MYSQL_ERRNO,
vErrorMsg = MESSAGE_TEXT;
CALL util.debugAdd('collection_new', JSON_OBJECT(
'errorNumber', vErrorNumber,
'errorMsg', vErrorMsg,
'lockName', vLockName,
'userFk', vUserFk,
'ticketFk', vTicketFk
)); -- Tmp
IF vLockName IS NOT NULL THEN
DO RELEASE_LOCK(vLockName);
END IF;

View File

@ -15,11 +15,6 @@ proc: BEGIN
DECLARE vEndingDate DATETIME;
DECLARE vIsTodayRelative BOOLEAN;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
RESIGNAL;
END;
SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
INTO vEndingDate
FROM productionConfig;

View File

@ -9,11 +9,6 @@ BEGIN
*/
DECLARE vStateFk INT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
RESIGNAL;
END;
INSERT INTO ticket (
clientFk,
shipped,

View File

@ -27,20 +27,6 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1
vErrorNumber = MYSQL_ERRNO,
vErrorMsg = MESSAGE_TEXT;
CALL util.debugAdd('ticket_splitItemPackingType', JSON_OBJECT(
'errorNumber', vErrorNumber,
'errorMsg', vErrorMsg,
'ticketFk', vTicketFk
)); -- Tmp
RESIGNAL;
END;
DELETE FROM vn.sale
WHERE quantity = 0
AND ticketFk = vTicketFk;