From 390ae7d98fa7d95ad7ee6351f50f3c244026cbf2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 7 Apr 2020 19:55:38 -0700 Subject: [PATCH] fix: verify that the datastore is still open when querying fixes part of https://github.com/ipfs/go-ipfs/issues/6986 (the other part is that we should be shutting down in the right order) --- datastore.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/datastore.go b/datastore.go index fc215e9..509dbb8 100644 --- a/datastore.go +++ b/datastore.go @@ -342,6 +342,9 @@ func (d *Datastore) Delete(key ds.Key) error { func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) { d.closeLk.RLock() defer d.closeLk.RUnlock() + if d.closed { + return nil, ErrClosed + } txn := d.newImplicitTransaction(true) // We cannot defer txn.Discard() here, as the txn must remain active while the iterator is open.