Skip to content

Commit

Permalink
Change for explicit error
Browse files Browse the repository at this point in the history
  • Loading branch information
EinKrebs committed Oct 2, 2024
1 parent 8f6e1ab commit 7e86e06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions qdb/memqdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions qdb/memqdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ func TestKeyRanges(t *testing.T) {
DistributionId: "dserr",
}))

assert.NoError(memqdb.DropKeyRange(ctx, "nonexistentKeyRange"))
}

func Test_MemQDB_GetKeyRange(t *testing.T) {
Expand Down

0 comments on commit 7e86e06

Please sign in to comment.