From a966efcc6b9804aeb21a65d561e1cf6b0e0ce22a Mon Sep 17 00:00:00 2001 From: Daniel Wasserman Date: Fri, 11 Oct 2024 10:53:33 -0500 Subject: [PATCH 1/2] Feat: call Forward in new goroutine in handleBridgeRequestedLog --- services/rfq/relayer/service/handlers.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/services/rfq/relayer/service/handlers.go b/services/rfq/relayer/service/handlers.go index fc1bc1abe8..dbba3dea6e 100644 --- a/services/rfq/relayer/service/handlers.go +++ b/services/rfq/relayer/service/handlers.go @@ -47,7 +47,12 @@ func (r *Relayer) handleBridgeRequestedLog(parentCtx context.Context, req *fastb return nil } - defer unlocker.Unlock() + shouldUnlock := true + defer func() { + if shouldUnlock { + unlocker.Unlock() + } + }() _, err = r.db.GetQuoteRequestByID(ctx, req.TransactionId) // expect no results @@ -120,12 +125,17 @@ func (r *Relayer) handleBridgeRequestedLog(parentCtx context.Context, req *fastb if err != nil { return fmt.Errorf("could not get quote request handler: %w", err) } - // Forward instead of lock since we called lock above. - fwdErr := qr.Forward(ctx, dbReq) - if fwdErr != nil { - logger.Errorf("could not forward to handle seen: %w", fwdErr) - span.AddEvent("could not forward to handle seen") - } + + // Forward in new goroutine and retain the lock. + shouldUnlock = false + go func() { + defer unlocker.Unlock() + fwdErr := qr.Forward(ctx, dbReq) + if fwdErr != nil { + logger.Errorf("could not forward to handle seen: %w", fwdErr) + span.AddEvent(fmt.Sprintf("could not forward to handle seen: %s", fwdErr.Error())) + } + }() return nil } From 42893f085888b6a3e6933496a70d9197fa47010a Mon Sep 17 00:00:00 2001 From: Daniel Wasserman Date: Fri, 11 Oct 2024 10:56:38 -0500 Subject: [PATCH 2/2] [goreleaser]