Skip to content

Commit

Permalink
fs: Retry listing if no marker (minio#14221)
Browse files Browse the repository at this point in the history
Retry listings, when no next marker is returned and the result isn't truncated.

This can happen when an object is queued, but no info can be fetched.

Fixes minio#14190
  • Loading branch information
klauspost authored Feb 1, 2022
1 parent 3882da6 commit 067d21d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions cmd/fs-v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -1260,9 +1260,23 @@ func (fs *FSObjects) ListObjectVersions(ctx context.Context, bucket, prefix, mar

// ListObjects - list all objects at prefix upto maxKeys., optionally delimited by '/'. Maintains the list pool
// state for future re-entrant list requests.
func (fs *FSObjects) ListObjects(ctx context.Context, bucket, prefix, marker, delimiter string, maxKeys int) (loi ListObjectsInfo, e error) {
return listObjects(ctx, fs, bucket, prefix, marker, delimiter, maxKeys, fs.listPool,
fs.listDirFactory(), fs.isLeaf, fs.isLeafDir, fs.getObjectInfoNoFSLock, fs.getObjectInfoNoFSLock)
func (fs *FSObjects) ListObjects(ctx context.Context, bucket, prefix, marker, delimiter string, maxKeys int) (loi ListObjectsInfo, err error) {
// listObjects may in rare cases not be able to find any valid results.
// Therefore, it cannot set a NextMarker.
// In that case we retry the operation, but we add a
// max limit, so we never end up in an infinite loop.
tries := 50
for {
loi, err = listObjects(ctx, fs, bucket, prefix, marker, delimiter, maxKeys, fs.listPool,
fs.listDirFactory(), fs.isLeaf, fs.isLeafDir, fs.getObjectInfoNoFSLock, fs.getObjectInfoNoFSLock)
if err != nil {
return loi, err
}
if !loi.IsTruncated || loi.NextMarker != "" || tries == 0 {
return loi, nil
}
tries--
}
}

// GetObjectTags - get object tags from an existing object
Expand Down

0 comments on commit 067d21d

Please sign in to comment.