Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sidecar: clean old shims for orders in current batch #342

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sidecar_acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps link to the PR where this will be fixed for good?
Also add a comment that removeShims will only return an error for serious problems (for example not being able to read orders from disk) and not if there is no pending shim (only a warning will be logged but no error returned).

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 {
Expand Down