cshuo commented on code in PR #19971:
URL: https://github.com/apache/hudi/pull/19971#discussion_r4025720968
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/heartbeat/HoodieHeartbeatClient.java:
##########
@@ -144,14 +146,45 @@ public void start(String instantTime) {
Heartbeat newHeartbeat = new Heartbeat();
newHeartbeat.setHeartbeatStarted(true);
instantToHeartbeatMap.put(instantTime, newHeartbeat);
- // Ensure heartbeat is generated for the first time with this blocking
call.
- // Since scheduler submits the task to a thread, no guarantee when that
thread will get CPU
- // cycles to generate the first heartbeat.
+ // Attempt the first heartbeat synchronously. A timed-out write is retried
by the scheduler;
+ // callers that need a confirmed heartbeat before proceeding can use
awaitHeartbeat().
Review Comment:
The in-memory lastHeartbeatTime is updated only after writeHeartbeatFile()
succeeds. If the initial write times out (no exception will be thrown), it
remains null, while start() schedules retries and returns normally.
You’re right that validation calls isHeartbeatExpired(), but with a null
timestamp it falls back to storage. If no heartbeat file exists, it reads 0 and
treats the heartbeat as expired.
See comment here:
https://github.com/apache/hudi/blob/5ba8d7ca1915b8734a44ea4bdd822463140a3ff4/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/heartbeat/HoodieHeartbeatClient.java#L220-L223
--
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]