Skip to content

ARROW-6063: [FlightRPC] implement half-closed semantics for DoPut#5196

Closed
ghost wants to merge 6 commits intomasterfrom
unknown repository
Closed

ARROW-6063: [FlightRPC] implement half-closed semantics for DoPut#5196
ghost wants to merge 6 commits intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Aug 26, 2019

Implements ARROW-6063 for C++/Python. In C++, gRPC reads are not thread-safe with respect to each other, but in DoPut, closing the writer (which was the only way for the client to indicate that it was done writing) would also execute reads (to prevent gRPC from hanging due to unread messages). This meant there was no way to asynchronously read application metadata during a DoPut.

By explicitly introducing a "done writing" operation, the server can be notified that the client is done writing and shut down its side of the call, which then unblocks the read side of the client. This lets us run a background thread on the client to read from the channel, and block closing the reader/writer until the background thread is unblocked (by the server closing its side of the call).

Longer term, the "right" solution is to introduce nonblocking/asynchronous operations in Flight.

Personal Travis: https://travis-ci.com/lihalite/arrow/builds/124584278

Copy link
Copy Markdown
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

Sounds good to me on the principle.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm... why segfault? Isn't this something that we can detect and prevent programmatically? (raise an error if reading from a stream whose writer side was closed)

Copy link
Copy Markdown
Author

@ghost ghost Aug 27, 2019

Choose a reason for hiding this comment

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

Segfault is the wrong word, I'll clarify this - gRPC aborts if it sees an internal state it didn't expect. (Personally I think this is rather dumb, since it's fairly easy to cause, even just by accidentally calling certain methods twice or concurrently.)

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 27, 2019

Rebased/addressed comments. Personal Travis: https://travis-ci.com/lihalite/arrow/builds/124741965

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, and should this count of number of metadata items received? I assume it should be equal to the number of batches written, so we could check that after joining the reader.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point - I'll improve the test.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Aug 27, 2019

Codecov Report

Merging #5196 into master will increase coverage by 1.56%.
The diff coverage is 93.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5196      +/-   ##
==========================================
+ Coverage   87.64%   89.21%   +1.56%     
==========================================
  Files        1033      750     -283     
  Lines      148463   107623   -40840     
  Branches     1437        0    -1437     
==========================================
- Hits       130118    96014   -34104     
+ Misses      17983    11609    -6374     
+ Partials      362        0     -362
Impacted Files Coverage Δ
cpp/src/arrow/flight/client.h 100% <ø> (ø) ⬆️
python/pyarrow/tests/test_flight.py 71.76% <100%> (+1.16%) ⬆️
cpp/src/arrow/flight/flight_test.cc 98.05% <100%> (ø) ⬆️
python/pyarrow/_flight.pyx 54.1% <100%> (+0.3%) ⬆️
cpp/src/arrow/flight/internal.cc 81.34% <100%> (+0.09%) ⬆️
cpp/src/arrow/flight/client.cc 91.81% <85.71%> (-0.32%) ⬇️
js/src/util/fn.ts
go/arrow/memory/memory_avx2_amd64.go
rust/datafusion/src/execution/filter.rs
rust/arrow/src/csv/writer.rs
... and 282 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 beea8f9...796f155. Read the comment docs.

Copy link
Copy Markdown
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

LGTM on the principle. A couple nits.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use std::make_shared.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The std::move here is pointless. C++ will move temporaries automatically.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you can write auto values = batch.data->column_data(0)->GetValues<int64_t>(1).

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 29, 2019

Thanks for the review! Fixed those concerns & rebased.

Copy link
Copy Markdown
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

+1, thank you!

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