fix: avoid account sync deadlock

This commit is contained in:
Qu Xuan
2020-07-31 16:32:57 +08:00
parent 1dd8a0c066
commit cbc4739b1a
+5 -3
View File
@@ -1903,9 +1903,11 @@ func (account *SCloudaccount) SubmitSyncAccountTask(ctx context.Context, userCre
defer cloudaccountPendingSyncsMutex.Unlock()
if _, ok := cloudaccountPendingSyncs[account.Id]; ok {
if waitChan != nil {
// an active cloudaccount sync task is running, return with conflict error
log.Errorf("an active cloudaccount sync task is running, early return with conflict error")
waitChan <- errors.Wrap(httperrors.ErrConflict, "cloudaccountPendingSyncs")
go func() {
// an active cloudaccount sync task is running, return with conflict error
log.Errorf("an active cloudaccount sync task is running, early return with conflict error")
waitChan <- errors.Wrap(httperrors.ErrConflict, "cloudaccountPendingSyncs")
}()
}
return
}