eBay / nuraft_mesg

A session management and gRPC service layer for NuRaft.
Apache License 2.0
6 stars 11 forks source link

Fall back to the Dump method (which copies) when the grpc::ByteBuffer.TrySingleSlice fails #43

Closed raakella1 closed 8 months ago

raakella1 commented 8 months ago

To deserialize the ByteBuffer at the receiver side of the GRPC generic service, we use the method TrySingleSlice which gives us the reference to the underlying buffer. This only works if the underlying buffer is made up of a single slice. GRPC doesn't guarantee that the buffer we receive is always made up of a single slice. (On average, this issue causes the unit test to fail in every 5 to 10 runs) The fix in this PR falls back to using the method DumpToSingleSlice which gives us a copy of the underlying buffer. The downside to this is that we incur an additional copy. We need to revisit this when we are doing a performance analysis and see if this becomes a bottleneck.

The unit test passes consistently with this fix.

codecov-commenter commented 8 months ago

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (8066124) 76.95% compared to head (5a66685) 76.36%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #43 +/- ## ========================================== - Coverage 76.95% 76.36% -0.59% ========================================== Files 20 20 Lines 820 825 +5 Branches 91 93 +2 ========================================== - Hits 631 630 -1 - Misses 132 136 +4 - Partials 57 59 +2 ``` | [Files](https://app.codecov.io/gh/eBay/nuraft_mesg/pull/43?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eBay) | Coverage Δ | | |---|---|---| | [src/lib/utils.hpp](https://app.codecov.io/gh/eBay/nuraft_mesg/pull/43?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eBay#diff-c3JjL2xpYi91dGlscy5ocHA=) | `73.07% <25.00%> (-17.40%)` | :arrow_down: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/eBay/nuraft_mesg/pull/43/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eBay)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.