Skip to content

Validate Iceberg schema evolution before the constant column and row count shortcuts - #2944

Draft
ianton-ru wants to merge 1 commit into
antalya-26.8from
bugfix/antalya-26.8/iceberg-schema-check-before-shortcuts
Draft

ianton-ru wants to merge 1 commit into
antalya-26.8from
bugfix/antalya-26.8/iceberg-schema-check-before-shortcuts

Conversation

@ianton-ru

Copy link
Copy Markdown

StorageObjectStorageSource::createReader has two shortcuts that answer without reading the data file: constant columns taken from the file statistics (allow_experimental_iceberg_read_optimization) and the cached row count (use_cache_for_count_from_files). Both skipped getSchemaTransformer, which is where Iceberg rejects metadata that violates the specification, so the outcome for the same metadata depended on the file statistics and on the cache:

  • A primitive column turned into a struct: every column of a single-row file is constant, so the read needed nothing from the file. When the row count was cached, the statistics value of the old type (Int64) was inserted into a column of the new type (Tuple) and the query failed with BAD_GET instead of ICEBERG_SPECIFICATION_VIOLATION. When the cache entry was not valid, the file was read and the expected exception was raised. The cache entry is valid only if the data file is older than the entry, compared in whole seconds, so 04890_iceberg_metadata_spec_violation_no_abort failed about once per ten runs.
  • A required column added to the schema: SELECT count() was answered from the cached row count and returned a result for metadata that SELECT * rejects.

The change calls getSchemaTransformer for the file before the shortcuts. It returns immediately for a file written under the current schema, and the transformation is cached per pair of schemas.

The new test 05814_iceberg_schema_evolution_validated_before_shortcuts fills the row count cache and then evolves the schema. It fails with BAD_GET and with a returned count without the change. All 119 Iceberg functional tests pass in docker through Praktika on a build of antalya-26.8 with the change.

The flaky failure was seen in https://altinity-build-artifacts.s3.amazonaws.com/json.html?PR=2917&sha=939a6bde149e96eedf97bbdf1d3df5f285f1d502&name_0=PR&name_1=Stateless+tests+%28amd_binary%2C+cas+s3+storage%2C+parallel%29&name_2=Tests

Related: #2917

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Validate the Iceberg schema evolution of a data file before answering from file statistics or from the cached row count, so metadata that violates the specification is rejected with ICEBERG_SPECIFICATION_VIOLATION instead of failing with BAD_GET or returning a result.

Documentation entry for user-facing changes

Not needed.

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

…count shortcuts

`StorageObjectStorageSource::createReader` has two shortcuts that answer without reading the data
file: constant columns taken from the file statistics (`allow_experimental_iceberg_read_optimization`)
and the cached row count (`use_cache_for_count_from_files`). Both skipped `getSchemaTransformer`,
which is where Iceberg rejects metadata that violates the specification, so the outcome for the
same metadata depended on the file statistics and on the cache:

- A primitive column turned into a struct: every column of a single-row file is constant, so the
  read needed nothing from the file. When the row count was cached, the statistics value of the old
  type (`Int64`) was inserted into a column of the new type (`Tuple`) and the query failed with
  `BAD_GET` instead of `ICEBERG_SPECIFICATION_VIOLATION`. When the cache entry was not valid, the
  file was read and the expected exception was raised. The cache entry is valid only if the data
  file is older than the entry, compared in whole seconds, so
  `04890_iceberg_metadata_spec_violation_no_abort` failed about once per ten runs.
- A required column added to the schema: `SELECT count()` was answered from the cached row count
  and returned a result for metadata that `SELECT *` rejects.

Call `getSchemaTransformer` for the file before the shortcuts. It returns immediately for a file
written under the current schema, and the transformation is cached per pair of schemas.

Add a test that fills the row count cache and then evolves the schema. It fails with `BAD_GET` and
with a returned count without the change.

CI report: https://altinity-build-artifacts.s3.amazonaws.com/json.html?PR=2917&sha=939a6bde149e96eedf97bbdf1d3df5f285f1d502&name_0=PR&name_1=Stateless+tests+%28amd_binary%2C+cas+s3+storage%2C+parallel%29&name_2=Tests
Related: #2917

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown

Workflow [PR], commit [90f1635]

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants