add a timeout to the transaction responsible for saving the updated server data

This commit is contained in:
Dawid Wysokiński 2021-05-01 16:21:49 +02:00
parent 6008d9250c
commit 443c7fb537

View File

@ -277,7 +277,9 @@ func (w *workerUpdateServerData) update() error {
return errors.Wrap(err, "workerUpdateServerData.update") return errors.Wrap(err, "workerUpdateServerData.update")
} }
return w.db.RunInTransaction(context.Background(), func(tx *pg.Tx) error { ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
return w.db.RunInTransaction(ctx, func(tx *pg.Tx) error {
if len(tribesResult.deletedTribes) > 0 { if len(tribesResult.deletedTribes) > 0 {
if _, err := tx.Model(&models.Tribe{}). if _, err := tx.Model(&models.Tribe{}).
Where("tribe.id = ANY (?)", pg.Array(tribesResult.deletedTribes)). Where("tribe.id = ANY (?)", pg.Array(tribesResult.deletedTribes)).