Skip to content

Commit b185709

Browse files
committed
fix: concurrent modification and query
1 parent cb1ea9f commit b185709

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

s3.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func (s *S3Bucket) Query(q dsq.Query) (dsq.Results, error) {
233233

234234
index := q.Offset
235235
nextValue := func() (dsq.Result, bool) {
236+
tryAgain:
236237
if q.Limit > 0 && sent >= q.Limit {
237238
return dsq.Result{}, false
238239
}
@@ -262,8 +263,18 @@ func (s *S3Bucket) Query(q dsq.Query) (dsq.Results, error) {
262263
}
263264
if !q.KeysOnly {
264265
value, err := s.Get(ds.NewKey(entry.Key))
265-
if err != nil {
266-
return dsq.Result{Error: err}, false
266+
switch err {
267+
case nil:
268+
case ds.ErrNotFound:
269+
// This just means the value got deleted in the
270+
// mean-time. That's not an error.
271+
//
272+
// We could use a loop instead of a goto, but
273+
// this is one of those rare cases where a goto
274+
// is easier to understand.
275+
goto tryAgain
276+
default:
277+
return dsq.Result{Entry: entry, Error: err}, false
267278
}
268279
entry.Value = value
269280
}

0 commit comments

Comments
 (0)