Skip to content

Commit

Permalink
fixes the incorrect remaining items count in a paginated list items q…
Browse files Browse the repository at this point in the history
…uery

Signed-off-by: Hemant Singh <shemant@vmware.com>
  • Loading branch information
HemantNegi committed Jan 25, 2024
1 parent 4929f3e commit 789af91
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/server/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ func (l *LimitedServer) list(ctx context.Context, r *etcdserverpb.RangeRequest)
if limit > 0 && resp.Count > r.Limit {
resp.More = true
resp.Kvs = kvs[0 : limit-1]

// count the actual number of results if there are more items in the db.
_, count, err := l.backend.Count(ctx, prefix)
if err != nil {
return nil, err
}
logrus.Tracef("LIST COUNT key=%s, end=%s, revision=%d, currentRev=%d count=%d", r.Key, r.RangeEnd, r.Revision, rev, count)
resp.Count = count
}

return resp, nil
Expand Down

0 comments on commit 789af91

Please sign in to comment.