[#1291] fixed nested tx deadlock when creating new user with OAuth2

This commit is contained in:
Gani Georgiev
2022-12-18 11:11:34 +02:00
parent 84ba89d5af
commit bd16680548
3 changed files with 63 additions and 2 deletions

View File

@@ -675,9 +675,10 @@ func (form *RecordUpsert) DrySubmit(callback func(txDao *daos.Dao) error) error
return err
}
// use the default app.Dao to prevent changing the transaction form.Dao
// use the default app.Dao().ConcurrentDB() to prevent changing the transaction form.Dao
// and causing "transaction has already been committed or rolled back" error
return form.app.Dao().RunInTransaction(func(txDao *daos.Dao) error {
dryDao := daos.New(form.app.Dao().ConcurrentDB())
return dryDao.RunInTransaction(func(txDao *daos.Dao) error {
tx, ok := txDao.DB().(*dbx.Tx)
if !ok {
return errors.New("failed to get transaction db")