From d2cd76a65ebb2869e2ceda9ddbe44455cef207ae Mon Sep 17 00:00:00 2001 From: positiveblue Date: Thu, 24 Feb 2022 13:45:41 -0800 Subject: [PATCH] sidecar: clean old shims for orders in current batch --- sidecar_acceptor.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sidecar_acceptor.go b/sidecar_acceptor.go index e441c8534..86d8e7789 100644 --- a/sidecar_acceptor.go +++ b/sidecar_acceptor.go @@ -601,6 +601,13 @@ func (a *SidecarAcceptor) matchPrepare(pendingBatch *order.Batch, sdcrLog.Infof("Received PrepareMsg for batch=%x, num_orders=%v", batch.ID[:], len(batch.MatchedOrders)) + // Ensure that we do not have any registered shims for the orders + // in this batch. This is not supposed to happen but we have a bug. + if err = a.removeShims(batch); err != nil { + return nil, fmt.Errorf("unable to cleanup shims before start "+ + "preparing the current batch: %v", err) + } + // If there is still a pending batch around from a previous iteration, // we need to clean up the pending channels first. if pendingBatch != nil {