Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

fix:shutdown stuck when there is error on the flush path#831

Merged
stephaniewang526 merged 2 commits intogoogleapis:masterfrom
yirutang:fix1
Feb 16, 2021
Merged

fix:shutdown stuck when there is error on the flush path#831
stephaniewang526 merged 2 commits intogoogleapis:masterfrom
yirutang:fix1

Conversation

@yirutang
Copy link
Copy Markdown
Contributor

…l to release the requests in the queue, causing shutdown to wait forever

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

…l to release the requests in the queue, causing shutdown to wait forever
@yirutang yirutang requested review from a team and tswast February 16, 2021 19:19
@product-auto-label product-auto-label bot added the api: bigquerystorage Issues related to the googleapis/java-bigquerystorage API. label Feb 16, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Feb 16, 2021
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 16, 2021

Codecov Report

Merging #831 (d1c2ecf) into master (94c7848) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #831      +/-   ##
============================================
+ Coverage     81.10%   81.14%   +0.04%     
  Complexity      996      996              
============================================
  Files            74       74              
  Lines          5346     5347       +1     
  Branches        415      415              
============================================
+ Hits           4336     4339       +3     
+ Misses          839      838       -1     
+ Partials        171      170       -1     
Impacted Files Coverage Δ Complexity Δ
...e/cloud/bigquery/storage/v1beta2/StreamWriter.java 85.03% <100.00%> (+0.44%) 38.00 <0.00> (ø)

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 94c7848...a04598a. Read the comment docs.

@stephaniewang526 stephaniewang526 merged commit c2fd750 into googleapis:master Feb 16, 2021
public void onError(Throwable t) {
LOG.fine("OnError called");
if (streamWriter.shutdown.get()) {
abortInflightRequests(t);
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.

There are two more issues:

  1. Even if you abort the inflight request here, the shutdown can still add more requests through writeAllOutstanding();
  2. Besides, it is also possible that another thread is calling append, and will contribute another stuck request at https://screenshot.googleplex.com/7pmsyb2zyKDEaGF


ApiFuture<AppendRowsResponse> appendFuture1 = sendTestMessage(writer, new String[] {"A"});
ApiFuture<AppendRowsResponse> appendFuture2 = sendTestMessage(writer, new String[] {"B"});
Thread.sleep(5000L);
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.

What is this for?

Thread.sleep(5000L);
fakeExecutor.advanceTime(Duration.ofSeconds(20));
// Shutdown writer immediately and there will be some error happened when flushing the queue.
writer.shutdown();
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.

I don't understand this. You advance the time before shutdown. So even in the old code path before your fix, you can reduce the only inflight requests in the queue and unblock. Will this unit test block before your fix?

Please think carefully how to write a unit test.

@yirutang yirutang deleted the fix1 branch February 18, 2021 00:10
shubhwip pushed a commit to shubhwip/java-bigquerystorage that referenced this pull request Oct 7, 2023
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquerystorage Issues related to the googleapis/java-bigquerystorage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants