-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ordering of paginated /v3/roles
is inconsistent
#2249
Comments
It's probably not a bad idea to always use |
For some context, I believe this line was an attempt to deal with this when we implemented it, but I guess it didn't work as we intended (or we missed something):
We wanted to default ordering of v3 roles to be by |
Seeing similar issues when running this call to generate a report. Environments with more than 5000 roles must use pagination in order to process all so a consistent ordering is necessary to accurately collect this data. |
Sarah and I pushed the start of a solution to WIP-order-on-guid, just to document where that work is. We have implemented the fix and have some test clean up and broken roles tests to fix. |
This change resolves an issue with inconsistent ordering that CAPI users were experiencing when resources were created within the same second as each other. Resources that have a GUID field in the CAPI DB will now order by GUID as a secondary order parameter, which should cause the ordering of resources to be consistent. #2249 Co-authored-by: Jenna Goldstrich <[email protected]> Co-authored-by: Sarah Weinstein <[email protected]>
We have run some performance testing before and after making the change. We ran Before change:
After change:
|
Fix shipped in capi-release 1.111.0. |
Thanks for submitting an issue to
cloud_controller_ng
. We are always trying to improve! To help us, please fill out the following template.Issue
When paging through
/v3/roles
, users have found inconsistencies in the results returned.Context
The v3 roles endpoint is backed by a join across several tables, so the default pagination behavior of falling back on the
id
doesn't paginate consistently asid
s can be duplicated.Another thing to consider is that CC only stores timestamps to the second, so if roles are created within the same second ordering by
created_ats
may result in inconsistent ordering as well. This is unavoidable unless CC starts storing more granular timestamps, but we should be aware of this edge case when considering solutions.From Felisia Martini: I think we saw a similar issue happening for service credential bindings during development. That is also an endpoint that joins two tables and the default pagination by id (which was also overriding the user defined order by) is not good enough because the same id will exist in several tables. We did however rely on
created_at
as a more deterministic ordering parameter, but looking at this issue that might have been just a temporary fix. Anyways, this is what we did: 309e311 and the different binding tables are joined in a View in this case. Also, when checking SQL statement we noticed that any ordering applied in the view will be overriden by the paginatororder_by
later.Steps to Reproduce
per_page
query paramfor the
created_ats
concern:Expected result
Consistent default pagination order (when not using an
order_by
query parameter) for the/v3/roles
endpointCurrent result
The intent that surfaced this bug was to compile a complete list of all the roles, but inconsistent ordering inhibits that list creation. For example if two roles are created within the same second, when curling page 1 role A may be on page 1 and role B on page 2, but when curling page 2 entry A and B may swap order and role A would be seen again on page 2. The result being role A would appear twice in the compiled list, and role B wouldn't appear at all.
Results come back in varying order, the following are two separate runs of a script against the same CAPI:
Possible Fix
As a first step we could consider implementing something along the lines of what was done for service credential bindings. This doesn't address the issue of having multiple entries with the same
created_ats
timestamps, but at least should reduce some volatility. We could also explore other ways to order, byguid
or some other field that is consistently unique.The text was updated successfully, but these errors were encountered: