fabientra commented on issue #13570:
URL: https://github.com/apache/gluten/issues/13570#issuecomment-6952055815
Thanks for looking into it!
1. **Filters.** With only partition predicates (day and bucket), the native
scan is exact even with the default batch settings. With one extra column
predicate (`platform = 'android'`) on a larger partition with many position
deletes, the defaults lost 17,951 / 19,179 / 19,069 rows in 3 runs, and
`preferredBatchBytes=1g` was exact 9 of 9. This fits the root cause: the scan
batch grows only when the first batch is filtered down (`maxFilteringRatio_`),
and rows are lost only in the batch where the bitmap grows.
2. **Lost rows.** New runs today, on the current snapshot (expected
39,070,902 rows; it has more position deletes since a later delete commit):
`count(DISTINCT id)` equals `count(*)` in every run, and the count is never
above the expected value, so no row is duplicated, only dropped. Comparing
counts per `user_id` with Spark's reader, each lossy run loses rows of only 1
to 10 of the 76,207 users (11 distinct users over 5 runs), so the loss is a few
dense chunks of rows, not a thin spread. The same sets of rows also repeat
across runs and across the 1.7.0 and 1.8.0 nightlies (same `count` and
`bit_xor(xxhash64(id))`). I could not get exact row positions: with `_file` /
`_pos` in the projection, the same query read exact (it looks like the scan
then falls back to Spark's reader).
3. **Concurrency.** It reproduces with `spark.executor.cores=1`: 6 of 6 runs
lost rows (−82 to −289), on a new engine with one task per executor. Earlier,
`IOThreads=0`, `SplitPreloadPerDriver` and a 1 GB split size (4 tasks instead
of 39) did not help either, while the batch-size arms of the root-cause comment
switch the loss on and off in the same engine.
4. **Unpartitioned table.** `add_files` registers data files only, so such a
copy would have no position deletes. Instead, I copied the rows of the affected
file into a new unpartitioned v2 table (5 data files, 3.67 M rows) and deleted
1,047 rows with merge-on-read (5 position delete files). I could **not**
reproduce on it: 22 of 22 native reads were exact, with and without a filter
(`name = '<one event name>'` keeps 47% of the rows), also right after
`db.events` reads that lost rows on the same engine. Partitioning is not in the
code path, so my guess is that the small copy gives too few chances: 5 files of
one split each, against many more splits and batches in the `db.events` scan,
where the loss already concentrates in a few chunks.
5. **Metadata.**
- Table: Iceberg format-version 2, merge-on-read (`write.delete.mode`,
`write.update.mode`, `write.merge.mode`), partitioned by
`day(server_created_at)` and `bucket(8, app_id)`, sorted on 5 columns. Schema
evolution: 2 columns added, and 1 column dropped and added again (new field
id). The file was written with the current 46-column schema.
- File: written by `parquet-mr version 1.15.2` (Iceberg's Spark writer),
ZSTD, v1 encodings (PLAIN, PLAIN_DICTIONARY, RLE, BIT_PACKED), column index and
offset index on all 240 column chunks, dictionary pages on 186 of them. 48 leaf
columns, 34 of them strings.
- Row groups (rows, uncompressed bytes per row): 1,897,054 (224), 596,262
(3,928), 578,683 (4,182), 575,506 (4,180), 20,763 (4,127). The jump after row
group 0 is why splits that start in row groups 1-4 get a ~2,500-row first batch
that then grows to 4,096.
6. **7,083-row gap.** The plain Parquet read of the 15 files gives more
rows: 39,132,154 against 39,125,071 for Spark's Iceberg reader. The 7,083 rows
are the deleted positions that match the query, which a plain Parquet read does
not apply. The 15 files are the data files of that partition with rows of this
app at that snapshot.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]