Skip to content

adapter: Consolidate the slow-path peek implementation - #39628

Open
ggevay wants to merge 4 commits into
gabor/peek-seq-04-log-timestamp-earlyfrom
gabor/peek-seq-05-merge-slow-path-peek
Open

ggevay wants to merge 4 commits into
gabor/peek-seq-04-log-timestamp-earlyfrom
gabor/peek-seq-05-merge-slow-path-peek

Conversation

@ggevay

@ggevay ggevay commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
  1. Merge implement_peek_plan into implement_slow_path_peek. The frontend implements fast-path and constant peeks itself, so the coordinator's implement_peek_plan only ever received slow-path plans. Its slow-path arm moves into implement_slow_path_peek. Its fast-path and constant arms and PlannedPeek are deleted. The statement-logging guard is created only once the peek is registered, so no error path has to defuse it.
  2. Move create_peek_response_stream to peek_client. It is a free function used by both the frontend fast path and the coordinator slow path, and touches no coordinator state. Pure move (git show --color-moved).
  3. Same for subscribes. implement_subscribe only runs for the frontend's ExecuteSubscribe command now, so it creates its statement-logging guard only for the Subscribing response, and the handler no longer defuses one on errors.

No behavior change intended.

🤖 Generated with Claude Code

@ggevay
ggevay added this pull request to stack #39631 October 7, 2026 10:30
@ggevay ggevay changed the title gabor/peek seq 05 merge slow path peek adapter: Consolidate the slow-path peek implementation Oct 7, 2026
@ggevay
ggevay force-pushed the gabor/peek-seq-05-merge-slow-path-peek branch from 4bf8c78 to 5843322 Compare October 7, 2026 13:13
@ggevay
ggevay force-pushed the gabor/peek-seq-05-merge-slow-path-peek branch from 5843322 to 39ec177 Compare October 8, 2026 13:18
@ggevay
ggevay marked this pull request as ready for review October 8, 2026 14:17
@ggevay
ggevay requested a review from a team as a code owner October 8, 2026 14:17
@ggevay
ggevay force-pushed the gabor/peek-seq-05-merge-slow-path-peek branch from 39ec177 to 1cf8bf8 Compare October 8, 2026 14:30
@ggevay
ggevay force-pushed the gabor/peek-seq-05-merge-slow-path-peek branch from 1cf8bf8 to c49ce29 Compare October 12, 2026 12:23

@aljoscha aljoscha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I had an inline comment about an outdated comment.

Also, I think the code currently is fine, but we're still duplicating some "peek" code in the coordinator now. Maybe a sketch of a fully unified implementation is that the frontend only does a "create dataflow" command or sth, and handle all the rest of peeking, same as it does for fast-path peeks?

Comment thread src/adapter/src/peek_client.rs Outdated
Comment on lines +1111 to +1114
// NOTE: Using the cursor creates Futures that are not Sync,
// so we can't drive them on the main Coordinator loop.
// Spawning a task has the additional benefit that we get to
// delete batches once we're done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is now outdated, we're not on the coordinator main loop anyways, at this point, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, fixed. The spawned task is still needed, but because ExecuteResponse::SendingRowsStreaming holds a Sync stream and the cursor's futures aren't Sync, and the comment now says that.

@ggevay
ggevay force-pushed the gabor/peek-seq-05-merge-slow-path-peek branch from c49ce29 to d495c0a Compare October 12, 2026 20:13
@ggevay
ggevay force-pushed the gabor/peek-seq-05-merge-slow-path-peek branch from d495c0a to b1d5551 Compare October 12, 2026 20:31
@ggevay
ggevay force-pushed the gabor/peek-seq-05-merge-slow-path-peek branch from b1d5551 to e0accd4 Compare November 10, 2026 15:53
@ggevay
ggevay force-pushed the gabor/peek-seq-05-merge-slow-path-peek branch from e0accd4 to a251be9 Compare November 10, 2026 16:51
@ggevay

ggevay commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Agreed. Your #39811 already moves the slow path's registration and retirement to the frontend, so issuing the peek from the frontend too fits there or right after it. That would also remove the coordinator's wait on the instance task that #39811 adds.

ggevay and others added 4 commits November 11, 2026 15:44
The frontend implements fast-path and constant peeks itself, so the
coordinator's `implement_peek_plan` only ever received slow-path plans from
`implement_slow_path_peek`. Fold its slow-path arm into
`implement_slow_path_peek`, delete its fast-path and constant arms and
`PlannedPeek`, and create the statement-logging guard only once the peek is
registered, so that no error path has to defuse it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It is a free function that both the frontend's fast path and the
coordinator's slow path use, and it touches no coordinator state. Move it to
`peek_client`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the coordinator no longer sequencing SUBSCRIBE, `implement_subscribe`
only runs for the frontend's `ExecuteSubscribe` command, so it no longer
needs to take an `ExecuteContext`'s guard by reference. Create the guard
where the `Subscribing` response is assembled, as `implement_slow_path_peek`
does for peeks, so that the `ExecuteSubscribe` handler has no error path
that has to defuse it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment on reading a stashed peek's batches still said the cursor's
non-Sync futures can't run on the coordinator loop, but the response stream is
now built on the session task. What requires the spawned task is the Sync
stream that `ExecuteResponse::SendingRowsStreaming` holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ggevay
ggevay force-pushed the gabor/peek-seq-05-merge-slow-path-peek branch from a251be9 to 5c5ec97 Compare November 11, 2026 14:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants