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

fix(common): revamp the async polling loop #7762

Merged
merged 1 commit into from
Dec 19, 2021

Conversation

devbww
Copy link
Contributor

@devbww devbww commented Dec 19, 2021

  • Do not drop a cancellation request made before we receive
    the longrunning::Operation.

    Instead, remember that a cancellation request was made,
    and then cancel the operation once we know it has started.

    This (probabilistically) saves a significant chunk of time
    in the spanner_cancel_backup_create sample, as we now
    always cancel the CreateBackup().

  • Do not fabricate a cancelled Status.

    The only way we really know an operation has been cancelled
    is by examining the GetOperation() response.


This change is Reviewable

* Do not drop a cancellation request made before we receive
  the `longrunning::Operation`.

  Instead, remember that a cancellation request was made,
  and then cancel the operation once we know it has started.

  This (probabilistically) saves a significant chunk of time
  in the `spanner_cancel_backup_create` sample, as we now
  always cancel the `CreateBackup()`.

* Do not fabricate a cancelled `Status`.

  The only way we really know an operation has been cancelled
  is by examining the `GetOperation()` response.
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: 71b5be9d94f38f628c5a624a6c9b093dbfc10d29

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@codecov
Copy link

codecov bot commented Dec 19, 2021

Codecov Report

Merging #7762 (71b5be9) into main (4da3051) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7762      +/-   ##
==========================================
- Coverage   95.15%   95.15%   -0.01%     
==========================================
  Files        1271     1271              
  Lines      114603   114633      +30     
==========================================
+ Hits       109054   109082      +28     
- Misses       5549     5551       +2     
Impacted Files Coverage Δ
...golden/tests/golden_thing_admin_connection_test.cc 99.57% <100.00%> (ø)
...loud/internal/async_long_running_operation_test.cc 97.72% <100.00%> (+0.03%) ⬆️
google/cloud/internal/async_polling_loop.cc 100.00% <100.00%> (ø)
google/cloud/internal/async_polling_loop_test.cc 100.00% <100.00%> (ø)
...e/cloud/spanner/testing/cleanup_stale_instances.cc 61.29% <0.00%> (-19.36%) ⬇️
google/cloud/bigtable/internal/common_client.h 94.02% <0.00%> (-5.98%) ⬇️
...le/cloud/spanner/database_admin_connection_test.cc 99.70% <0.00%> (+0.49%) ⬆️
.../cloud/storage/benchmarks/throughput_experiment.cc 74.87% <0.00%> (+0.50%) ⬆️
...le/cloud/internal/default_completion_queue_impl.cc 97.72% <0.00%> (+0.56%) ⬆️
... and 1 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 4da3051...71b5be9. Read the comment docs.

@devbww devbww marked this pull request as ready for review December 19, 2021 07:03
@devbww devbww requested a review from a team as a code owner December 19, 2021 07:03
@devbww devbww merged commit b2fe267 into googleapis:main Dec 19, 2021
@devbww devbww deleted the heed-early-cancelation branch December 19, 2021 17:10
devbww added a commit to devbww/google-cloud-cpp that referenced this pull request Apr 6, 2022
Do not fabricate a deadline-exceeded `Status` when the polling policy
says enough is enough.  That left the operation in an unknowable state.
Rather, cancel the operation and wait for the next poll to yield us an
accurate status (which may end up being OK).

That is, a polling limit is really a request for auto-cancellation.

(See googleapis#7762 for the part-un work on ensuring an explicit cancel yielded an
accurate status.)

In the case of the Spanner backup tests, for example, this means we can do
something meaningful after hitting the poll limit of a `CreateBackup()`
call, as we'll know that the backup is no longer pending.

Update the poll-loop mocking tests to account for the new sequence of RPCs.
devbww added a commit to devbww/google-cloud-cpp that referenced this pull request Apr 14, 2022
Do not fabricate a deadline-exceeded `Status` when the polling policy
says enough is enough.  That left the operation in an unknowable state.
Rather, cancel the operation and wait for the next poll to yield us an
accurate status (which may end up being OK).

That is, a polling limit is really a request for auto-cancellation.

(See googleapis#7762 for the part-un work on ensuring an explicit cancel yielded an
accurate status.)

In the case of the Spanner backup tests, for example, this means we can do
something meaningful after hitting the poll limit of a `CreateBackup()`
call, as we'll know that the backup is no longer pending.

Update the poll-loop mocking tests to account for the new sequence of RPCs.
devbww added a commit to devbww/google-cloud-cpp that referenced this pull request Apr 14, 2022
Do not fabricate a deadline-exceeded `Status` when the polling policy
says enough is enough.  That left the operation in an unknowable state.
Rather, cancel the operation and wait for the next poll to yield us an
accurate status (which may end up being OK).

That is, a polling limit is really a request for auto-cancellation.

(See googleapis#7762 for the part-un work on ensuring an explicit cancel yielded an
accurate status.)

In the case of the Spanner backup tests, for example, this means we can do
something meaningful after hitting the poll limit of a `CreateBackup()`
call, as we'll know that the backup is no longer pending.

Update the poll-loop mocking tests to account for the new sequence of RPCs.
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.

3 participants