JHSUYU opened a new pull request, #4820:
URL: https://github.com/apache/solr/pull/4820

   SOLR-18406: Restart replication after index generation expires
   
     # Description
   
   During leader/follower index replication, the follower first requests the 
file list for generation G and then downloads the files using separate 
`filecontent` requests.
   
   If the reservation for G expires before a file download starts, and a  
leader commit removes G `DirectoryFileStream.initWrite()` attempts to save the 
stale commit point and throws an `IllegalStateException`. This was returned as 
HTTP 500.
   
    The existing `filelist` path already handles the same condition as an 
invalid index generation, but the `filecontent` path did not.
   
     # Solution
   
     Convert the stale-generation failure in `DirectoryFileStream.initWrite()` 
into an explicit HTTP 409 conflict with an `invalid index generation` message.
   
   When `IndexFetcher` receives this response, it stops retrying the same file 
from the already unavailable generation and restarts the complete replication 
cycle once, beginning with a new `indexversion` request. This allows the 
follower to fetch the leader's current generation instead of failing the entire 
replication attempt.
   
    The change also ensures that a commit point is only reserved and released 
when it was successfully saved.
   
     # Tests
   
     Added
     
`TestReplicationHandler.testFollowerRestartsWhenCommitExpiresBeforeFileDownload
     `.
   
     The test uses real leader and follower Jetty instances and performs this 
sequence:
   
     1. The leader commits generation G.
     2. The follower starts an explicit `fetchindex` request.
     3. The follower pauses after receiving `filelist(G)` and before requesting
        `filecontent(G)`.
     4. The commit reservation expires.
     5. The leader commits G+1, allowing G to be deleted.
     6. The follower resumes, detects that G is unavailable, restarts 
replication, and installs G+1.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to