Paginate Grants() to fix gRPC ResourceExhausted on large datasets#42
Open
c1-dev-bot[bot] wants to merge 1 commit into
Open
Paginate Grants() to fix gRPC ResourceExhausted on large datasets#42c1-dev-bot[bot] wants to merge 1 commit into
c1-dev-bot[bot] wants to merge 1 commit into
Conversation
The Grants() function returned all grants for a resource in a single gRPC response. When the grant count is large (e.g. 77,000 direct grants), the serialized response exceeds the baton-sdk's default 4MB MaxRecvMsgSize limit, causing ResourceExhausted. Add offset-based pagination with a default page size of 1000 grants. The SDK's requested page size is respected when provided. This follows the established connector-side pagination pattern from CXH-1255. Fixes: CXH-1552
Contributor
Connector PR Review: Paginate Grants() to fix gRPC ResourceExhausted on large datasetsBlocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0 Review SummaryThis PR adds offset-based pagination to Security IssuesNone found. Correctness IssuesNone found. SuggestionsNone. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Grants()inpkg/connector/resources.goto prevent gRPCResourceExhaustederrors when a resource has a large number of grantsDetails
The
Grants()function previously returned all grants for a resource in a single gRPC response with no pagination. When a file contains ~77,000 direct grants, the serialized response (5.66MB) exceeds the baton-sdk's default 4MBMaxRecvMsgSizelimit.The fix uses simple offset-based pagination on the already-sorted in-memory grants slice:
PageToken.Tokenis empty), starts at offset 0pageSizegrants per callNextPageTokento the next offset when more grants remainNextPageTokenwhen all grants have been returnedThis approach is appropriate for baton-file because all data is already loaded into memory from the file — we're only paginating the gRPC response, not the data loading.
Test plan
Fixes: CXH-1552
Automated PR Notice
This PR was automatically created by c1-dev-bot as a potential implementation.
This code requires: