From ec091efe3b53cf5e88de2d2fc407431c26dc5632 Mon Sep 17 00:00:00 2001 From: Prabhat Khera <91852476+prabhat-org@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:06:20 +1200 Subject: [PATCH] fix deadlock situation (#10360) --- .../endpointgroups/endpointgroup_update.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/api/http/handler/endpointgroups/endpointgroup_update.go b/api/http/handler/endpointgroups/endpointgroup_update.go index 84964695d..bf7410cfd 100644 --- a/api/http/handler/endpointgroups/endpointgroup_update.go +++ b/api/http/handler/endpointgroups/endpointgroup_update.go @@ -155,12 +155,16 @@ func (handler *Handler) updateEndpointGroup(tx dataservices.DataStoreTx, endpoin err = handler.AuthorizationService.CleanNAPWithOverridePolicies(tx, &endpoint, endpointGroup) if err != nil { // Update flag with endpoint and continue - handler.PendingActionsService.Create(portainer.PendingActions{ - EndpointID: endpoint.ID, - Action: "CleanNAPWithOverridePolicies", - ActionData: endpointGroup.ID, - }) - log.Warn().Err(err).Msgf("Unable to update user authorizations for endpoint (%d) and endpoint group (%d).", endpoint.ID, endpointGroup.ID) + go func(endpointID portainer.EndpointID, endpointGroupID portainer.EndpointGroupID) { + err := handler.PendingActionsService.Create(portainer.PendingActions{ + EndpointID: endpointID, + Action: "CleanNAPWithOverridePolicies", + ActionData: endpointGroupID, + }) + if err != nil { + log.Error().Err(err).Msgf("Unable to create pending action to clean NAP with override policies for endpoint (%d) and endpoint group (%d).", endpointID, endpointGroupID) + } + }(endpoint.ID, endpointGroup.ID) } } }