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 write inconsistency in the gRPC implementation #990

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

singhravidutt
Copy link
Contributor

Refactored gRPC write channel. Major changes

  1. Created GoogleCloudStorageContentWriteStream which manages a single writeObject stream.
  2. Refactored FakeService(gcs) in GoogleCloudStorageContentWriteStreamTest to support more usecases like
    • Exception during onCompleted.
    • WriteObjectResponse being prepared based on object is in finialized state or not.
    • Added test case to verify the retry logic of stream faiure during commit.
    • WriteStatus API call no longer needs overriden with static value instead fetched state maintained in fakeService.
    • etc.
  3. Added unit test class GoogleCloudStorageContentWriteStream to test the various behaviour of resumable writeObject stream.

@singhravidutt
Copy link
Contributor Author

/gcbrun

@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Attention: Patch coverage is 82.44681% with 33 lines in your changes missing coverage. Please review.

Project coverage is 82.44%. Comparing base (998eb64) to head (2633c62).
Report is 71 commits behind head on master.

Files with missing lines Patch % Lines
...op/gcsio/GoogleCloudStorageContentWriteStream.java 82.14% 23 Missing and 2 partials ⚠️
...doop/gcsio/GoogleCloudStorageGrpcWriteChannel.java 83.33% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #990      +/-   ##
============================================
+ Coverage     76.73%   82.44%   +5.71%     
- Complexity     1640     1796     +156     
============================================
  Files           101      102       +1     
  Lines          7935     8027      +92     
  Branches        990      996       +6     
============================================
+ Hits           6089     6618     +529     
+ Misses         1409     1009     -400     
+ Partials        437      400      -37     
Flag Coverage Δ
integrationtest 67.18% <55.85%> (?)
unittest 76.87% <80.85%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@singhravidutt singhravidutt marked this pull request as ready for review April 4, 2023 04:49
: false;
}

public WriteObjectResponse closeStream() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want this class to implement closeable java interface?

protected static final ImmutableSet<Code> TRANSIENT_ERRORS =
ImmutableSet.of(
Status.Code.DEADLINE_EXCEEDED,
Status.Code.INTERNAL,
Copy link
Contributor

Choose a reason for hiding this comment

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

should we really retry in this case?


// Wait for streaming RPC to become ready for upload.
// wait for 1 min for the channel to be ready. Else bail out
if (!responseObserver.ready.await(60 * 1000, MILLISECONDS)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why one minute? Should we make this configurable.

channelOptions.getGrpcWriteMessageTimeout()));

} catch (IOException e) {
throw e;
Copy link
Contributor

Choose a reason for hiding this comment

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

why even catching?

}
}

public void writeChunk(WriteObjectRequest request) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

why this need to be public?

if (TRANSIENT_ERRORS.contains(statusCode)) {
transientError = t;
}
if (transientError == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not have else?

}

public boolean isComplete() {
return done.getCount() == 0 ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

just return?

}

public boolean isReady() {
return ready.getCount() == 0 ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

}

public boolean isComplete() {
return done.getCount() < 1 ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

just return?


@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

We avoid using mocks in connector. Do we really need to use mocks?

@medb medb changed the title fixed write inconsistency in gRPC implementation Fix write inconsistency in the gRPC implementation Apr 5, 2023
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