Skip to content

[Bug]: Spark-generated Iceberg Parquet table fails to read even with one row #27196

Closed

Description

@Ariznawlll

Description

MatrixOne cannot read a supported external Iceberg v2 table generated by Spark when the data file uses the NYC TLC Parquet schema. The failure is not scale-dependent: it reproduces with a table containing only 1 row.

The same Iceberg snapshot is readable by Spark. MatrixOne's small deterministic Iceberg tables also work, so catalog connectivity, Nessie, MinIO, credentials, and the basic Iceberg read path are healthy.

This bug was found while validating #23359 with the published Iceberg external-table test design.

Environment

  • Branch: main
  • Commit: 1f9e501594509fb5d2e0284833faf8c3426e2285
  • Test date: 2026-08-16
  • MatrixOne deployment: local 1 CN + 1 TN + 1 LogService
  • External services: Nessie REST catalog + MinIO S3-compatible object storage
  • Spark: 3.5.1
  • Iceberg Spark runtime: 1.6.1
  • Table format: Iceberg v2, partitioned by months(tpep_pickup_datetime)
  • Source Parquet: NYC TLC Yellow Taxi 2024-01

Steps to reproduce

The repository already contains the complete seed and comparison harness. The following is the smallest reproducible path.

1. Build MatrixOne and start the local Iceberg services

git checkout 1f9e501594509fb5d2e0284833faf8c3426e2285
make build
make dev-up-iceberg-tier-a

# Start MatrixOne in another terminal.
./mo-service -launch etc/launch-minio-local/launch.toml

Wait until MatrixOne accepts connections on 127.0.0.1:6001 and Nessie is available on 127.0.0.1:19120.

2. Seed only one Spark row into an Iceberg v2 table

Use a local MySQL client command template with valid local credentials; do not commit credentials into the repository.

export MO_ICEBERG_NYC_TLC_ROW_LIMIT=1
export MO_ICEBERG_MO_SQL_CMD='mysql -h 127.0.0.1 -P 6001 -u root -p<local-password> -e {sql}'
export MO_ICEBERG_MO_QUERY_SQL_CMD='mysql -h 127.0.0.1 -P 6001 -u root -p<local-password> --batch --raw --skip-column-names -e {sql}'

make dev-seed-iceberg-tier-b-nyc-tlc

The seed executes etc/launch-minio-local/tier-b/seed_nyc_tlc.spark.sql, creates tiera.public_nyc_tlc.yellow_tripdata, and maps it to iceberg_tier_b.yellow_tripdata in MatrixOne.

The relevant Spark table definition is:

CREATE TABLE tiera.public_nyc_tlc.yellow_tripdata
USING iceberg
PARTITIONED BY (months(tpep_pickup_datetime))
TBLPROPERTIES (
  'format-version'='2',
  'write.delete.mode'='merge-on-read',
  'write.update.mode'='merge-on-read',
  'write.merge.mode'='merge-on-read'
)
AS
SELECT *
FROM (
  SELECT
    CAST(`VendorID` AS INT) AS vendor_id,
    CAST(tpep_pickup_datetime AS TIMESTAMP) AS tpep_pickup_datetime,
    CAST(tpep_dropoff_datetime AS TIMESTAMP) AS tpep_dropoff_datetime,
    CAST(passenger_count AS INT) AS passenger_count,
    CAST(trip_distance AS DOUBLE) AS trip_distance,
    CAST(`RatecodeID` AS INT) AS rate_code_id,
    CAST(store_and_fwd_flag AS STRING) AS store_and_fwd_flag,
    CAST(`PULocationID` AS INT) AS pu_location_id,
    CAST(`DOLocationID` AS INT) AS do_location_id,
    CAST(payment_type AS INT) AS payment_type,
    CAST(fare_amount AS DECIMAL(12,2)) AS fare_amount,
    CAST(extra AS DECIMAL(12,2)) AS extra,
    CAST(mta_tax AS DECIMAL(12,2)) AS mta_tax,
    CAST(tip_amount AS DECIMAL(12,2)) AS tip_amount,
    CAST(tolls_amount AS DECIMAL(12,2)) AS tolls_amount,
    CAST(improvement_surcharge AS DECIMAL(12,2)) AS improvement_surcharge,
    CAST(total_amount AS DECIMAL(12,2)) AS total_amount,
    CAST(congestion_surcharge AS DECIMAL(12,2)) AS congestion_surcharge,
    CAST(`Airport_fee` AS DECIMAL(12,2)) AS airport_fee
  FROM parquet.`yellow_tripdata_2024-01.parquet`
  WHERE tpep_pickup_datetime >= TIMESTAMP '2024-01-01 00:00:00'
    AND tpep_pickup_datetime < TIMESTAMP '2024-02-01 00:00:00'
  LIMIT 1
) src;

3. Confirm the Spark control

SELECT COUNT(*)
FROM tiera.public_nyc_tlc.yellow_tripdata;

Spark returns:

1

4. Query the same Iceberg snapshot from MatrixOne

SELECT COUNT(*)
FROM iceberg_tier_b.yellow_tripdata;

Repeat the query three times on a fresh mapped table.

5. Run the repository Tier B comparison (optional full check)

set -a
source etc/launch-minio-local/tier-b/tier_b_nyc_tlc.generated.env
set +a

MO_ICEBERG_CI_PROFILE=tier-b make test-iceberg-nightly

Actual behavior

The MatrixOne query fails 3/3 even with one row. Depending on the query shape, the error is one of:

ERROR 20400 (HY000): invalid state ICEBERG_OBJECT_IO: Iceberg signed HTTP response is too large to materialize [max_bytes=536870912, signed_url=<redacted>]
ERROR 20400 (HY000): ICEBERG_OBJECT_IO: Iceberg row-group footer read failed [file=<redacted>]

The error is inconsistent with the physical object size. In the 200,000-row control, the two data files were only:

437,541 bytes / 25,866 records
3,032,314 bytes / 174,134 records

Both are far below the reported 512 MiB materialization limit.

Expected behavior

MatrixOne should read the Spark-generated Iceberg v2 table and return the same rows as Spark. For the minimal reproducer:

COUNT(*) = 1

Stability and controls

  • Minimal reproducer: 3/3 failed at 1 row.
  • Scale boundary: 1, 1,000, 10,000, 50,000, 100,000 and 200,000 rows all reproduced the failure; each focused count was repeated 3 times.
  • Spark oracle: passed and returned the expected row count from the same snapshot.
  • MatrixOne deterministic local Iceberg E2E control: 3 fresh runs, 12/12 subcases passed (catalog, append/read, time travel, partition filter, merge-on-read delete).
  • Topology control: reproduced on both MinIO-backed MatrixOne fileservice and a fresh standard local DISK-V2 MatrixOne launch.
  • Service health: no MatrixOne panic, OOM or restart was observed; all test databases and external mappings were cleaned up.
  • This is not a big-data-only bug: one row is sufficient.

Evidence

The repository's Tier B runner produced the following failures on all three rounds:

ICE-TEST-130_public_dataset_count_filter: query_failed
ICE-TEST-130_public_dataset_limit_projection: query_failed
ICE-TEST-130_public_dataset_location_aggregation: query_failed

Example MatrixOne SQL and error:

select count(*) as c
from iceberg_tier_b.yellow_tripdata
where tpep_pickup_datetime >= timestamp '2024-01-01 00:00:00'
  and tpep_pickup_datetime < timestamp '2024-02-01 00:00:00';

ERROR 20400 (HY000): ICEBERG_OBJECT_IO: Iceberg row-group footer read failed

Code analysis

Confirmed error locations on the tested commit:

  • pkg/iceberg/io/signed_http_fs.go: signedHTTPFileService.materializedReadTooLarge emits the 512 MiB error.
  • pkg/iceberg/metadata/row_group_parquet.go: readParquetRowGroupFooters wraps parquet.OpenFile failures as Iceberg row-group footer read failed.

Hypothesis: a range/size contract mismatch between the signed HTTP object reader and Parquet ReaderAt causes a small Spark-generated Parquet object to be handled as an unbounded/full response, or returns incorrect bytes for footer reads. This is a hypothesis, not yet a confirmed root cause.

Regression coverage

After the fix, add:

  1. A deterministic Spark-generated one-row Iceberg v2 fixture in the external Iceberg/MOTR scenario suite using Nessie + MinIO. Assert COUNT(*), ordered projection, aggregation and row values against Spark.
  2. Keep the existing 200,000-row NYC TLC Tier B smoke.
  3. Run the full NYC month only in nightly big-data after the one-row correctness path passes; large data is not required to reproduce this defect.

Do not baseline the current error as expected behavior.

Related

Activity

  1. added this to the MO-202608 milestone on Aug 16, 2026
  2. added
    kind/bug
    on Aug 16, 2026
  3. added theissue type on Aug 16, 2026
  4. Ariznawlll commented on Aug 16, 2026

    @Ariznawlll
    CollaboratorAuthor

    补充最新 main@1f9e501594509fb5d2e0284833faf8c3426e2285 的原生 MinIO + Nessie 复现证据(非 Docker 环境):

    • MinIO RELEASE.2025-09-06T17-38-46Z,Nessie 0.108.4,Spark 3.5.1 + Iceberg 1.6.1。
    • NOAA 2019/2020 Iceberg v2 表:73,302,108 行、16 个 data file;MatrixOne 全表与分组读取 3/3 仍出现 signed HTTP request too large 或 row-group footer read error。
    • 另一个 64-file/640-row 表在 iceberg_rewrite_data_files 合并为 1 个文件后,MatrixOne 3/3 同样出现 signed HTTP 读取失败;Spark 对同一新 snapshot 读取正常、行数及 checksum 不变。
    • 对照:3 个 8-file/80-row 表重写为 1 文件后,MatrixOne 均能正常读取 80 行、checksum=3160。
    • 服务在错误后保持健康,无 panic/OOM/restart。

    这说明问题不依赖 Docker,也不只存在于原报告的数据源;它与生成对象的布局/大小或 footer/range 获取路径相关。64-file 重写后的读取失败继续归入本 issue,没有重复新建 bug。独立的维护返回元数据错误已拆为 #27201。

  5. added
    ai-easy
    on Aug 18, 2026
  6. Ariznawlll commented on Aug 19, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:b5c948130897783c544e12ab83bfd94702282f89
    • 测试日期:2026-08-19
    • 环境:macOS arm64;Iceberg signed HTTP range 和 Parquet footer 回归

    原问题验证

    原问题是 Spark 生成的 NYC TLC Iceberg v2 Parquet 表即使只有 1 行,MatrixOne 读取也会因 signed HTTP range 响应分片导致 row-group footer 读取失败;该问题不是大数据量专属。

    Happy Path 覆盖

    1. TestSignedHTTPFileServiceReadsFragmentedKnownLengthResponse:已知长度且被分片的 signed range 响应完整读取,3/3 通过。
    2. TestLocalScanPlannerReadsFragmentedSignedParquetFooterThroughProvider:通过真实 provider → object reader → Parquet footer 路径读取 1 行 fixture,3/3 通过。

    Unhappy Path 覆盖

    TestSignedHTTPFileServiceRejectsTruncatedKnownLengthResponse 覆盖响应体截断,正确返回 io.ErrUnexpectedEOF,不会把不完整数据当作成功读取。

    白盒验证

    执行 go test ./pkg/iceberg/io -run 'TestSignedHTTPFileServiceReadsFragmentedKnownLengthResponse|TestSignedHTTPFileServiceRejectsTruncatedKnownLengthResponse' -count=3 和 go test ./pkg/iceberg/metadata -run '^TestLocalScanPlannerReadsFragmentedSignedParquetFooterThroughProvider$' -count=3,全部通过。对应修复为 PR #27204,commit 0d7ad8b6b。

    回归测试

    该场景依赖 Spark/Nessie/MinIO 和外部 Iceberg 表,不适合普通 MOTR SQL suite;保留 Iceberg Tier B/nightly 外部表回归。

    大数据评估

    不需要新增 big-data。原问题 1 行即可触发;现有 200,000 行 NYC TLC smoke 可继续作为 nightly 守护,但不是本缺陷的必要覆盖。

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions