You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "nsivabalan (via GitHub)" <gi...@apache.org> on 2026/07/23 23:30:27 UTC

[PR] fix(timeline-service): fail marker creation when create request fails [hudi]

nsivabalan opened a new pull request, #19369:
URL: https://github.com/apache/hudi/pull/19369

   ### Change Logs
   
   `TimelineServerBasedWriteMarkers#create` silently returned `Option.empty()` when the timeline server's marker creation request failed, instead of raising an error. Callers of `WriteMarkers#create` do not check the returned `Option` for emptiness, so a failed marker creation was treated as if it succeeded, allowing a write to proceed and create a data file without a durable marker for it. Marker-based rollback of a failed write would then miss such files.
   
   Changes:
   - `TimelineServerBasedWriteMarkers#create` now throws `HoodieIOException` when the marker creation request fails, instead of returning `Option.empty()`, so the failure surfaces to the writer.
   - Relaxes `executeCreateMarkerRequest`'s visibility to package-private so it can be overridden in tests to simulate a failure.
   - Adds `testMarkerCreationFailure` to `TestTimelineServerBasedWriteMarkers`, asserting the exception is thrown with the expected message on a simulated failure.
   
   ### Impact
   
   No public API change. Writers using timeline-server-based markers now get an exception (instead of a silent no-op) when a marker creation request fails, so a data file is not written without a durable marker.
   
   ### Risk level
   
   low. New unit test covers the failure path of marker creation.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Change Logs and Impact were stated clearly
   - [x] Adequate tests were added if applicable
   - [ ] CI passed


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "voonhous (via GitHub) via commits" <co...@hudi.apache.org>.
voonhous closed pull request #19369: fix(timeline-service): fail marker creation when create request fails
URL: https://github.com/apache/hudi/pull/19369


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "voonhous (via GitHub) via commits" <co...@hudi.apache.org>.
voonhous commented on PR #19369:
URL: https://github.com/apache/hudi/pull/19369#issuecomment-6701217472

   Temporarily closing this PR while we debug a GitHub settings error on master (#20471); it will be reopened shortly, no action needed.


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19369:
URL: https://github.com/apache/hudi/pull/19369#discussion_r3802700818


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/marker/TimelineServerBasedWriteMarkers.java:
##########
@@ -168,7 +170,8 @@ public Option<StoragePath> createWithEarlyConflictDetection(String partitionPath
    * @param markerFileName Marker file name.
    * @return {@code true} if successful; {@code false} otherwise.
    */
-  private boolean executeCreateMarkerRequest(Map<String, String> paramsMap, String partitionPath, String markerFileName) {
+  @VisibleForTesting
+  boolean executeCreateMarkerRequest(Map<String, String> paramsMap, String partitionPath, String markerFileName) {

Review Comment:
   `executeCreateMarkerRequest` hands back a bare boolean, and that boolean carries three distinct outcomes: created, already exists, and early-conflict-detected. Collapsing them here is what lets the new throw above fire for a conflict, and the exception type matters.
   
   `createWithEarlyConflictDetection` in this same file throws `HoodieEarlyConflictDetectionException` for the identical `false`, and `HoodieAppendHandle` keys off exactly that type:
   
   ```java
   if (!config.getIgnoreWriteFailed() || ExceptionUtil.isCausedBy(e, HoodieEarlyConflictDetectionException.class)) {
     throw new HoodieException(e.getMessage(), e);
   }
   ```
   
   `hoodie.write.ignore.failed` defaults to `true` (`HoodieWriteConfig.IGNORE_FAILED`), so a conflict that arrives as `HoodieIOException` is swallowed into `writeStatus.markFailure` instead of aborting the write. This is reachable: with server-side early conflict detection enabled, `MarkerHandler#createMarker` runs detection for every create on that marker dir, and `WriteMarkers` routes pending compaction and clustering instants through the plain `create(..., false)` path even under OCC.
   
   Concrete suggestion: return the outcome from the server rather than a boolean, and map each one separately -- `Option.of` for created, `Option.empty()` for already-exists when `checkIfExists` is set, and `HoodieEarlyConflictDetectionException` for a detected conflict. If you would rather keep the wire format as-is for now, at minimum do not convert a conflict into `HoodieIOException`.



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/marker/TimelineServerBasedWriteMarkers.java:
##########
@@ -137,7 +139,7 @@ protected Option<StoragePath> create(String partitionPath, String fileName, IOTy
     if (success) {
       return Option.of(new StoragePath(FSUtils.constructAbsolutePath(markerDirPath, partitionPath), markerFileName));
     } else {
-      return Option.empty();
+      throw new HoodieIOException("[timeline-server-based] Failed to create marker for partition " + partitionPath + ", fileName " + fileName + " with IOType " + type);

Review Comment:
   Digging into the server side, `false` has exactly two producers, and neither one is a failed create:
   
   - `MarkerDirState#processMarkerCreationRequests` -> `future.setIsSuccessful(!exists)`, i.e. the marker already exists.
   - the `catch (HoodieEarlyConflictDetectionException)` in that same method, plus the equivalent in `MarkerHandler#createMarker` via `finishCreateMarkerFuture`, i.e. early conflict detection fired.
   
   A genuine failure never reaches the client as `false`. Transport errors already become `HoodieRemoteException` inside `executeCreateMarkerRequest`, and a marker flush failure throws `HoodieIOException` out of `processMarkerCreationRequests` before the futures are completed (that leg has since been fixed on master by #19368). So the message on this exception names a condition that this branch cannot actually be in.
   
   @nsivabalan on "a client can never ask to create a marker that already exists" -- the log-marker path can, and the surrounding code is built to tolerate it:
   
   - `HoodieWriteHandle#getLogCreationCallback` returns `createLogMarkerIfNotExists(...).isPresent()`, and all three consumers discard that boolean (`HoodieLogFormatWriter#createNewFile`, `HoodieNativeLogFormatWriter`, `HoodieNativeCDCFileWriter`). An empty Option was designed as a tolerated no-op.
   - `HoodieLogFormatWriter#getOutputStream` is an explicit collision-recovery loop: `while (!created) { if (exists(logFile)) rollOver(); createNewFile(); }` with `catch (FileAlreadyExistsException) { rollOver(); }`. `createNewFile()` fires `preFileCreation`, i.e. creates the marker, *before* `storage.create(path, false)`. A task that dies in that window leaves a marker with no log file behind it; the retry recomputes the same rolled-over name and, with this change, throws on that attempt and every later one, because the marker persists in `.hoodie/.temp/<instant>` for the life of the instant. Two writers racing the rollover hit the same thing: the loser used to recover through `FileAlreadyExistsException -> rollOver`.
   - The write token is not always distinct per attempt. `HoodieWriteHandle` inherits `latestLogFile.getLogWriteToken()` for table version below 8, `FSUtils.makeWriteToken` falls back to the constant `HoodieLogFormat.DEFAULT_WRITE_TOKEN` ("0-0-0") when the task context is unavailable, and `JavaTaskContextSupplier` returns 0/0/0 unconditionally.
   - `RollbackHelperV1` uses `createIfNotExists(..., IOType.APPEND, ...)` for rollback log appends; a retried rollback reuses the same rollback instant, so the same marker dir and the same log file names.
   
   Concrete suggestion: gate the throw on `checkIfExists`, so `createIfNotExists` keeps returning `Option.empty()`. That matches `DirectWriteMarkers.create`, which returns empty for already-exists and reserves a throw for real I/O failure, and it matches the contract written on the method being overridden -- `WriteMarkers#create(String, String, IOType, boolean)`: "the marker path or empty option if already exists and `checkIfExists` is true". The more complete fix is to have the server report which of the three outcomes happened, since a bare boolean cannot express it.



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19369:
URL: https://github.com/apache/hudi/pull/19369#issuecomment-5064609387

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a9fbee27be3a8a1badf52d1ee0c2bddc8d939ba9",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "a9fbee27be3a8a1badf52d1ee0c2bddc8d939ba9",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * a9fbee27be3a8a1badf52d1ee0c2bddc8d939ba9 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "wombatu-kun (via GitHub)" <gi...@apache.org>.
wombatu-kun commented on code in PR #19369:
URL: https://github.com/apache/hudi/pull/19369#discussion_r3643043796


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/marker/TimelineServerBasedWriteMarkers.java:
##########
@@ -137,7 +139,7 @@ protected Option<StoragePath> create(String partitionPath, String fileName, IOTy
     if (success) {
       return Option.of(new StoragePath(FSUtils.constructAbsolutePath(markerDirPath, partitionPath), markerFileName));
     } else {
-      return Option.empty();
+      throw new HoodieIOException("[timeline-server-based] Failed to create marker for partition " + partitionPath + ", fileName " + fileName + " with IOType " + type);

Review Comment:
   A false result here does not mean the create failed: the server returns false when the marker already exists (MarkerDirState sets isSuccessful to !exists), and a genuine I/O failure already surfaces as HoodieRemoteException, not as false. So this throw fires on an already-existing marker, which createIfNotExists/createLogMarkerIfNotExists treat as a harmless Option.empty no-op - is turning already-exists into a hard failure intended, or should the throw be limited to a real create failure?



##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/marker/TestTimelineServerBasedWriteMarkers.java:
##########
@@ -162,6 +168,54 @@ private void restartServerAndClient(int numberOfSimulatedConnectionFailures,
     }
   }
 
+  @Test
+  public void testMarkerCreationFailure() throws IOException {
+    FileSystemViewStorageConfig.Builder builder = FileSystemViewStorageConfig.newBuilder().withRemoteServerHost("localhost")
+        .withRemoteServerPort(timelineService.getServerPort())
+        .withRemoteTimelineClientTimeoutSecs(DEFAULT_READ_TIMEOUT_SECS);
+    MockTimelineServerBasedWriteMarkers timelineServerBasedWriteMarkers = new MockTimelineServerBasedWriteMarkers(basePath, markerFolderPath.toString(), "000", builder.build());
+    // this should succeed.
+    timelineServerBasedWriteMarkers.create("2020/06/01", "file1", IOType.MERGE);
+
+    assertTrue(storage.exists(markerFolderPath));
+    assertTrue(writeMarkers.doesMarkerDirExist());
+
+    // lets fail the marker creation
+    timelineServerBasedWriteMarkers.failMarkerCreation = true;
+    try {
+      timelineServerBasedWriteMarkers.create("2020/06/01", "file2", IOType.MERGE);
+      fail("Should not have reached here");
+    } catch (HoodieIOException ioe) {
+      assertTrue(ioe.getMessage().contains("[timeline-server-based] Failed to create marker for partition"));
+    } finally {
+      if (timelineService != null) {
+        timelineService.close();
+      }
+    }
+  }
+
+  static class MockTimelineServerBasedWriteMarkers extends TimelineServerBasedWriteMarkers {
+
+    boolean failMarkerCreation = false;
+
+    public MockTimelineServerBasedWriteMarkers(HoodieTable table, String instantTime) {
+      super(table, instantTime);
+    }
+
+    MockTimelineServerBasedWriteMarkers(String basePath, String markerFolderPath, String instantTime, FileSystemViewStorageConfig fileSystemViewStorageConfig) {
+      super(basePath, markerFolderPath, instantTime, fileSystemViewStorageConfig);
+    }
+
+    @Override
+    boolean executeCreateMarkerRequest(Map<String, String> paramsMap, String partitionPath, String markerFileName) {
+      if (!failMarkerCreation) {
+        return super.executeCreateMarkerRequest(paramsMap, partitionPath, markerFileName);
+      } else {
+        return false;

Review Comment:
   Returning false here mirrors a create failure, but the real server also returns false when the marker already exists (MarkerDirState: !exists), so the test cannot tell a genuine failure from a benign already-exists and never covers createIfNotExists on an existing marker. Add a case that creates the same marker twice to lock down the intended behavior.



##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/marker/TestTimelineServerBasedWriteMarkers.java:
##########
@@ -162,6 +168,54 @@ private void restartServerAndClient(int numberOfSimulatedConnectionFailures,
     }
   }
 
+  @Test
+  public void testMarkerCreationFailure() throws IOException {
+    FileSystemViewStorageConfig.Builder builder = FileSystemViewStorageConfig.newBuilder().withRemoteServerHost("localhost")
+        .withRemoteServerPort(timelineService.getServerPort())
+        .withRemoteTimelineClientTimeoutSecs(DEFAULT_READ_TIMEOUT_SECS);
+    MockTimelineServerBasedWriteMarkers timelineServerBasedWriteMarkers = new MockTimelineServerBasedWriteMarkers(basePath, markerFolderPath.toString(), "000", builder.build());
+    // this should succeed.
+    timelineServerBasedWriteMarkers.create("2020/06/01", "file1", IOType.MERGE);
+
+    assertTrue(storage.exists(markerFolderPath));
+    assertTrue(writeMarkers.doesMarkerDirExist());
+
+    // lets fail the marker creation
+    timelineServerBasedWriteMarkers.failMarkerCreation = true;
+    try {
+      timelineServerBasedWriteMarkers.create("2020/06/01", "file2", IOType.MERGE);
+      fail("Should not have reached here");
+    } catch (HoodieIOException ioe) {
+      assertTrue(ioe.getMessage().contains("[timeline-server-based] Failed to create marker for partition"));
+    } finally {

Review Comment:
   @AfterEach cleanup() already closes timelineService, so closing it again in this finally double-closes the service. Drop the finally - the try only needs to wrap the failing create.



##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/marker/TestTimelineServerBasedWriteMarkers.java:
##########
@@ -162,6 +168,54 @@ private void restartServerAndClient(int numberOfSimulatedConnectionFailures,
     }
   }
 
+  @Test
+  public void testMarkerCreationFailure() throws IOException {
+    FileSystemViewStorageConfig.Builder builder = FileSystemViewStorageConfig.newBuilder().withRemoteServerHost("localhost")
+        .withRemoteServerPort(timelineService.getServerPort())
+        .withRemoteTimelineClientTimeoutSecs(DEFAULT_READ_TIMEOUT_SECS);
+    MockTimelineServerBasedWriteMarkers timelineServerBasedWriteMarkers = new MockTimelineServerBasedWriteMarkers(basePath, markerFolderPath.toString(), "000", builder.build());
+    // this should succeed.
+    timelineServerBasedWriteMarkers.create("2020/06/01", "file1", IOType.MERGE);
+
+    assertTrue(storage.exists(markerFolderPath));
+    assertTrue(writeMarkers.doesMarkerDirExist());
+
+    // lets fail the marker creation
+    timelineServerBasedWriteMarkers.failMarkerCreation = true;
+    try {
+      timelineServerBasedWriteMarkers.create("2020/06/01", "file2", IOType.MERGE);
+      fail("Should not have reached here");
+    } catch (HoodieIOException ioe) {
+      assertTrue(ioe.getMessage().contains("[timeline-server-based] Failed to create marker for partition"));
+    } finally {
+      if (timelineService != null) {
+        timelineService.close();
+      }
+    }
+  }
+
+  static class MockTimelineServerBasedWriteMarkers extends TimelineServerBasedWriteMarkers {
+
+    boolean failMarkerCreation = false;
+
+    public MockTimelineServerBasedWriteMarkers(HoodieTable table, String instantTime) {

Review Comment:
   This MockTimelineServerBasedWriteMarkers(HoodieTable, String) constructor is unused - the test builds the mock through the (String, String, String, FileSystemViewStorageConfig) constructor. Remove it.



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19369:
URL: https://github.com/apache/hudi/pull/19369#issuecomment-5064640512

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a9fbee27be3a8a1badf52d1ee0c2bddc8d939ba9",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15672",
       "triggerID" : "a9fbee27be3a8a1badf52d1ee0c2bddc8d939ba9",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * a9fbee27be3a8a1badf52d1ee0c2bddc8d939ba9 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15672) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "nsivabalan (via GitHub)" <gi...@apache.org>.
nsivabalan commented on code in PR #19369:
URL: https://github.com/apache/hudi/pull/19369#discussion_r3647334014


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/marker/TimelineServerBasedWriteMarkers.java:
##########
@@ -137,7 +139,7 @@ protected Option<StoragePath> create(String partitionPath, String fileName, IOTy
     if (success) {
       return Option.of(new StoragePath(FSUtils.constructAbsolutePath(markerDirPath, partitionPath), markerFileName));
     } else {
-      return Option.empty();
+      throw new HoodieIOException("[timeline-server-based] Failed to create marker for partition " + partitionPath + ", fileName " + fileName + " with IOType " + type);

Review Comment:
   hey @wombatu-kun : thanks for the note. 
   none of our code path should try to create an already existing marker. every file is immutable including log files. and task retries will use a diff write token. so, a client can never ask for to create a marker that already exists. 
   
   let me know if I am missing any case here



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19369:
URL: https://github.com/apache/hudi/pull/19369#discussion_r3653987463


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/marker/TimelineServerBasedWriteMarkers.java:
##########
@@ -137,7 +139,7 @@ protected Option<StoragePath> create(String partitionPath, String fileName, IOTy
     if (success) {
       return Option.of(new StoragePath(FSUtils.constructAbsolutePath(markerDirPath, partitionPath), markerFileName));
     } else {
-      return Option.empty();
+      throw new HoodieIOException("[timeline-server-based] Failed to create marker for partition " + partitionPath + ", fileName " + fileName + " with IOType " + type);

Review Comment:
   🤖 This `create(...)` override ignores its `checkIfExists` param, so it now throws on the `createIfNotExists` path too. The server returns `success=false` both on a real failure and when the marker already exists, whereas `DirectWriteMarkers.create()` returns `Option.empty()` for the already-exists case. Callers that rely on that idempotency — `createLogMarkerIfNotExists` in `HoodieWriteHandle`, and Flink's `FlinkCreateHandle`/`FlinkMergeHandle.createMarkerFile` — would now get an exception instead of an empty Option. Could we gate the throw on `!checkIfExists` (or otherwise distinguish already-exists from failure) so the two marker impls stay consistent? @nsivabalan
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/marker/TestTimelineServerBasedWriteMarkers.java:
##########
@@ -162,6 +168,54 @@ private void restartServerAndClient(int numberOfSimulatedConnectionFailures,
     }
   }
 
+  @Test
+  public void testMarkerCreationFailure() throws IOException {
+    FileSystemViewStorageConfig.Builder builder = FileSystemViewStorageConfig.newBuilder().withRemoteServerHost("localhost")
+        .withRemoteServerPort(timelineService.getServerPort())
+        .withRemoteTimelineClientTimeoutSecs(DEFAULT_READ_TIMEOUT_SECS);
+    MockTimelineServerBasedWriteMarkers timelineServerBasedWriteMarkers = new MockTimelineServerBasedWriteMarkers(basePath, markerFolderPath.toString(), "000", builder.build());
+    // this should succeed.
+    timelineServerBasedWriteMarkers.create("2020/06/01", "file1", IOType.MERGE);
+
+    assertTrue(storage.exists(markerFolderPath));
+    assertTrue(writeMarkers.doesMarkerDirExist());
+
+    // lets fail the marker creation
+    timelineServerBasedWriteMarkers.failMarkerCreation = true;
+    try {
+      timelineServerBasedWriteMarkers.create("2020/06/01", "file2", IOType.MERGE);
+      fail("Should not have reached here");
+    } catch (HoodieIOException ioe) {
+      assertTrue(ioe.getMessage().contains("[timeline-server-based] Failed to create marker for partition"));
+    } finally {
+      if (timelineService != null) {
+        timelineService.close();
+      }
+    }
+  }
+
+  static class MockTimelineServerBasedWriteMarkers extends TimelineServerBasedWriteMarkers {
+
+    boolean failMarkerCreation = false;

Review Comment:
   🤖 nit: `failMarkerCreation` reads as an imperative verb rather than a boolean predicate — could you rename it to something like `shouldFailMarkerCreation` so that `if (!shouldFailMarkerCreation)` reads more naturally?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/marker/TimelineServerBasedWriteMarkers.java:
##########
@@ -137,7 +139,7 @@ protected Option<StoragePath> create(String partitionPath, String fileName, IOTy
     if (success) {
       return Option.of(new StoragePath(FSUtils.constructAbsolutePath(markerDirPath, partitionPath), markerFileName));
     } else {
-      return Option.empty();
+      throw new HoodieIOException("[timeline-server-based] Failed to create marker for partition " + partitionPath + ", fileName " + fileName + " with IOType " + type);

Review Comment:
   🤖 One case worth double-checking here: `createIfNotExists` / `createLogMarkerIfNotExists` route through this *same* overridden `create(..., checkIfExists=true)`, and this timeline-server impl ignores `checkIfExists`. So the server returning `false` for an already-existing marker (`MarkerDirState#processMarkerCreationRequests` does `future.setIsSuccessful(!exists)`) now throws for those callers too, where it previously returned a benign `Option.empty()`.
   
   A couple of real callers depend on that no-op rather than a fresh write token: `HoodieWriteHandle#getLogCreationCallback` calls `createLogMarkerIfNotExists(...).isPresent()` (so an existing APPEND log marker is expected to yield empty, not an exception), and `RollbackHelperV1` uses `createIfNotExists` for APPEND markers during rollback retries. Since genuine I/O failures already surface as `HoodieRemoteException`, would it be safer to scope the throw to the `checkIfExists == false` path (or have the server distinguish already-exists from a real create failure) so the `*IfNotExists` contract is preserved?



##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/marker/TestTimelineServerBasedWriteMarkers.java:
##########
@@ -162,6 +168,54 @@ private void restartServerAndClient(int numberOfSimulatedConnectionFailures,
     }
   }
 
+  @Test
+  public void testMarkerCreationFailure() throws IOException {
+    FileSystemViewStorageConfig.Builder builder = FileSystemViewStorageConfig.newBuilder().withRemoteServerHost("localhost")
+        .withRemoteServerPort(timelineService.getServerPort())
+        .withRemoteTimelineClientTimeoutSecs(DEFAULT_READ_TIMEOUT_SECS);
+    MockTimelineServerBasedWriteMarkers timelineServerBasedWriteMarkers = new MockTimelineServerBasedWriteMarkers(basePath, markerFolderPath.toString(), "000", builder.build());
+    // this should succeed.
+    timelineServerBasedWriteMarkers.create("2020/06/01", "file1", IOType.MERGE);
+
+    assertTrue(storage.exists(markerFolderPath));
+    assertTrue(writeMarkers.doesMarkerDirExist());
+
+    // lets fail the marker creation
+    timelineServerBasedWriteMarkers.failMarkerCreation = true;
+    try {
+      timelineServerBasedWriteMarkers.create("2020/06/01", "file2", IOType.MERGE);
+      fail("Should not have reached here");
+    } catch (HoodieIOException ioe) {
+      assertTrue(ioe.getMessage().contains("[timeline-server-based] Failed to create marker for partition"));
+    } finally {
+      if (timelineService != null) {
+        timelineService.close();
+      }
+    }
+  }
+
+  static class MockTimelineServerBasedWriteMarkers extends TimelineServerBasedWriteMarkers {
+
+    boolean failMarkerCreation = false;
+
+    public MockTimelineServerBasedWriteMarkers(HoodieTable table, String instantTime) {
+      super(table, instantTime);
+    }
+
+    MockTimelineServerBasedWriteMarkers(String basePath, String markerFolderPath, String instantTime, FileSystemViewStorageConfig fileSystemViewStorageConfig) {
+      super(basePath, markerFolderPath, instantTime, fileSystemViewStorageConfig);
+    }
+
+    @Override
+    boolean executeCreateMarkerRequest(Map<String, String> paramsMap, String partitionPath, String markerFileName) {
+      if (!failMarkerCreation) {
+        return super.executeCreateMarkerRequest(paramsMap, partitionPath, markerFileName);

Review Comment:
   🤖 nit: the `else` branch here is redundant since the `if` block always returns — dropping it to a bare `return false;` after the closing brace would be slightly cleaner.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19369:
URL: https://github.com/apache/hudi/pull/19369#issuecomment-5065145966

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a9fbee27be3a8a1badf52d1ee0c2bddc8d939ba9",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15672",
       "triggerID" : "a9fbee27be3a8a1badf52d1ee0c2bddc8d939ba9",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * a9fbee27be3a8a1badf52d1ee0c2bddc8d939ba9 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15672) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(timeline-service): fail marker creation when create request fails [hudi]

Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19369:
URL: https://github.com/apache/hudi/pull/19369#discussion_r3802702280


##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/marker/TestTimelineServerBasedWriteMarkers.java:
##########
@@ -162,6 +168,54 @@ private void restartServerAndClient(int numberOfSimulatedConnectionFailures,
     }
   }
 
+  @Test
+  public void testMarkerCreationFailure() throws IOException {
+    FileSystemViewStorageConfig.Builder builder = FileSystemViewStorageConfig.newBuilder().withRemoteServerHost("localhost")
+        .withRemoteServerPort(timelineService.getServerPort())
+        .withRemoteTimelineClientTimeoutSecs(DEFAULT_READ_TIMEOUT_SECS);
+    MockTimelineServerBasedWriteMarkers timelineServerBasedWriteMarkers = new MockTimelineServerBasedWriteMarkers(basePath, markerFolderPath.toString(), "000", builder.build());
+    // this should succeed.
+    timelineServerBasedWriteMarkers.create("2020/06/01", "file1", IOType.MERGE);
+
+    assertTrue(storage.exists(markerFolderPath));
+    assertTrue(writeMarkers.doesMarkerDirExist());
+
+    // lets fail the marker creation
+    timelineServerBasedWriteMarkers.failMarkerCreation = true;
+    try {
+      timelineServerBasedWriteMarkers.create("2020/06/01", "file2", IOType.MERGE);
+      fail("Should not have reached here");
+    } catch (HoodieIOException ioe) {
+      assertTrue(ioe.getMessage().contains("[timeline-server-based] Failed to create marker for partition"));
+    } finally {
+      if (timelineService != null) {
+        timelineService.close();
+      }
+    }
+  }
+
+  static class MockTimelineServerBasedWriteMarkers extends TimelineServerBasedWriteMarkers {
+
+    boolean failMarkerCreation = false;
+
+    public MockTimelineServerBasedWriteMarkers(HoodieTable table, String instantTime) {
+      super(table, instantTime);
+    }
+
+    MockTimelineServerBasedWriteMarkers(String basePath, String markerFolderPath, String instantTime, FileSystemViewStorageConfig fileSystemViewStorageConfig) {
+      super(basePath, markerFolderPath, instantTime, fileSystemViewStorageConfig);
+    }
+
+    @Override
+    boolean executeCreateMarkerRequest(Map<String, String> paramsMap, String partitionPath, String markerFileName) {
+      if (!failMarkerCreation) {
+        return super.executeCreateMarkerRequest(paramsMap, partitionPath, markerFileName);
+      } else {
+        return false;

Review Comment:
   +1, and it is a bit stronger than "cannot tell them apart": `MockTimelineServerBasedWriteMarkers` returns `false` before ever calling `super`, so no request reaches the server. The test asserts "if this method returns false, we throw", which restates the diff rather than exercising anything -- it would still pass if the client and server disagreed completely about what `false` means.
   
   Two concrete changes:
   
   1. Drop the mock for this case and call `create("2020/06/01", "file1", IOType.MERGE)` twice against the real `timelineService` already started in `setup()`, asserting the second call's outcome. That covers client -> server -> already-exists -> client for real.
   2. Put the already-exists contract in `TestWriteMarkersBase` rather than here. Nothing pins it today: `createSomeMarkers` creates each marker exactly once, and `createLogMarkerIfNotExists` is called once on a single file. A test there runs against `DirectWriteMarkers`, `DirectWriteMarkersV1`, `TimelineServerBasedWriteMarkers` and `TimelineServerBasedWriteMarkersV1`, so it would settle whether the two implementations are meant to agree -- which is the open question in this thread.



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org