]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Try playlist rebuild transaction if needed
authorChocobozzz <me@florianbigard.com>
Fri, 9 Sep 2022 10:05:35 +0000 (12:05 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 9 Sep 2022 10:05:57 +0000 (12:05 +0200)
server/lib/activitypub/playlists/create-update.ts

index c28700be687349d3deb348637afd8b4c0e5b136a..9339e8ea433d904f5c1467a0ebd0e8ba3dd59d7a 100644 (file)
@@ -1,5 +1,6 @@
 import { map } from 'bluebird'
 import { isArray } from '@server/helpers/custom-validators/misc'
+import { retryTransactionWrapper } from '@server/helpers/database-utils'
 import { logger, loggerTagsFactory } from '@server/helpers/logger'
 import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants'
 import { sequelizeTypescript } from '@server/initializers/database'
@@ -124,13 +125,13 @@ async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist
 async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MVideoPlaylist) {
   const elementsToCreate = await buildElementsDBAttributes(elementUrls, playlist)
 
-  await sequelizeTypescript.transaction(async t => {
+  await retryTransactionWrapper(() => sequelizeTypescript.transaction(async t => {
     await VideoPlaylistElementModel.deleteAllOf(playlist.id, t)
 
     for (const element of elementsToCreate) {
       await VideoPlaylistElementModel.create(element, { transaction: t })
     }
-  })
+  }))
 
   logger.info('Rebuilt playlist %s with %s elements.', playlist.url, elementsToCreate.length, lTags(playlist.uuid, playlist.url))