Skip to content

Conversation

@devbww
Copy link
Contributor

@devbww devbww commented Mar 24, 2021

Support the marking of requests with a relative priority of high,
medium, or low. This acts as a hint to the Cloud Spanner scheduler,
and does not actually guarantee priority or order of execution.
If unspecified, the priority defaults to high.

Introduce the google::cloud::spanner::RequestPriority enum, and
add one as an optional field to CommitOptions, QueryOptions,
and ReadOptions, with builder-pattern support where applicable.

CommitOptions can already be applied to Client::Commit(), and
ReadOptions to Client::Read() and PartitionRead().

QueryOptions can already be applied to Client::ExecuteQuery(),
ProfileQuery(), ExecuteDml(), ProfileDml(), and AnalyzeSql(),
but here it is also added to Client::ExecuteBatchDml() and
ExecutePartitionedDml().


This change is Reviewable

@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Mar 24, 2021
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 24, 2021
@codecov
Copy link

codecov bot commented Mar 24, 2021

Codecov Report

Merging #6103 (631f939) into master (4755d7a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6103   +/-   ##
=======================================
  Coverage   95.67%   95.68%           
=======================================
  Files        1173     1173           
  Lines      104827   104889   +62     
=======================================
+ Hits       100298   100359   +61     
- Misses       4529     4530    +1     
Impacted Files Coverage Δ
google/cloud/spanner/client.h 100.00% <ø> (ø)
google/cloud/spanner/connection.h 100.00% <ø> (ø)
google/cloud/spanner/client.cc 97.15% <100.00%> (+0.03%) ⬆️
google/cloud/spanner/commit_options.h 100.00% <100.00%> (ø)
google/cloud/spanner/commit_options_test.cc 100.00% <100.00%> (ø)
google/cloud/spanner/internal/connection_impl.cc 93.73% <100.00%> (+0.22%) ⬆️
...gle/cloud/spanner/internal/connection_impl_test.cc 97.51% <100.00%> (+0.02%) ⬆️
google/cloud/spanner/query_options.h 100.00% <100.00%> (ø)
google/cloud/spanner/query_options_test.cc 100.00% <100.00%> (ø)
google/cloud/spanner/read_options.h 100.00% <100.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4755d7a...631f939. Read the comment docs.

@devbww devbww marked this pull request as ready for review March 24, 2021 08:04
@devbww devbww requested a review from a team as a code owner March 24, 2021 08:04
Copy link
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 15 of 15 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @devbww)

Transaction transaction, std::vector<SqlStatement> statements);
StatusOr<BatchDmlResult> ExecuteBatchDml(Transaction transaction,
std::vector<SqlStatement> statements,
QueryOptions const& opts = {});
Copy link
Contributor

Choose a reason for hiding this comment

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

Do other QueryOptions settings, like the optimizer version, make sense for these DML methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For ExecutePartionedDml(), yes, because it is implemented using ExecuteSqlRequest, which at least has space for optimizer_version. That said, I don't know whether optimizer_version actually applies in Partitioned DML mode.

But for ExecuteBatchDml(), no ... it is implemented using ExecuteBatchDmlRequest, which does not have space for optimizer_version.

The alternative seemed to be to introduce a new DmlOptions, with just priority, for at least ExecuteBatchDml() (and for ExecutePartitionedDml() if optimizer_version doesn't apply there). But that seemed counter to our new "options bucket" philosophy. Still, I'm happy either way (or some other way).

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't want to introduce a new options type, but perhaps using google::cloud::Options would make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. PTAL.

devbww added 2 commits March 30, 2021 03:53
Support the marking of requests with a relative priority of high,
medium, or low.  This acts as a hint to the Cloud Spanner scheduler,
and does not actually guarantee priority or order of execution.
If unspecified, the priority defaults to high.

Introduce the `google::cloud::spanner::RequestPriority` enum, and
add one as an optional field to `CommitOptions`, `QueryOptions`,
and `ReadOptions`, with builder-pattern support where applicable.

`CommitOptions` can already be applied to `Client::Commit()`, and
`ReadOptions` to `Client::Read()` and `PartitionRead()`.

`QueryOptions` can already be applied to `Client::ExecuteQuery()`,
`ProfileQuery()`, `ExecuteDml()`, `ProfileDml()`, and `AnalyzeSql()`,
but here it is also added to `Client::ExecuteBatchDml()` and
`ExecutePartitionedDml()`.
Don't add `QueryOptions` to `ExecuteBatchDml()`, where only the
request priority applies. Start using `google::cloud::Options`
instead. Other `spanner::Client` interfaces will be migrating in
that direction in the future.
@devbww devbww force-pushed the rpc-priority-merge branch from c2934f2 to 631f939 Compare March 30, 2021 07:53
@devbww devbww merged commit 50b28ca into googleapis:master Mar 30, 2021
@devbww devbww deleted the rpc-priority-merge branch March 30, 2021 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants