ivandika3 opened a new pull request, #1723:
URL: https://github.com/apache/ratis/pull/1723

   ## What changes were proposed in this pull request?
   
   Generated-by: GPT 6.1 Sol
   
   See https://issues.apache.org/jira/browse/RATIS-2844
   
   In short, the main issue is that two sliding window client: Leader client 
window ("RAFT" window)  and explicit client window ("server ID" window) share 
the same underlying ordered stream `AsyncStreamObservers` which means two 
sliding window clients share the same sliding window server. This causes issues 
since each sliding window client manages its own sequence number and the 
sliding window server will keep track of the sequence number sent by the 
clients and only will process the request from the last sequence number + 1 
(i.e. nextToProcess) or if it's the first request.
   
   Visually
   
   ```
   Before:
   Leader client window ──┐
                          ├─ One ordered stream → One server window
   Explicit client window ┘
   ```
   
   The test reproduces the issue by using the following client call
   
   ```
   client.async().send(INCREMENT);
   client.async().sendReadOnly(QUERY, leaderId);
   ```
   
   You can see from the following table that this causes request
   
   Request | Client window | Sequence number | Shared server window
   -- | -- | -- | --
   Initial dummy request | Leader | 1 | Processes it; expects 2
   Increment | Leader | 2 | Processes it; expects 3
   Explicit-target dummy request | Explicit server | 1 | Cannot advance 
processing
   
   This is because the `client.async().sendReadOnly(QUERY, leaderId)` will send 
with sequenceNum 1 for its dummy / connection bootstrap request, but the server 
already sees sequenceNum 1 and ignores it so the 
`client.async().sendReadOnly(QUERY, leaderId)` will timeout.
   
   So the main invariant is is that one ClientWindow should have a single 
exclusive ServerWindow. The solution to have two separate StreamObservers so 
that one ClientWindow has a corresponding exclusive ServerWindow.
   
   Netty should not be affected for now since NettyRpcService doesn't use 
ServerWindow and processes the calls in a sequential manner. In the future we 
can support real asynchronous processing in Netty.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/RATIS-2844
   
   ## How was this patch tested?
   
   UT.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to