You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "zhaoyudi-creator (via GitHub)" <gi...@apache.org> on 2026/08/28 02:55:04 UTC
[I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
zhaoyudi-creator opened a new issue, #19774:
URL: https://github.com/apache/hudi/issues/19774
### Bug Description
**What happened:**
With MOR + BUCKET index + NBCC, if the first write into a bucket (FileGroup) is a failed write whose "file has already been produced but the commit did not finish", then all subsequently committed data in that bucket is entirely filtered out of snapshot queries — the query does not fail, it silently returns an incomplete result.
The BUCKET index acts as an amplifier here: it forces the failed write and the later successful writes to share the same FileGroup, so a single failed write drags down all later data in the whole bucket.
**What you expected:**
**Steps to reproduce:**
Steps to reproduce the behavior:
1. Create the table:
```sql
CREATE TABLE test_mor (
id BIGINT, ts BIGINT, v STRING
) USING hudi
TBLPROPERTIES (
primaryKey = 'id',
preCombineField = 'ts',
type = 'mor',
hoodie.index.type = 'BUCKET',
hoodie.bucket.index.num.buckets = '2',
hoodie.metadata.enable = 'false'
);
```
2. Enable NBCC (see the concurrency config under Environment Description).
3. Normal write (lands in bucket A): `INSERT INTO test_mor VALUES (1, 1000, 'a');`
4. Produce one failed write (lands in bucket B, id=2): write `(2, 1002, 'b')` so that its **log file is already produced** but the corresponding deltacommit **did not finish** (the instant stays inflight/requested with no completed marker). For example, kill the job before the commit finishes; under the `LAZY` policy this failed log is not rolled back immediately and remains in the bucket B directory.
5. Two more normal writes to the same bucket B:
```sql
INSERT INTO test_mor VALUES (2, 1003, 'b');
INSERT INTO test_mor VALUES (2, 1004, 'b');
```
6. Run `SELECT * FROM test_mor;` → only `id=1` is returned; the entire `id=2` row is missing.
### Environment
**Hudi version:** 1.1.1
**Query engine:** (Spark/Flink/Trino etc)
**Relevant configs:**
### Logs and Stack Trace
**Additional context**
Root cause (in hudi-common's `HoodieFileGroup` file-slice attribution logic; line numbers are from the 1.1 branch and may differ slightly in the community release):
**(1) Bucketing puts the failed write and later successful writes into the same FileGroup.**
With the BUCKET index, all logs in a bucket share the same fileId (the bucket number). `AbstractTableFileSystemView.buildFileGroups` groups by `HoodieLogFile::getFileId` (`AbstractTableFileSystemView.java:287`), so bucket B's failed-write log (t2) and later successful-write logs (t3, t4) all fall into one FileGroup.
**(2) With no base file, the earliest log's deltacommit becomes the slice base instant — without checking whether it is committed.**
Logs are processed in ascending deltacommit order. `HoodieFileGroup.getBaseInstantTime` (`HoodieFileGroup.java:192-194`):
```java
if (fileSlices.isEmpty()) {
// no base file in the file group, use the log file delta commit time.
return logFile.getDeltaCommitTime(); // uses the earliest log's deltacommit directly, no completed check
}
```
Bucket B's earliest log is exactly the failed t2 (instant time t2 < t3 < t4), so the slice's base instant is anchored on the uncommitted t2.
**(3) The successful t3, t4 are routed by completion time into the same t2 slice.**
`completion(t3) >= t2` holds (`HoodieFileGroup.java:196-201`), so t3 and t4 are attached to the slice whose base instant = t2. Bucket B ends up with a single slice anchored on the uncommitted t2.
**(4) getAllFileSlices filters out that whole slice.**
```java
// HoodieFileGroup.java:224-230 isFileSliceCommitted
return timeline.containsOrBeforeTimelineStarts(slice.getBaseInstantTime()); // baseInstant = t2
```
`containsOrBeforeTimelineStarts(t2)` = `containsInstant(t2) || isBeforeTimelineStarts(t2)` (`BaseHoodieTimeline.java:480-482`). t2 never completed → both are false → returns false. `getAllFileSlices` (`HoodieFileGroup.java:249-251`) therefore discards the entire slice, including the already-committed t3/t4 data attached under it.
**(5) filterUncommittedFiles cannot recover it.**
The `filterUncommittedFiles` in `getLatestFileSlices` (`AbstractTableFileSystemView.java:750-767`) runs *after* `getAllFileSlices`; the slice is already gone by then. It also reuses the original base instant when constructing the new slice, so even if it ran it would not change the anchor.
**Trigger condition (key):** the earliest log in a bucket comes from an uncommitted failed write — it seizes the slice's base-instant anchor. If any successfully committed log/base file exists in the bucket before the failed write, the anchor lands on a committed instant and the failed file is only dropped at file granularity by `filterUncommittedFiles`, without taking down the whole slice.
--
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: commits-unsubscribe@hudi.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
Posted by "zhaoyudi-creator (via GitHub)" <gi...@apache.org>.
zhaoyudi-creator commented on issue #19774:
URL: https://github.com/apache/hudi/issues/19774#issuecomment-5454432139
@danny0405 I'd like to break uncommitted file slices into two categories and check whether the distinction holds up:
Category 1 — the base instant corresponds to a base file. This is exactly the case you raised: "an uncommitted base file at t2 (leftover from a failed compaction / bulk_insert, not rolled back under LAZY) sharing a file group with later committed delta logs." I agree this one must stay as-is and remain hidden: the pre-V8 read path doesn't run filterUncommittedFiles, and filterBaseFileAfterPendingCompaction only covers pending compaction, so nothing can strip an orphan base file — once the slice is admitted, the base file is read in full. (And under the BUCKET index the fileId is fixed by the bucket number, so later committed writes to the same bucket necessarily land in the same file group as the orphan base file — which makes this leak reachable in exactly the configuration this issue reports.)
Category 2 — log files only, no base file. This is the case reported here. Even though the base instant (the earliest, failed log's instant) is uncommitted, admitting this slice doesn't leak anything: there's no base file, and any uncommitted log block is filtered out block-by-block by the log reader against the completed timeline (BaseHoodieLogRecordReader skips blocks that are inflight / not on the completed timeline).
So I'm wondering whether we could use getBaseFile().isPresent() to separate the two and only admit the second:
`private boolean isFileSliceCommitted(FileSlice slice) {
if (!compareTimestamps(slice.getBaseInstantTime(), LESSER_THAN_OR_EQUALS, lastInstant.get().requestedTime())) {
return false;
}
if (timeline.containsOrBeforeTimelineStarts(slice.getBaseInstantTime())) {
return true;
}
if (slice.getBaseFile().isPresent()) {
return false; // Category 1: an uncommitted slice that carries a base file keeps its original semantics — never revived by a log
}
return slice.getLogFiles()
.anyMatch(lf -> timeline.containsOrBeforeTimelineStarts(lf.getDeltaCommitTime()));
}`
For any slice that has a base file this is byte-for-byte identical to the pre-patch behavior, so the pre-V8 base-file exposure you're worried about is kept out by this guard; only log-only slices go through the committed-log path.
A few things I'd appreciate your take on:
Is this "don't admit a slice that carries a base file" guard enough to cover the inconsistent pre-V8 slices you mentioned? Beyond the base file, is there any exposure path I'm missing?
Even with the guard, a Category-2 slice still keeps its base instant on the failed t2 (only its visibility is corrected). Is your preference for patch 1 mainly about moving the anchor onto a valid committed instant, so this "identity" issue is avoided at the root?
If Category 2 is also handled by re-anchoring at construction time (patch 1), then isFileSliceCommitted wouldn't need to change at all — is that the route you'd rather take?
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on issue #19774:
URL: https://github.com/apache/hudi/issues/19774#issuecomment-5453898160
patch 2 is not right, just ignore it.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on issue #19774:
URL: https://github.com/apache/hudi/issues/19774#issuecomment-5450285477
@zhaoyudi-creator I have updated the comments and also the patch, pls verify.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on issue #19774:
URL: https://github.com/apache/hudi/issues/19774#issuecomment-5453997880
After further compatibility analysis, I think **patch 1 is the correct fix** and patch 2 should not be used.\n\n- Patch 1: https://github.com/apache/hudi/issues/19774#issuecomment-5449553257\n- Patch 2: https://github.com/apache/hudi/issues/19774#issuecomment-5451608691\n\nThe failing state is produced by NBCC when a new, log-only file group is reconstructed with out-of-order completion:\n\n\n\nIf the logs are added one at a time, creates an uncommitted slice first and the completed log is then assigned to that slice. The existing check hides the whole slice.\n\nPatch 1 fixes the root cause during file-group construction. It sorts and adds the logs as a batch and, when the file group has no existing slice, establishes the earliest completed log as the initial slice anchor before assigning the pending logs. The pending log then follows the existing rule of attaching to the latest slice, while the slice remains visible through the committed anchor.\n\nThis is also compatible wi
th the legitimate sources of uncommitted base files:\n\n1. A base file left by a failed is not published as a valid record location, so later writers do not append logs to that slice. The base-only uncommitted slice should continue to be ignored.\n2. A base file produced by pending compaction belongs to an intentional slice barrier. The compaction instant makes the slice eligible, and the filesystem view already removes the uncommitted base file: pre-V8 uses , while V8+ uses .\n\nPatch 2 instead broadens so that any committed log can make a slice with an uncommitted base instant visible. That changes a general visibility invariant to handle an NBCC construction-order bug and can expose inconsistent pre-V8 slices containing an actual uncommitted base file that is not covered by pending-compaction filtering. Pre-V8 log-block filtering cannot remove such a base file.\n\nTherefore patch 1 is the more targeted fix: it corrects the reachable NBCC log-only case at slice construction time
, preserves the existing slice-visibility invariant, and leaves the established pre-V8 and V8+ file filtering behavior unchanged.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on issue #19774:
URL: https://github.com/apache/hudi/issues/19774#issuecomment-5451608691
An alternative—and currently my preferred fix—is to make the minimal change in `isFileSliceCommitted`, without changing file-group construction.
A file slice's base instant acts as a slicing barrier; it does not necessarily have to be committed itself. This is analogous to a pending compaction instant. If the first physical file is a pending log at `t2`, the existing attribution creates a slice at `t2`, and later completed logs `t3`/`t4` correctly remain in that slice. The actual bug is that slice visibility currently checks only the barrier instant and discards the entire slice before V8+ file-level filtering can run.
The slice should be considered committed/visible when either its base instant is on the timeline or at least one contained log belongs to a committed delta instant:
```java
private boolean isFileSliceCommitted(FileSlice slice) {
if (!compareTimestamps(
slice.getBaseInstantTime(),
LESSER_THAN_OR_EQUALS,
lastInstant.get().requestedTime())) {
return false;
}
return timeline.containsOrBeforeTimelineStarts(slice.getBaseInstantTime())
|| slice.getLogFiles()
.anyMatch(logFile -> timeline.containsOrBeforeTimelineStarts(logFile.getDeltaCommitTime()));
}
```
For the reported sequence:
```text
raw slice t2: [t2 (pending), t3, t4]
visible slice t2: [t3, t4]
```
Once the slice passes this check, the existing V8+ `filterUncommittedFiles` removes the pending `t2` log and retains the committed `t3`/`t4` logs. A slice containing only pending files remains hidden from committed APIs and remains accessible through the explicit including-inflight APIs.
This also keeps pre-V8/0.x compatibility: legacy writers query the latest valid base instant before writing and encode the selected base instant in the log filename. No new batch API, sorting relocation, or visibility change to `addLogFile` is needed.
### Alternative minimal patch
[Download `hudi-19774.patch`](https://gist.githubusercontent.com/danny0405/c864bd3e40802725b910667072e4a6d5/raw/ab802130e4d14ee72177e2ee0c7cc50d4bd5e7e8/hudi-19774.patch) · [View this patch revision on GitHub](https://gist.github.com/danny0405/c864bd3e40802725b910667072e4a6d5/fea80f9778e1677dd0464e98b4e2cd49e81cf1b0)
Regression coverage should verify that a slice anchored by an uncommitted first log is retained because it contains later committed logs, while the reader view filters only the uncommitted physical log.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on issue #19774:
URL: https://github.com/apache/hudi/issues/19774#issuecomment-5449553257
I reproduced this and agree the fix should happen while the file group is constructed, rather than by weakening `isFileSliceCommitted` or treating a slice as committed merely because it contains a committed log.
The key issue is that `addLogFile` cannot choose the correct initial base instant when it sees only the failed leading log. The filesystem view already has the complete set of logs for the file group, so the proposed fix adds them as a batch:
1. Sort all logs by delta-commit time inside `HoodieFileGroup`.
2. If there is no existing base/compaction slice, find the earliest completed log and establish its instant as the initial slice base.
3. Add every log in the original delta-commit order. Earlier pending logs then follow the existing pending-log rule and attach to the latest slice.
4. Keep `isFileSliceCommitted` unchanged; it still validates the slice anchor, while the V8+ read-view filtering removes individual uncommitted files from that valid slice.
For the reported sequence, the result becomes:
```text
raw slice t3: [t2 (failed), t3, t4]
visible slice t3: [t3, t4]
```
There is no separate slice anchored at the uncommitted `t2`.
<details>
<summary>Proposed production patch</summary>
```diff
diff --git a/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieFileGroup.java b/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieFileGroup.java
index 89088cb14190..38329fcbab69 100644
--- a/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieFileGroup.java
+++ b/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieFileGroup.java
@@ -32,6 +32,7 @@ import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
import java.util.TreeMap;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -117,7 +118,7 @@ public class HoodieFileGroup implements Serializable {
*
* <p>CAUTION: the log file must be added in sequence of the delta commit time.
*/
- public void addLogFile(CompletionTimeQueryView completionTimeQueryView, HoodieLogFile logFile) {
+ private void addLogFile(CompletionTimeQueryView completionTimeQueryView, HoodieLogFile logFile) {
String baseInstantTime = getBaseInstantTime(completionTimeQueryView, logFile);
if (!fileSlices.containsKey(baseInstantTime)) {
fileSlices.put(baseInstantTime, new FileSlice(fileGroupId, baseInstantTime));
@@ -125,6 +126,28 @@ public class HoodieFileGroup implements Serializable {
fileSlices.get(baseInstantTime).addLogFile(logFile);
}
+ /**
+ * Add log files into the group.
+ *
+ * <p>When the group has no existing slice, the first completed log establishes the initial slice before any logs
+ * are added. This allows an earlier pending log to follow the normal pending-log rule and attach to the latest slice,
+ * instead of creating an uncommitted slice that would also hide later committed logs.
+ */
+ public void addLogFiles(CompletionTimeQueryView completionTimeQueryView, List<HoodieLogFile> logFiles) {
+ if (fileSlices.isEmpty()) {
+ List<HoodieLogFile> sortedLogFiles = logFiles.stream()
+ .sorted(HoodieLogFile.getLogFileComparator()).collect(Collectors.toList());
+ sortedLogFiles.stream()
+ .filter(logFile -> completionTimeQueryView.isCompleted(logFile.getDeltaCommitTime()))
+ .findFirst()
+ .ifPresent(logFile -> addNewFileSliceAtInstant(logFile.getDeltaCommitTime()));
+ sortedLogFiles.forEach(logFile -> addLogFile(completionTimeQueryView, logFile));
+ } else {
+ logFiles.stream().sorted(HoodieLogFile.getLogFileComparator())
+ .forEach(logFile -> addLogFile(completionTimeQueryView, logFile));
+ }
+ }
+
@VisibleForTesting
public String getBaseInstantTime(CompletionTimeQueryView completionTimeQueryView, HoodieLogFile logFile) {
diff --git a/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java b/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java
index 75118b90bb2c..f768c6880def 100644
--- a/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java
+++ b/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java
@@ -256,8 +256,7 @@ public abstract class AbstractTableFileSystemView implements SyncableFileSystemV
}
if (logFiles.containsKey(fileId)) {
// this should work for both table versions >= 8 and lower.
- logFiles.get(fileId).stream().sorted(HoodieLogFile.getLogFileComparator())
- .forEach(logFile -> group.addLogFile(completionTimeQueryView, logFile));
+ group.addLogFiles(completionTimeQueryView, logFiles.get(fileId));
}
fileGroups.add(group);
});
```
</details>
Regression coverage constructs an MOR file group with `t2` inflight and `t3`/`t4` completed, verifies that the raw view has exactly one slice based at `t3` containing all three logs, and verifies that the V8+ visible view filters only `t2` while retaining `t3`/`t4`. The unit regression deliberately supplies the logs out of order to verify that sorting is owned by `addLogFiles`.
Compatibility notes:
* Existing base files and pending-compaction slices remain authoritative because the initial-base lookup runs only when `fileSlices` is empty.
* If every log is pending, the existing provisional pending-slice behavior is retained.
* Table-version-6/pre-V8 log naming continues to use the encoded base instant; the existing version-6 slicing tests pass through the new batch API.
Focused result: `TestHoodieFileGroup` passes all 8 tests, including both pre-V8 and V8+ slicing cases.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 closed issue #19774: [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries
URL: https://github.com/apache/hudi/issues/19774
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
Posted by "zhaoyudi-creator (via GitHub)" <gi...@apache.org>.
zhaoyudi-creator commented on issue #19774:
URL: https://github.com/apache/hudi/issues/19774#issuecomment-5450233997
Thanks for the reply, and I agree with your approach — I've actually made the fix along the same lines and verified it: during file group construction, use the instant of the earliest completed (committed) log file as the base instant of the file slice. Next I'll compare your patch against my own solution and confirm it passes the regression on TestHoodieFileGroup. I'll follow up once I have the results. Thanks again!
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [BUG] MOR + BUCKET + NBCC: when a bucket's earliest write is an uncommitted (file-written-but-not-committed) failed write, the entire bucket's later committed data is silently dropped from snapshot queries [hudi]
Posted by "zhaoyudi-creator (via GitHub)" <gi...@apache.org>.
zhaoyudi-creator commented on issue #19774:
URL: https://github.com/apache/hudi/issues/19774#issuecomment-5618546267
@danny0405
> [@danny0405](https://github.com/danny0405) I'd like to break uncommitted file slices into two categories and check whether the distinction holds up:
>
> Category 1 — the base instant corresponds to a base file. This is exactly the case you raised: "an uncommitted base file at t2 (leftover from a failed compaction / bulk_insert, not rolled back under LAZY) sharing a file group with later committed delta logs." I agree this one must stay as-is and remain hidden: the pre-V8 read path doesn't run filterUncommittedFiles, and filterBaseFileAfterPendingCompaction only covers pending compaction, so nothing can strip an orphan base file — once the slice is admitted, the base file is read in full. (And under the BUCKET index the fileId is fixed by the bucket number, so later committed writes to the same bucket necessarily land in the same file group as the orphan base file — which makes this leak reachable in exactly the configuration this issue reports.)
>
> Category 2 — log files only, no base file. This is the case reported here. Even though the base instant (the earliest, failed log's instant) is uncommitted, admitting this slice doesn't leak anything: there's no base file, and any uncommitted log block is filtered out block-by-block by the log reader against the completed timeline (BaseHoodieLogRecordReader skips blocks that are inflight / not on the completed timeline).
>
> So I'm wondering whether we could use getBaseFile().isPresent() to separate the two and only admit the second:
>
> private boolean isFileSliceCommitted(FileSlice slice) {
> if (!compareTimestamps(slice.getBaseInstantTime(), LESSER_THAN_OR_EQUALS, lastInstant.get().requestedTime())) {
> return false;
> }
> if (timeline.containsOrBeforeTimelineStarts(slice.getBaseInstantTime())) {
> return true;
> }
> if (slice.getBaseFile().isPresent()) {
> return false; // Category 1: an uncommitted slice that carries a base file keeps its original semantics — never revived by a log
> }
> return slice.getLogFiles()
> .anyMatch(lf -> timeline.containsOrBeforeTimelineStarts(lf.getDeltaCommitTime()));
> }
> For any slice that has a base file this is byte-for-byte identical to the pre-patch behavior, so the pre-V8 base-file exposure you're worried about is kept out by this guard; only log-only slices go through the committed-log path.
>
> A few things I'd appreciate your take on:
>
> Is this "don't admit a slice that carries a base file" guard enough to cover the inconsistent pre-V8 slices you mentioned? Beyond the base file, is there any exposure path I'm missing? Even with the guard, a Category-2 slice still keeps its base instant on the failed t2 (only its visibility is corrected). Is your preference for patch 1 mainly about moving the anchor onto a valid committed instant, so this "identity" issue is avoided at the root? If Category 2 is also handled by re-anchoring at construction time (patch 1), then isFileSliceCommitted wouldn't need to change at all — is that the route you'd rather take?
Switched the fix to **patch 1 (re-anchor at file-group construction)**.
### Why not patch 2
The approach I originally proposed still has issues: it leaves the slice keyed on an **uncommitted** instant and only carves out an exception in the visibility gate to surface it — treating the symptom, not the cause. It also misses the read paths that don't trim (e.g. the legacy Hive/MR incremental realtime read), and any newly added view API that forgets to trim would re-introduce the leak.
### Why patch 1 is better
1. **Fixes the root cause** — the earliest *completed* log establishes the initial slice, so the slice's base instant is itself committed; an earlier uncommitted log degrades to a pending log attached to that slice.
2. **Version-agnostic** — patch 2's rescue branch only kicks in on v8+, so the semantics diverge across versions; patch 1 is driven by completion time and behaves the same on v6 and v8+.
3. **Localized change** — everything lives at file-group construction. The sorting contract is pulled back inside: `addLogFiles` owns the sort + re-anchoring, and `addLogFile` becomes `private`.
Branch updated accordingly.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org