fix: avoid account sync deadlock

This commit is contained in:
Qu Xuan
2020-07-31 16:31:01 +08:00
parent 0deb908ac7
commit 509ebb92c7
+5 -3
View File
@@ -2380,9 +2380,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
}