yihua commented on code in PR #18411:
URL: https://github.com/apache/hudi/pull/18411#discussion_r3041746722
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -244,17 +245,44 @@ public void start() throws Exception {
.threadFactory(getThreadFactory("instant-request"))
.exceptionHook((errMsg, t) -> this.context.failJob(new
HoodieException(errMsg, t)))
.build();
- // start the executor if required
- if (tableState.syncHive) {
- initHiveSync();
- }
- // start client id heartbeats for optimistic concurrency control
- if (OptionsResolver.isMultiWriter(conf)) {
- initClientIds(conf);
- }
- restoreEvents();
+
+ // Run upgrade, metadata table init, and event restoration on the
executor
+ // thread instead of the Pekko dispatcher thread. Running these
synchronously
+ // on the dispatcher thread blocks heartbeat responses when the
operations
+ // involve heavy I/O (e.g., LSM timeline migration with hundreds of
archived
+ // actions), causing the ResourceManager to disconnect the JobManager.
+ //
+ // Safety guarantees:
+ // - Events via handleEventFromOperator() are submitted to the same
+ // single-threaded executor, so FIFO ordering ensures initialization
+ // completes before any event processing.
+ // - Coordination requests via handleCoordinationRequest() run on the
+ // separate instantRequestExecutor and are gated on initFuture to
+ // prevent startInstant() from racing ahead of the upgrade.
+ this.executor.execute(() -> {
+ try {
+ this.writeClient.tryUpgrade(instant, this.metaClient);
+ initMetadataTable(this.writeClient);
+ if (tableState.scheduleMdtCompaction) {
+ this.metadataWriteClient =
StreamerUtil.createMetadataWriteClient(writeClient);
+ }
+ if (tableState.syncHive) {
+ initHiveSync();
+ }
+ if (OptionsResolver.isMultiWriter(conf)) {
+ initClientIds(conf);
+ }
+ restoreEvents();
+ initFuture.complete(null);
+ } catch (Throwable t) {
+ initFuture.completeExceptionally(t);
+ throw t;
+ }
Review Comment:
🤖 The `throw t` here is swallowed by `NonThrownExecutor`, so when async init
fails (e.g. `tryUpgrade` throws), `initFuture` is completed exceptionally but
`context.failJob(t)` is never called — unlike the synchronous failure path in
the outer `catch` block which does call it. Could you add `context.failJob(t)`
here so the Flink job is proactively terminated on init failure, rather than
silently waiting for the first coordination request to discover the broken
future?
--
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]