prashantwason commented on code in PR #18411:
URL: https://github.com/apache/hudi/pull/18411#discussion_r3041687638
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -244,15 +245,36 @@ 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(() -> {
+ this.writeClient.tryUpgrade(instant, this.metaClient);
+ initMetadataTable(this.writeClient);
+ if (tableState.scheduleMdtCompaction) {
+ this.metadataWriteClient =
StreamerUtil.createMetadataWriteClient(writeClient);
+ }
+ if (tableState.syncHive) {
+ initHiveSync();
+ }
Review Comment:
Good catch. Added try-catch in the lambda body — on failure,
`initFuture.completeExceptionally(t)` is called before re-throwing, so
`NonThrownExecutor`'s exception hook still fires (calling `context.failJob()`)
and coordination requests get the exception instead of hanging.
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -244,15 +245,36 @@ 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
Review Comment:
Fixed — added `initFuture.completeExceptionally(throwable)` in the outer
catch block as well.
--
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]