Indian-boult opened a new pull request, #20780:
URL: https://github.com/apache/hudi/pull/20780

   ### Describe the issue this Pull Request addresses
   
   Closes #18072
   
   With `hoodie.filesystem.view.remote.retry.enable=true`, the timeline client 
retries a marker creation request when it gets no response. If the timeline 
server had already created the marker, the retry finds it and gets `false`. 
`create()` then returns an empty option, which the rollback treats as a failed 
marker creation, as the issue describes. With early conflict detection on, 
`createWithEarlyConflictDetection()` throws 
`HoodieEarlyConflictDetectionException` although no other writer exists. #19369 
turns the empty option into an exception, so it needs retries to be safe first, 
as noted in its review.
   
   This picks up #18073 by PavithranRick, which stalled in February after the 
review agreed on a request ID. That PR no longer applies on master, because 
#19368 changed `MarkerDirState` to only acknowledge markers once they are 
persisted. The port keeps the reviewed design and adapts it to that change.
   
   ### Summary and Changelog
   
   A retried marker creation request now succeeds when the timeline server 
already created the marker for the same request. Every other request for an 
existing marker still fails.
   
   - `TimelineServerBasedWriteMarkers` adds a random `requestid` to each create 
request. The timeline client resends the same request when it retries, so a 
retry carries the same ID.
   - `RequestHandler`, `MarkerHandler` and `MarkerCreationFuture` pass the ID 
through. A request without an ID keeps the old behavior, so an older client 
works with a newer timeline server.
   - `MarkerDirState` remembers the ID of the request that created each marker 
in this timeline server, in a `HashMap` guarded by 
`markerCreationProcessingLock`. A request whose ID matches is acknowledged.
   - Markers read from the file system after a timeline server restart have no 
ID, so retries for them fail as before. This follows the review on #18073, 
which asked not to backfill the map.
   - A retry is only acknowledged once the marker is persisted, so the 
guarantee from #19368 holds. If another batch is still writing the marker, the 
retry goes back to the queue and a later batch answers it. If that batch fails, 
the marker is removed and the retry creates it again.
   - When a batch fails to persist, only the markers that the batch added are 
removed. Before, every marker of a successful future in the batch was removed, 
and with retries that could drop a marker an earlier batch persisted.
   - Two retries of the same request in one batch both succeed and share the 
outcome of the batch. #18073 deduplicated in-flight futures by marker and 
request ID. Handling them in the batch loop under the lock gives the same 
result without a second queue structure.
   
   The new tests are below.
   - `TestMarkerDirState` covers a retry in a later batch and in the same 
batch, other requests for an existing marker with a different or no ID, a retry 
after a restart, a retry that arrives while another batch is persisting the 
marker with that batch succeeding and failing, and a failed batch that must 
keep a marker persisted earlier.
   - `TestRequestHandler#testCreateMarkerAPIRetryWithSameRequestId` checks the 
HTTP endpoint with the same, a different and no request ID.
   - 
`TestTimelineServerBasedWriteMarkers#testMarkerCreationRetrySucceedsAfterLostResponse`
 runs the real client with retries against a timeline server whose first 
response is lost after the marker was created, for `create()` and 
`createWithEarlyConflictDetection()`. `TimelineServiceTestHarness` gains 
`withNumberOfSimulatedLostResponses` for this, and its proxy now forwards POST 
requests.
   - On master, the retry tests fail because the retry gets `false`, and the 
client test gets an empty option or the early conflict detection exception.
   
   The commit credits PavithranRick as co-author, since #18073 introduced the 
request ID and went through the review that shaped this design.
   
   ### Impact
   
   Only affects timeline-server-based markers with remote retries enabled. A 
retry of a lost marker creation response no longer fails the write or the 
rollback. The timeline server keeps one request ID per marker it created, which 
adds about the size of a UUID per marker to the marker directory state. No 
public API or config change.
   
   ### Risk Level
   
   low. The change is limited to how the timeline server answers a create 
request for an existing marker. Only a request with the same ID as the one that 
created the marker changes its answer, and only once the marker is persisted. 
Requests without an ID, markers from before a restart and duplicates from other 
tasks behave as before.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   


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

  • [PR] fix(timeline-service): mak... Indian-boult (via GitHub) via commits

Reply via email to