From 9aa46c3a90d7f54dfa36ffda42d1464ef9225d1a Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 26 Mar 2024 16:50:15 +0100 Subject: [PATCH 1/2] fix: HOTFIX PROC vn.collection_new release lock on error --- db/routines/vn/procedures/collection_new.sql | 26 +++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index d91c63c24..82196585d 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -28,6 +28,7 @@ proc:BEGIN DECLARE vLockName VARCHAR(215); DECLARE vLockTime INT DEFAULT 15; DECLARE vFreeWagonFk INT; + DECLARE c1 CURSOR FOR SELECT ticketFk, `lines`, m3 FROM tmp.productionBuffer @@ -44,13 +45,21 @@ proc:BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + IF vLockName IS NOT NULL THEN + DO RELEASE_LOCK(vLockName); + END IF; + + RESIGNAL; + END; + SELECT pc.ticketTrolleyMax * o.numberOfWagons, pc.hasUniqueCollectionTime, w.code, o.warehouseFk, o.itemPackingTypeFk, st.code, - CONCAT('collection_new', o.warehouseFk, ':',o.itemPackingTypeFk), o.numberOfWagons, o.trainFk, o.linesLimit, @@ -61,7 +70,6 @@ proc:BEGIN vWarehouseFk, vItemPackingTypeFk, vStateFk, - vLockName, vWagons, vTrainFk, vLinesLimit, @@ -71,6 +79,12 @@ proc:BEGIN JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; + SET vLockName = CONCAT_WS('/', + 'collection_new', + vWarehouseFk, + vItemPackingTypeFk + ); + IF NOT GET_LOCK(vLockName, vLockTime) THEN LEAVE proc; END IF; @@ -250,13 +264,13 @@ proc:BEGIN UPDATE tTrain SET ticketFk = vFirstTicketFk WHERE wagon = vFreeWagonFk; - + -- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo DELETE tt.* FROM tTrain tt LEFT JOIN ( - SELECT DISTINCT wagon - FROM tTrain + SELECT DISTINCT wagon + FROM tTrain WHERE ticketFk IS NOT NULL ) nn ON nn.wagon = tt.wagon WHERE nn.wagon IS NULL; @@ -271,7 +285,7 @@ proc:BEGIN FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume; IF vDone THEN LEAVE read_loop; - END IF; + END IF; END IF; END LOOP; CLOSE c1; From b532ce3f77b03b21f533035660b1abd959f68b31 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 27 Mar 2024 08:30:45 +0100 Subject: [PATCH 2/2] hotFix: recreate addressTaxArea --- db/routines/vn/functions/addressTaxArea.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/functions/addressTaxArea.sql b/db/routines/vn/functions/addressTaxArea.sql index 3586dd4ce..1d4e9e2f0 100644 --- a/db/routines/vn/functions/addressTaxArea.sql +++ b/db/routines/vn/functions/addressTaxArea.sql @@ -20,6 +20,7 @@ BEGIN CALL vn.addressTaxArea(); SELECT areaFk INTO vTaxArea FROM tmp.addressTaxArea; + DROP TEMPORARY TABLE tmp.addressCompany, tmp.addressTaxArea;