From 034cc45b59dfa2c0d52713821cbb22ef80d2657f Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 26 Jan 2022 14:59:32 +0100 Subject: [PATCH] state: abort list operation on context cancellation Stopping cluster while listing pins seems to hang until the operation has finished. --- state/dsstate/datastore.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/state/dsstate/datastore.go b/state/dsstate/datastore.go index 271d7cdcf..b2d27a5aa 100644 --- a/state/dsstate/datastore.go +++ b/state/dsstate/datastore.go @@ -142,6 +142,12 @@ func (st *State) List(ctx context.Context) ([]*api.Pin, error) { total := 0 for r := range results.Next() { + // Abort if we shutdown. + select { + case <-ctx.Done(): + return nil, ctx.Err() + default: + } if r.Error != nil { logger.Errorf("error in query result: %s", r.Error) return pins, r.Error