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

[Backport stable/8.0] Make gRPC response sender thread-safe #361

Merged
merged 9 commits into from
May 12, 2022

Conversation

github-actions[bot]
Copy link

Description

Backport of #358 to stable/8.0.

relates to #349

The GatewayRequestStore is a utility class that will be used by the GrpcToLogStreamGateway and the GrpcResponseWriter to share request between the two of them. The GrpcToLogStreamGateway will store new requests in here. The GrpcResponseWriter will take these requests out and write the correct response to the correct request.

This store has to be thread-safe. Because of this we are using a ConcurrentHashMap as well as an AtomicLong

(cherry picked from commit 95bd731)
The single threaded executor was causing issues in combination with the GrpcResponseWriter. The response was send in a different thread from where the request was received. Since the writer reuses a DirectBuffer to store the record this could result in the buffer being modified by a thread, whilst the response was still being send in the single executor thread.

(cherry picked from commit e782635)
Incoming requests need to be stored in the new GatewayRequestStore so the GrpcResponseWriter will be able to access them.

(cherry picked from commit 8d29f4f)
The GrpcResponseWriter used to do all the mapping of the responses. This should not be the responsibility of this class. It should only be responsible for writing the responses to the correct requests.

The mapping itself has now been extracted into a separate GrpcResponseMapper class.

(cherry picked from commit a6ff9d6)
We now use the GrpcResponseMapper to map the valueBufferView to a proper rpc response. The sending of the responses has been relocated to the GrpcResponseWriter as it is the responsibility of this class.

(cherry picked from commit 4d7b440)
Creates the GatewayRequestStore and makes it available in the GrpcResponseWriter and the GrpcToLogStreamGateway.

(cherry picked from commit 879ecbc)
Every command will now create its own RecordMetadata. This ensures the thread-safety of this class.

(cherry picked from commit 51a917a)
Add javadoc to shortly describe why there is a GatewayRequestStore

(cherry picked from commit acaa2a8)
The GrpcToLogStreamGateway should not have to worry about any concurrency issues. By extracting the command writing to a separate class we have this logic isolated.

(cherry picked from commit 40b73c1)
@remcowesterhoud remcowesterhoud self-requested a review May 12, 2022 14:39
@remcowesterhoud remcowesterhoud merged commit 5b35a1c into stable/8.0 May 12, 2022
@remcowesterhoud remcowesterhoud deleted the backport-358-to-stable/8.0 branch May 12, 2022 14:39
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.

1 participant