Repository navigation
Conversation
) The new instant time generation utilizes RPC request to coordinate creation of new instants. Each write task will send an RPC request to the coordinator for the instant time, the coordinator uses a global lock to guard the access from multiple tasks. Now one checkpoint id corresponds to one instant. Basic work flow: * write task send request: current ckp id * write task expected response: the instant time * coordinator mappings of checkpoint and instant: ckp-id → {instant → {write-task-id → write meta event}} Note that the ckp id used in the request is the last known id instead of the current checkpoint, if a task is restored from a state of the current job, it is the state checkpoint id, otherwise -1 for fresh new job. (cherry picked from commit e34a7ab)
…ite path (apache#18264) (cherry picked from commit 69e24ea)
…use non-KeyedStateStore (apache#11952)
hudi-agent
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.
Thanks for the contribution! This PR backports async instant generation to 0.14.1, replacing the file-based CkpMetadata queue with direct coordinator-task communication via CoordinationRequest/Response and refactoring the Flink write path and its tests accordingly. A few correctness concerns are worth a closer look — notably uninitialized maps in the new mock keyed state classes, an unguarded await in CommitGuard, a silent default change in HoodieFlinkTable.create, a default flip in FlinkOptions, exception handling in the new coordinator request path, and a primitive/boxed mismatch on WriteMetadataEvent. Please take a look at the inline comments, and this should be ready for a Hudi committer or PMC member to take it from here. A few minor naming and dead code nits below. a few naming and type-consistency suggestions below.
| public MockKeyedListState(MockKeyContext keyContext) { | ||
| Objects.requireNonNull(keyContext, "keyContext is null"); | ||
| this.keyContext = keyContext; | ||
| } |
There was a problem hiding this comment.
🤖 mockListStateMap is declared on line 34 but never initialized — the constructor only assigns keyContext. Any call to update/add/get/addAll/clear will NPE at the mockListStateMap.computeIfAbsent(...) line. Compare with MockKeyedValueState which initializes this.keyValueStateMap = new HashMap<>() in its constructor. Could you add this.mockListStateMap = new HashMap<>(); here?
- AI-generated; verify before applying. React 👍/👎 to flag quality.
| public MockKeyedMapState(MockKeyContext keyContext) { | ||
| Objects.requireNonNull(keyContext, "keyContext is null"); | ||
| this.keyContext = keyContext; | ||
| } |
There was a problem hiding this comment.
🤖 Same issue as MockKeyedListState — mockMapStateMap is never initialized in the constructor, so the first call to any method (get/put/contains/etc.) will NPE on mockMapStateMap.computeIfAbsent(...). Could you add this.mockMapStateMap = new HashMap<>(); here?
- AI-generated; verify before applying. React 👍/👎 to flag quality.
| try { | ||
| if (!condition.await(commitAckTimeout, TimeUnit.MILLISECONDS)) { | ||
| throw new HoodieException("Timeout(" + commitAckTimeout + "ms) while waiting for instants [" + instants + "] to commit"); | ||
| } |
There was a problem hiding this comment.
🤖 This await isn't guarded by a predicate, which exposes two issues: (1) if unblock() runs before another thread enters await(), the signal is lost and the waiter blocks for the full commitAckTimeout; (2) every EventBuffers.reset(...) calls unblock(), so if multiple checkpoints are pending, the first commit will wake the waiter and blockFor returns even though there are still pending instants. For CoW upsert (where isBlockingInstantGeneration is true), that breaks the intended serialization across instants. Could we loop while pendingInstants is non-empty (similar to the supplier-based pattern), so the awaiter only proceeds when all pending instants are actually drained? @danny0405
- AI-generated; verify before applying. React 👍/👎 to flag quality.
| } | ||
|
|
||
| public static <T> HoodieFlinkTable<T> create(HoodieWriteConfig config, HoodieEngineContext context) { | ||
| return create(config, context, false); |
There was a problem hiding this comment.
🤖 This silently changes the default loadActiveTimelineOnLoad from true to false for every caller of the 2-arg create(config, context). That includes HoodieFlinkWriteClient.getHoodieTable(), FlinkUpgradeDowngradeHelper.getTable(), WriteProfile.getTable(), and FlinkTables.createTableInternal. The new lazy default is the right intent for the per-task write client path, but FlinkUpgradeDowngradeHelper (and arguably WriteProfile) likely expect the timeline to be loaded - upgrade/downgrade reasons over completed instants, and WriteProfile walks getCommitsTimeline(). Was this intentional for those callers, or would it be safer to keep the 2-arg version returning true and have only HoodieFlinkWriteClient.getHoodieTable(false) opt in to lazy loading?
- AI-generated; verify before applying. React 👍/👎 to flag quality.
| instantTime = startInstant(); | ||
| this.eventBuffers.initNewEventBuffer(checkpointId, instantTime, this.parallelism); | ||
| } else { | ||
| instantTime = instantTimeAndEventBuffer.getLeft(); |
There was a problem hiding this comment.
🤖 If startInstant() throws here (e.g. timeline transition fails, or the lock can't be acquired), the response future is never completed - it's not in a try/catch that completes it exceptionally. The executor's exception hook will call context.failJob(...), but until the JM tears the task down the writer is blocked on response.get() inside Correspondent.requestInstantTime. Could we wrap this body in try { ... } catch (Throwable t) { response.completeExceptionally(t); throw t; } so the writer fails fast rather than hanging?
- AI-generated; verify before applying. React 👍/👎 to flag quality.
| private final ClassLoader cl; | ||
| private final Thread.UncaughtExceptionHandler errorHandler; | ||
|
|
||
| private Thread t; |
There was a problem hiding this comment.
🤖 nit: t is a pretty opaque name for the field tracking the single created thread — thread (or singleThread) would make the if (t != null) guard in newThread immediately readable.
- AI-generated; verify before applying. React 👍/👎 to flag quality.
There was a problem hiding this comment.
🤖 Line 269: This silently overrides the user-configured hoodie.cleaner.policy.failed.writes to LAZY whenever non-blocking instant generation is enabled, with no log message. If a user explicitly set EAGER they'll likely be confused when behavior doesn't match their config. Could you at least log a warning when overriding a user-provided value (e.g. when the conf already contains the key with a non-LAZY value)? Or consider validating up-front and failing fast with a clear error.
- AI-generated; verify before applying. React 👍/👎 to flag quality.
There was a problem hiding this comment.
🤖 Line 306: AssertionError extends Error, not Exception, so if checkWrittenData(expected, 1) fails inside t1, the catch block won't catch it — the thread will die silently and t1.join() will return normally, leaving the test passing despite the failed assertion. This may be why TestWriteMergeOnReadWithCompact.testBlockedInstantTimeRequest documents the test as flaky. Could you catch Throwable and store it in an AtomicReference for the main thread to rethrow after join()?
- AI-generated; verify before applying. React 👍/👎 to flag quality.
There was a problem hiding this comment.
🤖 Line 185: nit: writeConfig is assigned here but never used after this point — it looks like a leftover from the CkpMetadata replacement. Could you remove it (or actually use it if something depends on this call)?
- AI-generated; verify before applying. React 👍/👎 to flag quality.
There was a problem hiding this comment.
🤖 Line 556: nit: assertDataFilesExists — the subject "files" is plural, so it might read more naturally as assertDataFilesExist (and the sibling assertEmptyBaseFiles already follows this pattern implicitly).
- AI-generated; verify before applying. React 👍/👎 to flag quality.
hudi-agent
left a comment
There was a problem hiding this comment.
🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.
Thanks for the additional cleanup work! This incremental change is in a different area — it tightens resource handling in HoodieAppendHandle, HoodieMergeHandle, HoodieSortedMergeHandle, the parquet stream writers, HFileBootstrapIndex, and SparkHelpers.scala, adds a new AutoCloseableUtils helper, and makes HoodieFileWriter extend AutoCloseable. The new code looks like a clear net improvement (closes-on-exception, suppressed-exception chaining, second writer still attempted on partial failure in HFileBootstrapIndex.Writer.close). Note: none of the prior findings from earlier rounds (the uninitialized mock state maps, CommitGuard lost-wakeup, HoodieFlinkTable.create default change, StreamWriteOperatorCoordinator uncompleted future, TestWriteCopyOnWrite swallowed AssertionError, the silent FAILED_WRITES_CLEANER_POLICY override in FlinkWriteClients, the FlinkOptions -1 default change, and the assorted nits/javadoc/naming items) appear addressed in this delta — those files were not touched here, so the earlier comments remain open. Please take a look at any inline comments, and this should be ready for a Hudi committer or PMC member to take it from here.
| @@ -549,6 +569,7 @@ public void write(Map<String, HoodieRecord<T>> recordMap) { | |||
| appendDataAndDeleteBlocks(header, true); | |||
| estimatedNumberOfBytesWritten += averageRecordSize * numberOfRecords; | |||
| } catch (Exception e) { | |||
There was a problem hiding this comment.
🤖 Closing the writer here (good for the leak) but not calling markClosed() means the handle ends up in a half-state: writer == null but isClosed() is still false. If any caller ever wraps write(recordMap) in a try-finally and then calls close(), close() will skip the early-return, reach appendDataAndDeleteBlocks(...), and NPE on writer.appendBlocks(...) / writer.getLogFile(). Current callers (HoodieSparkMergeOnReadTable, HoodieFlinkMergeOnReadTable) do write(); close(); without finally so this is latent, but would calling markClosed() here too be a cheap way to make the contract safe for future try-with-resources style use?
- AI-generated; verify before applying. React 👍/👎 to flag quality.
|
Temporarily closing this PR while we debug a GitHub settings error on master (#20471); it will be reopened shortly, no action needed. |
Describe the issue this Pull Request addresses
Summary and Changelog
Impact
Risk Level
Documentation Update
Contributor's checklist