Skip to content
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

Impl subscribe subcommand & subscription smoketests #1343

Merged
merged 7 commits into from
Jun 14, 2024

Conversation

coolreader18
Copy link
Collaborator

Description of Changes

Pending proposal acceptance

Expected complexity level and risk

2

@coolreader18 coolreader18 force-pushed the noa/subscribe-subcommand branch from ab7bd8f to fa755cb Compare June 5, 2024 23:48
@coolreader18 coolreader18 requested a review from Centril June 6, 2024 00:37
@coolreader18 coolreader18 force-pushed the noa/subscribe-subcommand branch from fa755cb to a134c4d Compare June 7, 2024 17:31
@coolreader18 coolreader18 force-pushed the noa/subscribe-subcommand branch from a134c4d to f09b53d Compare June 7, 2024 17:55
@coolreader18 coolreader18 marked this pull request as ready for review June 7, 2024 20:20
@bfops bfops added the release-any To be landed in any release window label Jun 10, 2024
Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

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

First 2/3 of review

@@ -331,16 +345,21 @@ where
.get_or_launch_module_host(database, instance_id)
.await
.map_err(log_and_500)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

From let address to here, this code is shared with fn describe. If we deduplicated, this would help towards a separate endpoint.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can do this in a follow up.

Comment on lines +50 to +52
"The timeout, in seconds, after which to disconnect and stop receiving \
subscription messages. If `-n` is specified, it will stop after whichever
one comes first.",
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a workable alternate semantics.

Note to self: change to this in the proposal.

.insert(header::AUTHORIZATION, auth_header.try_into().unwrap());
}
let (mut ws, _) = tokio_tungstenite::connect_async(req).await?;

Copy link
Contributor

Choose a reason for hiding this comment

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

How does this account for the request_id received matching the default we sent?

Copy link
Contributor

Choose a reason for hiding this comment

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

Did we send one?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't send one explicitly, but the server/host will interpret not sending one explicitly as request_id: 0 (serde does this for us).

Copy link
Contributor

Choose a reason for hiding this comment

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

But what is the significance of it? Ensure that the server did not send us anything we didn't ask for?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah pretty much, and so that we don't print it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Uh, I'm not sure I understand what you're asking for.

The SubscriptionUpdate sent by the server contains two additional fields besides the table updates:

  • uint32 requestId
  • uint64 total_host_execution_duration_micros

However, neither of them is documented nor well-specified (arguably).

So I'd argue that it is reasonable to not surface this to users unless and until stabilized.

Copy link
Contributor

@Centril Centril Jun 14, 2024

Choose a reason for hiding this comment

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

So I'd argue that it is reasonable to not surface this to users unless and until stabilized.

That's fair 👍
I'll update the proposal accordingly later on.

@@ -96,11 +97,13 @@ def extract_field(cmd_output, field_name):
field, = extract_fields(cmd_output, field_name)
return field
Copy link
Contributor

Choose a reason for hiding this comment

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

The diff here isn't something I understood to a degree where I can approve, so let's have someone better at python review the changes here.

match msg {
ServerMessage::SubscriptionUpdate(sub) => {
if print_initial_update {
let output = serde_json::to_string(&sub.reformat(&module_def)?)? + "\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

We should print in the same format as the spacetime sql subcommand, not as JSON.

Copy link
Contributor

@Centril Centril Jun 11, 2024

Choose a reason for hiding this comment

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

For the smoketests it is convenient to receive this as JSON, so perhaps we should add a --format to both sql and subscribe which accepts json, bsatn, and plain where the default is plain and formats as sql currently does.

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems broadly sensible. I'm not sure there's utility to the bsatn format, and I would name the current/default format table, not plain, but I think you're right that we should offer at least both of JSON and tabular output. I would also like to be careful that we use the same code for formatting in both subcommands so that we get the same format.

Copy link
Contributor

Choose a reason for hiding this comment

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

Happy to skip bsatn for now until there is utility.
And I like table -- calling these --format table | json seems sensible as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note: this is slightly less trivial than expected. Because:

  • the transaction updates contain deleted and inserted rows, which arguably is information we want to preserve
  • the subscription update supposedly only contains inserts -- but why would we format the subscription update differently from the transaction updates?
  • both of the updates refer to several tables, but it's not obvious how to display that (i.e. add some kind of "title" to a table)

What could work is to render one table per update, where the rows get two additional columns "table_name STRING" and "op ENUM('I', 'D')".

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll submit this as a follow-up.

Co-authored-by: Mazdak Farrokhzad <[email protected]>
Signed-off-by: Kim Altintop <[email protected]>
Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

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

All the .rs stuff looks good to me

@kim kim enabled auto-merge June 14, 2024 09:07
@kim kim added this pull request to the merge queue Jun 14, 2024
Merged via the queue into master with commit 66112bb Jun 14, 2024
7 checks passed
@kim kim deleted the noa/subscribe-subcommand branch June 14, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-any To be landed in any release window
Projects
None yet
5 participants