Skip to content

Revert "Revert "Revert "Add SZ3 compression codec""" - #84358

Merged
Algunenano merged 4 commits into
masterfrom
revert-83088
Jul 24, 2025
Merged

Algunenano merged 4 commits into
masterfrom
revert-83088

Conversation

@Algunenano

@Algunenano Algunenano commented Jul 24, 2025 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

This reverts commit 29032ae / Adds SZ3 compression codec

Closes #84345

@clickhouse-gh

clickhouse-gh Bot commented Jul 24, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [03eba5f]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_binary, old analyzer, s3 storage, DatabaseReplicated, parallel) failure
01396_inactive_replica_cleanup_nodes_zookeeper FAIL
Stateless tests (amd_tsan, s3 storage, parallel) failure
03039_recursive_cte_postgres_5 FAIL
00674_join_on_syntax FAIL
01852_map_combinator FAIL
Exception in test runner FAIL
Sanitizer assert (in stderr.log) FAIL
Found signal in gdb.log FAIL
Integration tests (release, 3/4) failure
Job Timeout Expired FAIL
Integration tests (tsan, 6/6) failure
test_storage_kafka/test_batch_slow_4.py::test_kafka_consumer_failover[generate_new_create_table_query] FAIL
Stress test (amd_tsan) failure
Server died FAIL
Hung check failed, possible deadlock found (see hung_check.log) FAIL
Cannot start clickhouse-server FAIL
Server failed to start (see application_errors.txt and clickhouse-server.clean.log) FAIL
Killed by signal (in clickhouse-server.log) FAIL
Fatal message in clickhouse-server.log (see fatal_messages.txt) FAIL
Killed by signal (output files) FAIL
Found signal in gdb.log FAIL

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR. labels Jul 24, 2025
@Algunenano

Algunenano commented Jul 24, 2025 •

Copy link
Copy Markdown
Member Author

@Algunenano
Algunenano enabled auto-merge July 24, 2025 16:33
@Algunenano
Algunenano added this pull request to the merge queue Jul 24, 2025
Merged via the queue into master with commit 68cafee Jul 24, 2025
@Algunenano
Algunenano deleted the revert-83088 branch July 24, 2025 16:47
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 24, 2025
@robot-clickhouse robot-clickhouse added pr-backports-created-cloud deprecated label, NOOP pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Jul 24, 2025
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 24, 2025
Algunenano added a commit that referenced this pull request Jul 24, 2025
Backport #84358 to 25.7: Revert "Revert "Revert "Add SZ3 compression codec"""
@alexey-milovidov alexey-milovidov mentioned this pull request Jun 29, 2026
1 task done
pull Bot pushed a commit to AKJUS/ClickHouse that referenced this pull request Jul 14, 2026
This reverts the removal of the SZ3 lossy floating-point compression
codec done in ClickHouse#84358
(itself a revert of ClickHouse#83088),
and adapts it to the current `master`, finishing the work that the
fuzzer crashes (ClickHouse#84345)
had left unfinished.

`SZ3` is an experimental, error-bounded lossy codec for `Float32`,
`Float64`, `Array(Float32)` and `Array(Float64)` columns. It requires
`SET allow_experimental_codecs = 1`.

Changes needed to revive it on top of `master`:

- Method byte: the original `SZ3` used `0x9c`, but that byte is now
  taken by the `ALP` codec, so `SZ3` is assigned the next free byte
  `0x9d`. The `SZ3` was never part of a stable release, so no persisted
  data depends on the old byte.
- `doDecompressData` now returns `UInt32` (the base class signature
  changed) and the codec registration was moved to the shared
  `registerCompressionCodecs.h`.
- Re-integrated the vector-dimension and lossy-offset handling into the
  refactored `MergeTreeDataPartWriterCompact`/`Wide`/`OnDisk`.
- `flake.nix` and the `aspell` dictionary entries are not restored,
  because both were removed from `master` in the meantime.
- `SZ3` is intentionally not re-added to the BuzzHouse codec fuzzer: its
  codec generator is now type-aware and only emits lossless codecs, and
  `SZ3` is lossy, which would produce false oracle mismatches.

Hardening of `doDecompressData` against corrupted input (the reason for
the original revert):

- The trusted `uncompressed_size` is now enforced. The previous code
  ignored it and let SZ3 write `config.num` (taken from the untrusted
  compressed data) elements into `dest`, which is only `uncompressed_size`
  bytes long - a heap buffer overflow. The decompressed element count is
  now validated against `uncompressed_size` before decompression.
- The float width is validated and `uncompressed_size` must be a multiple
  of it.
- The serialized `SZ3::Config` is parsed from a zero-padded copy of the
  data, after validating the dimension count and bit width, to avoid
  out-of-bounds reads, and `config.size_est()` is checked against the
  compressed size to prevent the payload-size underflow inside
  `SZ_decompress`.

Closes: ClickHouse#84345

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
This reverts the removal of the SZ3 lossy floating-point compression
codec done in ClickHouse#84358
(itself a revert of ClickHouse#83088),
and adapts it to the current `master`, finishing the work that the
fuzzer crashes (ClickHouse#84345)
had left unfinished.

`SZ3` is an experimental, error-bounded lossy codec for `Float32`,
`Float64`, `Array(Float32)` and `Array(Float64)` columns. It requires
`SET allow_experimental_codecs = 1`.

Changes needed to revive it on top of `master`:

- Method byte: the original `SZ3` used `0x9c`, but that byte is now
  taken by the `ALP` codec, so `SZ3` is assigned the next free byte
  `0x9d`. The `SZ3` was never part of a stable release, so no persisted
  data depends on the old byte.
- `doDecompressData` now returns `UInt32` (the base class signature
  changed) and the codec registration was moved to the shared
  `registerCompressionCodecs.h`.
- Re-integrated the vector-dimension and lossy-offset handling into the
  refactored `MergeTreeDataPartWriterCompact`/`Wide`/`OnDisk`.
- `flake.nix` and the `aspell` dictionary entries are not restored,
  because both were removed from `master` in the meantime.
- `SZ3` is intentionally not re-added to the BuzzHouse codec fuzzer: its
  codec generator is now type-aware and only emits lossless codecs, and
  `SZ3` is lossy, which would produce false oracle mismatches.

Hardening of `doDecompressData` against corrupted input (the reason for
the original revert):

- The trusted `uncompressed_size` is now enforced. The previous code
  ignored it and let SZ3 write `config.num` (taken from the untrusted
  compressed data) elements into `dest`, which is only `uncompressed_size`
  bytes long - a heap buffer overflow. The decompressed element count is
  now validated against `uncompressed_size` before decompression.
- The float width is validated and `uncompressed_size` must be a multiple
  of it.
- The serialized `SZ3::Config` is parsed from a zero-padded copy of the
  data, after validating the dimension count and bit width, to avoid
  out-of-bounds reads, and `config.size_est()` is checked against the
  compressed size to prevent the payload-size underflow inside
  `SZ_decompress`.

Closes: ClickHouse#84345

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud deprecated label, NOOP pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple crashes in sz3

5 participants