diff --git a/qdb/memqdb.go b/qdb/memqdb.go index d7a93bede..67191163e 100644 --- a/qdb/memqdb.go +++ b/qdb/memqdb.go @@ -200,12 +200,14 @@ func (q *MemQDB) DropKeyRange(_ context.Context, id string) error { q.mu.Lock() defer q.mu.Unlock() + _, ok := q.Krs[id] + if !ok { + return nil + } + lock, ok := q.Locks[id] if !ok { - lock = &sync.RWMutex{} - if err := ExecuteCommands(q.DumpState, NewUpdateCommand(q.Locks, id, lock)); err != nil { - return err - } + return spqrerror.New(spqrerror.SPQR_METADATA_CORRUPTION, fmt.Sprintf("no lock in MemQDB for key range \"%s\"", id)) } if !lock.TryLock() { return spqrerror.Newf(spqrerror.SPQR_KEYRANGE_ERROR, "key range \"%s\" is locked", id) diff --git a/qdb/memqdb_test.go b/qdb/memqdb_test.go index 739bdfd6c..770905801 100644 --- a/qdb/memqdb_test.go +++ b/qdb/memqdb_test.go @@ -204,6 +204,7 @@ func TestKeyRanges(t *testing.T) { DistributionId: "dserr", })) + assert.NoError(memqdb.DropKeyRange(ctx, "nonexistentKeyRange")) } func Test_MemQDB_GetKeyRange(t *testing.T) {