[DB-1849] Support forwarding of multi-stream writes to the leader#5459
[DB-1849] Support forwarding of multi-stream writes to the leader#5459timothycoleman merged 4 commits intomasterfrom
Conversation
ace3009 to
06c8b9f
Compare
06c8b9f to
e00cef0
Compare
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
e00cef0 to
c1ac8c3
Compare
c48b66c to
198a088
Compare
User description
Changed: Support forwarding of multi-stream writes to the leader
#5437 uses a multi-stream append to write to two different streams when creating a user index. Trying to create a user index on a follower node through the HTTP API would result in the following error as multi-stream writes are currently not forwarded to the leader:
This PR adds support for forwarding of multi-stream writes to the leader through the TCP API.
Note that the change is not forward compatible - thus trying to forward a multi-stream write from a new version of a follower to an old version of the leader will result in this (benign) error:
Auto-created Ticket
#5460
PR Type
Enhancement
Description
Add TCP protocol support for multi-stream write forwarding to leader
Implement authorization checks for multi-stream write operations
Add new TcpCommand types for multi-stream write requests/responses
Remove restriction preventing multi-stream writes on follower nodes
Diagram Walkthrough
File Walkthrough
TcpClientMessageDto.cs
Add multi-stream write message constructorssrc/KurrentDB.Core/Messages/TcpClientMessageDto.cs
WriteEventsMultiStreamDTO to initialize streamIDs, expected versions, events, stream indexes, and leader requirement
flag
WriteEventsMultiStreamCompletedDTO to initializeresult, event numbers, positions, and failure information
AuthorizationGateway.cs
Implement multi-stream write authorizationsrc/KurrentDB.Core/Services/AuthorizationGateway.cs
Authorize(WriteEvents)methodAuthorizeManymethod to sequentially check authorization for eachstream in multi-stream writes
AuthorizeManyAsyncmethod to handle asynchronous authorizationchecks across multiple streams
System.Collections.GenericnamespaceClientWriteTcpDispatcher.cs
Add multi-stream write TCP serialization supportsrc/KurrentDB.Core/Services/Transport/Tcp/ClientWriteTcpDispatcher.cs
UnwrapWriteEventsMultiStreammethod to deserialize multi-streamwrite requests from TCP packages
UnwrapWriteEventsMultiStreamCompletedmethod to deserializemulti-stream write responses
WrapWriteEventsto handle both single-stream and multi-streamwrites with appropriate DTO types
WrapWriteEventsCompletedinto separate methods for single-streamand multi-stream responses
WriteEventsMultiStreamandWriteEventsMultiStreamCompletedTCP commandsTcpCommand.cs
Define new TCP command typessrc/KurrentDB.Core/Services/Transport/Tcp/TcpCommand.cs
WriteEventsMultiStream = 0x8Ccommand type for multi-stream writerequests
WriteEventsMultiStreamCompleted = 0x8Dcommand type formulti-stream write responses
ClientMessageDtos.proto
Define multi-stream write protobuf messagessrc/Protos/ClientAPI/ClientMessageDtos.proto
WriteEventsMultiStreamprotobuf message with stream IDs, expectedversions, events, stream indexes, and leader flag
WriteEventsMultiStreamCompletedprotobuf message with result,event numbers, positions, and failure tracking
ClusterVNodeController.cs
Remove multi-stream write forwarding restrictionsrc/KurrentDB.Core/Services/VNode/ClusterVNodeController.cs
HandleAsNonLeadermethodRequireLeaderflag, allowingmulti-stream writes to be forwarded