Skip to content

Make the setting allow_experimental_reverse_key obsolete - #106440

Merged
nikitamikhaylov merged 2 commits into
masterfrom
obsolete-allow-experimental-reverse-key
Jun 9, 2026
Merged

nikitamikhaylov merged 2 commits into
masterfrom
obsolete-allow-experimental-reverse-key

Conversation

@nikitamikhaylov

@nikitamikhaylov nikitamikhaylov commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

Closes: #103677

Descending sort order in MergeTree sorting keys (ORDER BY with DESC, e.g. ORDER BY (time DESC, key)) used to be gated behind the experimental table-level setting allow_experimental_reverse_key. The feature has been available and covered by tests for a while, so this PR graduates it to always-on and makes the setting obsolete.

The obsolete setting is kept as a no-op for backward compatibility, so existing DDL and table metadata that set allow_experimental_reverse_key = 1 keep working. The now-dead gating code is removed: the allow_reverse_key member, the allow_reverse_sorting_key parameter of checkProperties, and the validation branch that rejected reversed sorting keys. The setting is also no longer randomized by the query fuzzer and BuzzHouse.

No SettingsChangesHistory entry is added: the setting's default value does not change (false), and the MergeTree settings history records new settings and value changes rather than tier-only obsolescence (consistent with existing obsolete MergeTree settings such as write_final_mark or cleanup_threads).

A new stateless test (04312_reverse_key_obsolete_setting) verifies that a descending sort key works without any setting, that the obsolete setting is still accepted, and that it is reported as obsolete in system.merge_tree_settings.

Changelog category (leave one):

  • Improvement

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

Descending sort order in MergeTree sorting keys (e.g. ORDER BY (time DESC, key)) is now always supported and no longer requires the experimental setting allow_experimental_reverse_key, which became obsolete.

Documentation entry for user-facing changes

  • Documentation is not required: the MergeTree settings reference is generated from the source, and the feature itself is already documented.

🤖 Generated with Claude Code

Version info

  • Merged into: 26.6.1.553

Descending sort order in `MergeTree` sorting keys (`ORDER BY` with `DESC`)
used to be gated behind the experimental table-level setting
`allow_experimental_reverse_key`. The feature is now always supported, so
the setting is made obsolete (kept as a no-op for backward compatibility,
so old DDL that sets it keeps working) and the gating code is removed:

- `allow_experimental_reverse_key` moved to the obsolete settings list via
  `MAKE_OBSOLETE_MERGE_TREE_SETTING`, with a matching entry in
  `SettingsChangesHistory`.
- Removed the `allow_reverse_key` member, the `allow_reverse_sorting_key`
  parameter of `checkProperties`, and the validation branch that rejected
  reversed sorting keys.
- Stopped randomizing the obsolete setting in the query fuzzer and BuzzHouse.

Added a stateless test that checks a descending sort key works without any
setting, that the obsolete setting is still accepted, and that it is
reported as obsolete in `system.merge_tree_settings`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [95a29de]

Summary: ✅


AI Review

Summary

This PR makes descending MergeTree sorting keys always supported by removing the allow_experimental_reverse_key gate and keeping the setting as an obsolete no-op. The implementation path is narrow and the compatibility behavior looks consistent, but the PR currently removes the only user-facing source documentation for the ORDER BY (... DESC ...) table-key syntax, so I would request a small documentation update before merge.

Findings

⚠️ Majors

  • [src/Storages/MergeTree/MergeTreeSettings.cpp:2208] The PR graduates descending MergeTree sorting keys but moves allow_experimental_reverse_key to a generic obsolete setting, which drops the setting description that explained ORDER BY (time DESC, key) and the ReadInOrder use case. The main MergeTree ORDER BY docs still only show ascending examples, so after this change users can no longer discover the always-on syntax from the generated settings docs or the engine docs. Existing inline thread: Make the setting allow_experimental_reverse_key obsolete #106440 (comment)
    Suggested fix: add a short note/example under docs/en/engines/table-engines/mergetree-family/mergetree.md ORDER BY documenting that sorting-key elements may use ASC/DESC, for example ORDER BY (event_time DESC, user_id), and remove SETTINGS allow_experimental_reverse_key = 1 from the example.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: add user-facing documentation for descending MergeTree sorting keys now that allow_experimental_reverse_key no longer carries that documentation.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 4, 2026
Making `allow_experimental_reverse_key` obsolete does not change its
default value (`false`), so there is no value change to record. The
`merge_tree_settings_changes_history` records new settings and value
changes, not tier-only obsolescence — most obsolete `MergeTree` settings
(e.g. `write_final_mark`, `min_bytes_for_compact_part`, `cleanup_threads`)
have no history entry. The `02995_new_settings_history` check does not
require one either, since the setting is neither new nor value-changed.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
MAKE_OBSOLETE_MERGE_TREE_SETTING(M, UInt64, kill_delay_period_random_add, 10) \
MAKE_OBSOLETE_MERGE_TREE_SETTING(M, UInt64, kill_threads, 128) \
MAKE_OBSOLETE_MERGE_TREE_SETTING(M, UInt64, cleanup_threads, 128) \
MAKE_OBSOLETE_MERGE_TREE_SETTING(M, Bool, allow_experimental_reverse_key, false) \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making allow_experimental_reverse_key obsolete removes the only source-level documentation I can find for descending MergeTree sorting keys. The current MergeTree docs describe ORDER BY expr, but they do not mention that table sorting keys now accept DESC or show the natural ORDER BY (time DESC, key) pattern this PR is graduating.

Please add a short note/example to the MergeTree ORDER BY documentation (or another user-facing source doc) so the always-on syntax is discoverable after this setting becomes a generic obsolete no-op.

@clickhouse-gh

clickhouse-gh Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.40% 84.40% +0.00%
Functions 92.40% 92.40% +0.00%
Branches 77.00% 77.00% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 30/31 (96.77%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 7 line(s) · Uncovered code

Full report · Diff report

@Algunenano Algunenano self-assigned this Jun 8, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

It would be great to introduce some fuzzing around this feature since right now it's only a gate and randomizing it won't use the code or trigger possible correctness bugs. cc @PedroTadim

@nikitamikhaylov
nikitamikhaylov added this pull request to the merge queue Jun 9, 2026
Merged via the queue into master with commit 376b503 Jun 9, 2026
166 of 167 checks passed
@nikitamikhaylov
nikitamikhaylov deleted the obsolete-allow-experimental-reverse-key branch June 9, 2026 13:16
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allow_experimental_reverse_key: timeline to beta/stable? 5-7x performance gap with InReverseOrder

3 participants