From 4565774669bc3c1b11cc726d577946953dbe53c5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 14 Feb 2023 08:59:27 +0100 Subject: Fix retrying update on sql serialization conflict --- server/controllers/api/video-channel.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'server/controllers/api/video-channel.ts') diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index d7c92952a..5b9fb794a 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts @@ -273,7 +273,6 @@ async function addVideoChannel (req: express.Request, res: express.Response) { async function updateVideoChannel (req: express.Request, res: express.Response) { const videoChannelInstance = res.locals.videoChannel - const videoChannelFieldsSave = videoChannelInstance.toJSON() const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannelInstance.toFormattedJSON()) const videoChannelInfoToUpdate = req.body as VideoChannelUpdate let doBulkVideoUpdate = false @@ -309,10 +308,9 @@ async function updateVideoChannel (req: express.Request, res: express.Response) } catch (err) { logger.debug('Cannot update the video channel.', { err }) - // Force fields we want to update // If the transaction is retried, sequelize will think the object has not changed - // So it will skip the SQL request, even if the last one was ROLLBACKed! - resetSequelizeInstance(videoChannelInstance, videoChannelFieldsSave) + // So we need to restore the previous fields + resetSequelizeInstance(videoChannelInstance) throw err } -- cgit v1.2.3