Batch Orbit item counts in GraphQL and add indexing lastCompletedAt
What does this MR do and why?
The Orbit overview page needs item counts for each group. Today the page sends one REST graph_status request per group. This MR lets one GraphQL request get the counts of up to 100 groups with one Orbit call.
orbit.itemCountsbatches its paths likeorbit.indexingdoes. Both resolvers share one batch method inStatusResolvable.- The field limit goes from 1 to 100 groups or projects in one request.
orbit.indexing.lastCompletedAtis new. It replaces the last REST field that the frontend reads. It is an experiment from 19.6, it acceptsai_workflowstokens (AI_WORKFLOW_SCOPES), and its description says when it is null.- The
orbit_item_countsrate limit goes from 10 to 30 requests per minute per user. This is the same asorbit_indexing_status.
batch_orbit_status(:orbit_item_counts) do |client, paths, request_context|
client.get_item_counts(user: current_user, traversal_paths: paths, request_context: request_context)
.fetch(:namespaces)
end| Request | Orbit field that Rails sets | Response that Rails reads |
|---|---|---|
| One path | traversal_path |
domains |
| More paths | traversal_paths |
namespaces |
Rails never sets both fields. Orbit runs one count query per path, up to 8 at once. If the query for a path fails, Orbit leaves that path out of namespaces. A path that Orbit does not return gets null. It never gets zero counts.
Rails sends traversal_path for one path only until the Orbit release with gitlab-org/orbit/knowledge-graph!3034 (merged) is the minimum version. A follow-up switches Rails to traversal_paths for every request.
Minimum Orbit version
This MR needs the Orbit release that includes gitlab-org/orbit/knowledge-graph!3034 (merged). That release adds GetItemCounts.traversal_paths. Deploy that Orbit release before this MR.
- An older Orbit still answers a request for one group.
- For a request with more groups, an older Orbit returns an error, so
itemCountsisnullwith a GraphQL error. The overview card then shows "Counts are not available right now". It does not show zeros.
Orbit proto gem
This MR bumps gitlab-orbit-proto to 0.156.0. That release has GetItemCountsRequest.traversal_paths and NamespaceItemCounts from gitlab-org/orbit/knowledge-graph!3034 (merged).
The bump uses bundle lock --update gitlab-orbit-proto --cooldown 0, because 0.156.0 is our own first-party release from gitlab-org/orbit/knowledge-graph!3034 (merged) and is younger than the 7-day Bundler cooldown.
SQL queries
itemCounts runs the same number of SQL queries for 2 and 6 groups. For projects, itemCounts adds no SQL queries to a plain query for 2 or 6 projects. The specs check both cases.
References
Related to gitlab-org/orbit/knowledge-graph#263
- Design: Orbit graph status in GraphQL.
- Orbit change: gitlab-org/orbit/knowledge-graph!3034 (merged). It has the count query timings.
- Token scopes, merged: !264673 (merged).
- Stack: this MR, !264744 (closed) (frontend), !264745 (merged) (REST removal).
Screenshots or screen recordings
This MR has no UI change. The frontend MR !264744 (closed) has the screenshots.
How to set up and validate locally
These numbers are for one overview page load with 50 groups on a GDK with the Orbit change.
| REST, per group | GraphQL, batched | |
|---|---|---|
| Count gRPC calls | 50 | 1 |
| ClickHouse count queries | 50 | 50, one per group |
The REST and GraphQL counts are equal for all 50 groups.
-
Send this query as a user with 2 or more groups that have Orbit turned on:
{ orbit { memberGroups(enabled: true, first: 50) { nodes { orbit { indexing { lastCompletedAt } itemCounts { domains { name entities { name count } } } } } } } } -
Make sure that the Orbit log has one
GetItemCountscall.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.