Fix ListQueues: iterator leak, unbounded CQL round-trips, and PageState after Close - #9523
Fix ListQueues: iterator leak, unbounded CQL round-trips, and PageState after Close#9523mykaul wants to merge 1 commit into
Conversation
Code reviewFound 1 issue:
🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
b6fdcdb to
23493b7
Compare
Fixed with the first option: |
45da0de to
3910aa8
Compare
v2 — Review feedback addressed + additional fixesReview comments addressed:
Additional fixes found during implementation:
Rebased on origin/main, squashed into a single commit. |
Reviewers - take a note of the above please. |
|
ping - is there anything I need to do to move this fix forward? |
rodrigozhou
left a comment
There was a problem hiding this comment.
The PR lgtm.
Just wondering if there's any place that assumes the function would return all task queues. Since your changes you limit to 10k, it could potentially break something.
cc: @dnr
| return nil, gocql.ConvertError("QueueV2ListQueues", err) | ||
| } | ||
| if len(pageToken) == 0 { | ||
| if pageToken == nil { |
There was a problem hiding this comment.
Is this different from len(pageToken) == 0?
3910aa8 to
3be6b22
Compare
OK, reverted this 10K, now just using paging. |
- Set explicit PageSize for Cassandra queue ReadMessages queries - Fix iterator leak and add round-trip cap in ListQueues - Fix GetTaskQueuesByBuildId: recreate iterator per page with PageState - Don't discard iter.Close() errors; use errors.Join on early-return paths - Capture PageState before Close (Close invalidates page state) - Add ORDER BY + LIMIT 10000 to SQL backends for consistent truncation
3be6b22 to
79e4d67
Compare
|
Updated PR description! |
What changed?
PageSizefor Cassandra/Scylla queue reads.GetTaskQueuesByBuildIdto recreate iterators withPageStateand consume all pages. There is no artificial 10,000-result cap.ListQueuespaging for under-filledALLOW FILTERINGpages, while bounding each request to 10 CQL round-trips and returningNextPageTokenwhen more results remain.PageStatebefore closing iterators.ListQueuesresult slice.Why?
Cassandra/Scylla can return under-filled pages for
ALLOW FILTERINGqueries, so a single CQL page does not necessarily satisfy the requested page size. Manual page traversal must also preserve the page token before iterator close. Iterator errors must not leak resources or be discarded.Validation
TestCassandraTaskQueueUserDataSuiteTestCassandraQueueV2Persistencemake lint-codeThe 10-page
ListQueuesbound is intentional because that API is paginated;GetTaskQueuesByBuildIdremains unbounded and returns all mappings as required by its API contract.