Skip to content

Conversation

@aalexfvk
Copy link
Contributor

@aalexfvk aalexfvk commented Feb 8, 2025

allow_suspicious_ttl_expressions is a profile level setting with default 0.

Issues:

  1. It is not respected during creating of ReplicatedMergeTree (does not allow anyway)
dev-vm.ru-central1.internal :) create table ttl_simple_6 (a Int) engine = ReplicatedMergeTree('/ttl_simple_6', 'r6') order by a partition by tuple() ttl now() + interval 1 second;

CREATE TABLE ttl_simple_6
(
    `a` Int
)
ENGINE = ReplicatedMergeTree('/ttl_simple_6', 'r6')
PARTITION BY tuple()
ORDER BY a
TTL now() + toIntervalSecond(1)

Query id: 295a0ef9-47ae-4b8f-9c6d-fa7f97900803


Elapsed: 0.003 sec. 

Received exception from server (version 25.2.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: TTL expression now() + toIntervalSecond(1) does not depend on any of the columns of the table. (BAD_ARGUMENTS)

dev-vm.ru-central1.internal :) SET allow_suspicious_ttl_expressions=1

SET allow_suspicious_ttl_expressions = 1

Query id: 648e2a76-42cb-4694-9417-114d30747db8

Ok.

0 rows in set. Elapsed: 0.002 sec. 

dev-vm.ru-central1.internal :) create table ttl_simple_6 (a Int) engine = ReplicatedMergeTree('/ttl_simple_6', 'r6') order by a partition by tuple() ttl now() + interval 1 second;

CREATE TABLE ttl_simple_6
(
    `a` Int
)
ENGINE = ReplicatedMergeTree('/ttl_simple_6', 'r6')
PARTITION BY tuple()
ORDER BY a
TTL now() + toIntervalSecond(1)

Query id: 887aef2c-b0f4-4a1d-b1e4-e170d33494e5


Elapsed: 0.035 sec. 

Received exception from server (version 25.2.1):
Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: TTL expression now() + toIntervalSecond(1) does not depend on any of the columns of the table. (BAD_ARGUMENTS)
  1. After introducing allow_suspicious_ttl_expressions tables with non-deterministic functions is not attached after restart.
Initialization failed, table will remain readonly. Error: Code: 36. DB::Exception: TTL expression now() - toIntervalHour(2) does not depend on any of the columns of the table. (BAD_ARGUMENTS), Stack trace (when copying this message, always include the lines below):

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000c89ffdb
1. DB::Exception::Exception<String const&>(int, FormatStringHelperImpl<std::type_identity<String const&>::type>, String const&) @ 0x0000000007672303
2. DB::TTLDescription::getTTLFromAST(std::shared_ptr<DB::IAST> const&, DB::ColumnsDescription const&, std::shared_ptr<DB::Context const>, DB::KeyDescription const&, bool) @ 0x0000000011727fec
3. DB::TTLTableDescription::getTTLForTableFromAST(std::shared_ptr<DB::IAST> const&, DB::ColumnsDescription const&, std::shared_ptr<DB::Context const>, DB::KeyDescription const&, bool) @ 0x0000000011728f3e
4. DB::TTLTableDescription::parse(String const&, DB::ColumnsDescription const&, std::shared_ptr<DB::Context const>, DB::KeyDescription const&) @ 0x00000000117294ef
5. DB::ReplicatedMergeTreeTableMetadata::checkEquals(DB::ReplicatedMergeTreeTableMetadata const&, DB::ColumnsDescription const&, std::shared_ptr<DB::Context const>) const @ 0x0000000011dc432f
6. DB::StorageReplicatedMergeTree::checkTableStructure(String const&, std::shared_ptr<DB::StorageInMemoryMetadata const> const&, bool) @ 0x00000000114fbc29
7. DB::ReplicatedMergeTreeAttachThread::run() @ 0x0000000011d0816b
8. DB::BackgroundSchedulePool::threadFunction() @ 0x000000000fa72aa7
9. void std::__function::__policy_invoker<void ()>::__call_impl<std::__function::__default_alloc_func<ThreadFromGlobalPoolImpl<false>::ThreadFromGlobalPoolImpl<DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, StrongTypedef<unsigned long, CurrentMetrics::MetricTag>, StrongTypedef<unsigned long, CurrentMetrics::MetricTag>, char const*)::$_0>(DB::BackgroundSchedulePool::BackgroundSchedulePool(unsigned long, StrongTypedef<unsigned long, CurrentMetrics::MetricTag>, StrongTypedef<unsigned long, CurrentMetrics::MetricTag>, char const*)::$_0&&)::'lambda'(), void ()>>(std::__function::__policy_storage const*) @ 0x000000000fa73c13
10. void* std::__thread_proxy[abi:v15000]<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>>(void*) @ 0x000000000c94ecad
11. ? @ 0x00007fc15fbb8ac3
12. ? @ 0x00007fc15fc4a850
 (version 24.3.15.72 (official build))"

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):

Fix allow_suspicious_ttl_expressions behaviour

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@aalexfvk aalexfvk marked this pull request as ready for review February 8, 2025 20:13
@aalexfvk aalexfvk changed the title Fix allow_suspicious_ttl_expressions behaviour Fix allow_suspicious_ttl_expressions misbehaviour Feb 8, 2025
@alesapin alesapin added the can be tested Allows running workflows for external contributors label Feb 10, 2025
@clickhouse-gh
Copy link

clickhouse-gh bot commented Feb 10, 2025

Workflow [PR], commit [ea6ef2b]

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Feb 10, 2025
@CurtizJ CurtizJ self-assigned this Feb 12, 2025
@CurtizJ
Copy link
Member

CurtizJ commented Feb 12, 2025

Fuzzer: #71217.
Intergration tests: #71533.
Stateless tests: #68619.

@CurtizJ CurtizJ enabled auto-merge February 12, 2025 16:52
@CurtizJ CurtizJ added this pull request to the merge queue Feb 12, 2025
Merged via the queue into ClickHouse:master with commit 1c1d193 Feb 12, 2025
115 of 125 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 12, 2025
@aalexfvk
Copy link
Contributor Author

@CurtizJ Could we make backports ?

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 pr-bugfix Pull request with bugfix, not backported by default 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.

4 participants