Skip to content

CI: fix ClickHouseVersion.__hash__ so equal versions hash equal - #129594

Open
0xABCD01 wants to merge 2 commits into
ClickHouse:masterfrom
0xABCD01:fix/clickhouse-version-hash
Open

0xABCD01 wants to merge 2 commits into
ClickHouse:masterfrom
0xABCD01:fix/clickhouse-version-hash

Conversation

@0xABCD01

@0xABCD01 0xABCD01 commented Nov 5, 2026 •

Copy link
Copy Markdown

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

CI only: ClickHouseVersion.__hash__ now hashes the fields that __eq__ compares, so equal versions hash equal.

Description

ClickHouseVersion.__hash__ returned hash(self.__repr__) — the hash of the bound method, which is never called. A bound method's hash is identity-derived, so two versions that compare equal under __eq__ (which compares major, minor, patch, tweak) generally hash differently, and set/dict deduplication or lookup across independently constructed copies silently misses.

The fix returns hash((self.major, self.minor, self.patch, self.tweak)), exactly the field set __eq__ compares. Hashing self.__repr__() instead would not fix the contract: __repr__ embeds the description, which comes from version_type, and __eq__ ignores version_type — equal versions with different version types would still hash differently.

No live failure was observed in the current call flows: the versions that reach the sets in get_supported_versions and official_docker.py mostly arrive as the same objects, so the broken hash has not produced a wrong result I could demonstrate. The defect is the contract itself — two ClickHouseVersion objects that compare equal hash differently, so any dedupe or lookup across independently constructed copies (one parsed from a tag, one built by the release flow) silently misses. The new test pins the contract.

Tests

  • New ci/tests/test_clickhouse_version.py (5 tests): 5 passed with the fix. Against the base implementation, 4 failed and 1 passed (the distinctness control). The different-metadata test also fails against a hash(self.__repr__()) variant.
  • Full ci/tests run in my sparse ci/-only checkout: 55 passed; the failing set is identical to base (all in test_fuzzer_dict_codegen_deps.py, from src/ files the sparse checkout does not contain).
  • ruff and pylint with the repo configuration: clean on the changed files.

Workflow [PR]
Sync PR [sync-upstream/pr/129594]

__hash__ hashed the bound __repr__ method object, whose hash follows the
identity of the instance, so two ClickHouseVersion objects that compare
equal hashed differently and sets/dicts treated them as different keys.
That breaks the dedupe in get_supported_versions and in
ci/tools/official_docker.py whenever the same release arrives as two
independently built copies.

Hash exactly the fields __eq__ compares (major, minor, patch, tweak).
Hashing __repr__() instead would still be wrong: __eq__ ignores the
version type, the repr does not.

Adds ci/tests/test_clickhouse_version.py pinning the contract.
@clickhouse-gh clickhouse-gh Bot added comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). external Author is not a member of the ClickHouse organization labels Nov 5, 2026
@cla-assistant

cla-assistant Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Nov 15, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Nov 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [54d9583]

Summary: ❌

job_name test_name status info comment
Code Review FAIL

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 15, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 15, 2026

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

Labels

can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). external Author is not a member of the ClickHouse organization manual approve Manual approve required to run CI pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants