Skip to content

fix(client): create a new log file version instead of reopening the latest on pre-v8 writes - #19755

Merged
yihua merged 2 commits into
apache:masterfrom
lokeshj1703:oss-append-handle-file-listing
Aug 26, 2026
Merged

fix(client): create a new log file version instead of reopening the latest on pre-v8 writes#19755
yihua merged 2 commits into
apache:masterfrom
lokeshj1703:oss-append-handle-file-listing

Conversation

@lokeshj1703

Copy link
Copy Markdown
Collaborator

Describe the issue this Pull Request addresses

closes #19754

Summary and Changelog

For a pre-table-version-8 table, HoodieWriteHandle#createLogWriter opened the log writer at the latest existing log file's version (reopening/append-targeting it). This changes it to target a new version (latest + 1) so the write does not depend on append support for the latest log file. The table-version-8+ path derives log file names differently and is unaffected.

Adds TestHoodieAppendHandle.testCreateLogFileWriterLogVersion, parameterized over table versions {SIX, EIGHT, NINE}, asserting the pre-v8 writer increments the version when a log file is present and the v8+ path is unchanged.

Mirrors the equivalent change on the Onehouse internal 1.x line.

Impact

Pre-v8 MOR log writes create a new log file version instead of reopening the latest one. The v8+ path is unchanged.

Risk Level

low. Confined to pre-v8 log-writer version selection and covered by a unit test.

Documentation Update

none

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

@github-actions github-actions Bot added the size:M PR with lines of changes in (100, 300] label Aug 26, 2026
@codecov-commenter

codecov-commenter commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.15%. Comparing base (29b7a52) to head (5f9e6ca).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19755      +/-   ##
============================================
- Coverage     77.96%   76.15%   -1.82%     
+ Complexity    33458    32689     -769     
============================================
  Files          2539     2539              
  Lines        140939   140942       +3     
  Branches      17012    17012              
============================================
- Hits         109890   107336    -2554     
- Misses        23388    25851    +2463     
- Partials       7661     7755      +94     
Components Coverage Δ
hudi-common 82.43% <ø> (-1.05%) ⬇️
hudi-client 80.18% <100.00%> (-2.90%) ⬇️
hudi-flink 85.62% <ø> (+<0.01%) ⬆️
hudi-spark-datasource 66.84% <ø> (-5.54%) ⬇️
hudi-utilities 74.34% <ø> (+0.01%) ⬆️
hudi-cli 15.06% <ø> (ø)
hudi-hadoop 68.11% <ø> (-1.14%) ⬇️
hudi-sync 75.54% <ø> (-0.03%) ⬇️
hudi-io 79.71% <ø> (-0.05%) ⬇️
hudi-timeline-service 83.44% <ø> (ø)
hudi-cloud 64.27% <ø> (ø)
hudi-kafka-connect 53.96% <ø> (+0.76%) ⬆️
Flag Coverage Δ
common-and-other-modules 51.04% <100.00%> (+0.01%) ⬆️
flink-integration-tests 48.98% <100.00%> (-0.02%) ⬇️
hadoop-mr-java-client 43.65% <100.00%> (-0.09%) ⬇️
integration-tests 13.56% <0.00%> (-0.01%) ⬇️
spark-client-hadoop-common 50.54% <100.00%> (-0.01%) ⬇️
spark-java-tests 41.15% <100.00%> (-10.86%) ⬇️
spark-scala-tests 46.62% <100.00%> (-0.01%) ⬇️
utilities 36.41% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ain/java/org/apache/hudi/io/HoodieWriteHandle.java 90.15% <100.00%> (+0.22%) ⬆️

... and 244 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lokeshj1703
lokeshj1703 marked this pull request as ready for review August 26, 2026 14:16

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! The PR changes the pre-v8 createLogWriter path to target a new log file version (latest + 1) rather than reopening the latest log file, avoiding a dependency on append support. Tracing the write path, the end-state file matches what the old exists()→rollover path produced, so the change looks behavior-preserving. One minor consistency question on the initial file size is noted inline. 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. A couple of minor naming nits in the new test file; the production change looks clean.

.map(logFile -> logFile.getLogVersion() + 1)
.orElse(HoodieLogFile.LOGFILE_BASE_VERSION);
return HoodieLogFormatWriter.builder()
.withParentPath(FSUtils.constructAbsolutePath(hoodieTable.getMetaClient().getBasePath(), partitionPath))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Now that this targets a fresh version (latest + 1) rather than reopening the latest file, should withFileSize be 0L to match the v8+ path above? Passing the previous log file's size seeds HoodieLogFile.getFileSize() on a file that actually starts empty. It looks harmless today (rollover uses outputStream.getPos(), and write stats use result.size()), but the stale initial size is a bit inconsistent with the intent.

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

cleanMetaClient();
}

private void mockMethodsNeededByConstructor() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit: mockMethodsNeededByConstructor reads as an explanation of why rather than a name — could you rename it to something like stubTableMocks() or initMockTable()?

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

when(mockHoodieTable.getMetaClient()).thenReturn(metaClient);
}

private static Stream<Arguments> versionsSixAndAbove() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit: versionsSixAndAbove implies it covers all table versions ≥ 6, but only three specific ones are listed — something like preAndPostV8Versions() or tableVersionsUnderTest() would be more accurate and make it clear why SEVEN (if it exists) is absent.

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

…atest on pre-v8 writes

For a pre-table-version-8 table, HoodieWriteHandle.createLogWriter opened the log
writer at the latest existing log file's version (reopening/append-targeting it).
Target a new version (latest + 1) instead, so the write does not depend on append
support for the latest log file. The table-version-8+ path derives log file names
differently and is unaffected.

Add TestHoodieAppendHandle.testCreateLogFileWriterLogVersion, parameterized over
{SIX, EIGHT, NINE}: pre-v8 increments the version when a log file is present, v8+ is
unchanged. Mirrors the equivalent change on the Onehouse internal 1.x line.
The test does not compile as cherry-picked from the internal 1.x line: on apache/hudi
master HoodieAppendHandle is abstract, so instantiate the concrete
HoodieInlineLogAppendHandle; and HoodieStorageUtils lives in
org.apache.hudi.common.util (not org.apache.hudi.storage).
@lokeshj1703
lokeshj1703 force-pushed the oss-append-handle-file-listing branch from b494716 to 5f9e6ca Compare August 26, 2026 14:43
@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! This PR changes the pre-v8 log-writer path so it targets a fresh log file version (latest + 1) instead of reopening the latest, avoiding reliance on append/exists semantics; the v8+ path is untouched. I traced the change through HoodieLogFormatWriter and confirmed the version selection, write-token reuse, and rollover behavior are consistent with the existing rollover path. The one open item (the withFileSize still carrying the old file's size) was already raised in a prior round's inline comment and is worth confirming. 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. One small naming nit in the test helper, otherwise the code is clean and readable.

cc @yihua

cleanMetaClient();
}

private void mockMethodsNeededByConstructor() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit: could you rename this to something like stubTableDefaults() or mockTableConfig()? mockMethodsNeededByConstructor describes why the helper exists rather than what it stubs, which makes it a little harder to read at the call site in setUp.

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

@yihua yihua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yihua
yihua merged commit b5263e1 into apache:master Aug 26, 2026
23 checks passed
voonhous pushed a commit to voonhous/hudi that referenced this pull request Aug 28, 2026
voonhous added a commit to voonhous/hudi that referenced this pull request Aug 28, 2026
…in TestHoodieAppendHandle

The apache#19755 backport (4b71100) brought the test over with master's
org.apache.hudi.common.util.HoodieStorageUtils import. The hudi-common package reorg (apache#19195) is
not on this branch, so the class only exists as org.apache.hudi.storage.HoodieStorageUtils here
and hudi-client-common test sources did not compile. Import-only change.
voonhous added a commit to voonhous/hudi that referenced this pull request Aug 28, 2026
…andle on this branch

The apache#19755 backport (4b71100) instantiates HoodieInlineLogAppendHandle, which master
introduced with the native-format log files (apache#19067). That split is not on this branch, where
HoodieAppendHandle is still the concrete class with the same six-argument constructor, so the
test constructs it directly. Test-only change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-v8 log writer reopens the latest log file version instead of creating a new one

5 participants