From fba22f9909c34d756058df1dd75d12c9555d48c9 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Thu, 12 Jan 2023 16:55:35 -0800 Subject: [PATCH] Restrucutre transactions to try and debug HASH conflict issue Signed-off-by: James Ketrenos --- server/scanner.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/server/scanner.js b/server/scanner.js index 3c9d30c..b74944c 100755 --- a/server/scanner.js +++ b/server/scanner.js @@ -347,6 +347,7 @@ const processBlock = async (items) => { asset.duplicate = duplicate.photoId; duplicates.push(asset); } + return; /* Done processing this asset (DUPLICATE) */ } @@ -381,13 +382,8 @@ const processBlock = async (items) => { transaction: t }); }); - await Promise.mapSeries(insertHash, async (item) => { - await photoDB.sequelize.query( - "INSERT INTO photohashes (hash,photoId) VALUES(:hash,:id)", { - replacements: item, - transaction: t - }); - }); + }); + await photoDB.sequelize.transaction(async (t) => { /* Update the DB with the image information */ await Promise.mapSeries(updateAsset, async (item) => { await photoDB.sequelize.query("UPDATE photos SET " + @@ -398,6 +394,15 @@ const processBlock = async (items) => { }); }); }); + await photoDB.sequelize.transaction(async (t) => { + await Promise.mapSeries(insertHash, async (item) => { + await photoDB.sequelize.query( + "INSERT INTO photohashes (hash,photoId) VALUES(:hash,:id)", { + replacements: item, + transaction: t + }); + }); + }); } catch (error) { console.error(error); process.exit(-1);