repo stringlengths 5 53 | pr_number int32 1 321k | task_type stringclasses 2
values | issue_text stringlengths 0 81.2k | pr_title stringlengths 1 319 | pr_body stringlengths 0 105k | base_sha stringlengths 40 40 | head_sha stringlengths 40 40 | gold_diff stringlengths 0 202M | changed_files listlengths 0 100 | review_threads listlengths 0 100 | test_patch stringlengths 0 23.4M | merged bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
ClickHouse/ClickHouse | 107,346 | issue_to_patch | Backport #107071 to 26.5: Support trim character sets longer than 16 in trim* functions | Original pull-request https://github.com/ClickHouse/ClickHouse/pull/107071
Cherry-pick pull-request https://github.com/ClickHouse/ClickHouse/pull/107177
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you inte... | 503b8321beb136b493f594dd79efaa00bcf6c6c4 | 821c3c723af96cb00ae75ee584786ffd524bbd3c | diff --git a/src/Functions/trim.cpp b/src/Functions/trim.cpp
index fbbfeab7635d..ea4c4b35a04c 100644
--- a/src/Functions/trim.cpp
+++ b/src/Functions/trim.cpp
@@ -7,18 +7,24 @@
#include <Functions/FunctionHelpers.h>
#include <base/find_symbols.h>
+#include <array>
+
namespace DB
{
namespace ErrorCodes
{
ex... | [
"src/Functions/trim.cpp",
"tests/queries/0_stateless/03784_functions_various_bugs.reference",
"tests/queries/0_stateless/03784_functions_various_bugs.sql",
"tests/queries/0_stateless/04051_functions_various_bugs.reference",
"tests/queries/0_stateless/04051_functions_various_bugs.sql",
"tests/queries/0_sta... | [] | diff --git a/tests/queries/0_stateless/03784_functions_various_bugs.reference b/tests/queries/0_stateless/03784_functions_various_bugs.reference
index 4f0092a0bd13..14f5097d57b8 100644
--- a/tests/queries/0_stateless/03784_functions_various_bugs.reference
+++ b/tests/queries/0_stateless/03784_functions_various_bugs.ref... | true | |
ClickHouse/ClickHouse | 107,345 | issue_to_patch | Backport #107071 to 26.4: Support trim character sets longer than 16 in trim* functions | Original pull-request https://github.com/ClickHouse/ClickHouse/pull/107071
Cherry-pick pull-request https://github.com/ClickHouse/ClickHouse/pull/107176
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you inte... | 7a7d19151f4f1b72f4d39d6d5f4681a147a86704 | 89d221e6ba94850bc9f7bbff6246d6d1c155a91e | diff --git a/src/Functions/trim.cpp b/src/Functions/trim.cpp
index fbbfeab7635d..ea4c4b35a04c 100644
--- a/src/Functions/trim.cpp
+++ b/src/Functions/trim.cpp
@@ -7,18 +7,24 @@
#include <Functions/FunctionHelpers.h>
#include <base/find_symbols.h>
+#include <array>
+
namespace DB
{
namespace ErrorCodes
{
ex... | [
"src/Functions/trim.cpp",
"tests/queries/0_stateless/03784_functions_various_bugs.reference",
"tests/queries/0_stateless/03784_functions_various_bugs.sql",
"tests/queries/0_stateless/04051_functions_various_bugs.reference",
"tests/queries/0_stateless/04051_functions_various_bugs.sql",
"tests/queries/0_sta... | [] | diff --git a/tests/queries/0_stateless/03784_functions_various_bugs.reference b/tests/queries/0_stateless/03784_functions_various_bugs.reference
index 4f0092a0bd13..14f5097d57b8 100644
--- a/tests/queries/0_stateless/03784_functions_various_bugs.reference
+++ b/tests/queries/0_stateless/03784_functions_various_bugs.ref... | true | |
ClickHouse/ClickHouse | 107,404 | issue_to_patch | Backport #106507 to 26.4: Fix wrong-results equality with NaN-producing key function | Original pull-request https://github.com/ClickHouse/ClickHouse/pull/106507
Cherry-pick pull-request https://github.com/ClickHouse/ClickHouse/pull/107403
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you inte... | 9606dc9fee640e794992e5e3bc76447de78fe727 | 50d133ad5475fa6e84282b834befad299b5e27bb | diff --git a/src/Storages/MergeTree/KeyCondition.cpp b/src/Storages/MergeTree/KeyCondition.cpp
index f072b15417b9..d33a22de871e 100644
--- a/src/Storages/MergeTree/KeyCondition.cpp
+++ b/src/Storages/MergeTree/KeyCondition.cpp
@@ -1927,7 +1927,14 @@ bool KeyCondition::canConstantBeWrappedByDeterministicFunctions(
... | [
"src/Storages/MergeTree/KeyCondition.cpp",
"tests/queries/0_stateless/04306_keycondition_nan_equality.reference",
"tests/queries/0_stateless/04306_keycondition_nan_equality.sql"
] | [] | diff --git a/tests/queries/0_stateless/04306_keycondition_nan_equality.reference b/tests/queries/0_stateless/04306_keycondition_nan_equality.reference
new file mode 100644
index 000000000000..de3badc3ed7f
--- /dev/null
+++ b/tests/queries/0_stateless/04306_keycondition_nan_equality.reference
@@ -0,0 +1,14 @@
+1
+1
+1
+... | true | |
ClickHouse/ClickHouse | 107,406 | issue_to_patch | Backport #106507 to 26.5: Fix wrong-results equality with NaN-producing key function | Original pull-request https://github.com/ClickHouse/ClickHouse/pull/106507
Cherry-pick pull-request https://github.com/ClickHouse/ClickHouse/pull/107405
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you inte... | 503b8321beb136b493f594dd79efaa00bcf6c6c4 | fabfda40ff61861206cadbd1e49d82901c35612c | diff --git a/src/Storages/MergeTree/KeyCondition.cpp b/src/Storages/MergeTree/KeyCondition.cpp
index 91aa8bc5f6ad..6b4360282121 100644
--- a/src/Storages/MergeTree/KeyCondition.cpp
+++ b/src/Storages/MergeTree/KeyCondition.cpp
@@ -2097,7 +2097,14 @@ bool KeyCondition::canConstantBeWrappedByDeterministicFunctions(
... | [
"src/Storages/MergeTree/KeyCondition.cpp",
"tests/queries/0_stateless/04306_keycondition_nan_equality.reference",
"tests/queries/0_stateless/04306_keycondition_nan_equality.sql"
] | [] | diff --git a/tests/queries/0_stateless/04306_keycondition_nan_equality.reference b/tests/queries/0_stateless/04306_keycondition_nan_equality.reference
new file mode 100644
index 000000000000..de3badc3ed7f
--- /dev/null
+++ b/tests/queries/0_stateless/04306_keycondition_nan_equality.reference
@@ -0,0 +1,14 @@
+1
+1
+1
+... | true | |
ClickHouse/ClickHouse | 105,555 | issue_to_patch | `applyTrivialInsertSelectOptimization` drops `columns_description` from context, breaking table function structure hints
_Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment._
_Retrospective finding from a historical scan of [PR #91599](https://github.com/ClickHouse/C... | Fix usage of insertion table in table functions when `optimize_trivial_insert_select` is enabled | ### Changelog category (leave one):
- Bug Fix (user-visible misbehavior in an official stable release)
### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md):
Fix usage of insert... | 9b22faf1eca3a6d0f481985027d5d26eadcfad0c | f545887f70a4b870d32bf49cd18e13e85b717081 | diff --git a/src/Interpreters/Access/InterpreterExecuteAsQuery.cpp b/src/Interpreters/Access/InterpreterExecuteAsQuery.cpp
index 8ab1a453a5ba..cc095e3e0b3e 100644
--- a/src/Interpreters/Access/InterpreterExecuteAsQuery.cpp
+++ b/src/Interpreters/Access/InterpreterExecuteAsQuery.cpp
@@ -33,7 +33,7 @@ namespace
... | [
"src/Interpreters/Access/InterpreterExecuteAsQuery.cpp",
"src/Interpreters/InterpreterInsertQuery.cpp",
"src/Storages/StorageInMemoryMetadata.cpp",
"tests/queries/0_stateless/04266_trivial_insert_select_table_function_structure_hint.reference",
"tests/queries/0_stateless/04266_trivial_insert_select_table_fu... | [] | diff --git a/tests/queries/0_stateless/04266_trivial_insert_select_table_function_structure_hint.reference b/tests/queries/0_stateless/04266_trivial_insert_select_table_function_structure_hint.reference
new file mode 100644
index 000000000000..641f5b5bad4f
--- /dev/null
+++ b/tests/queries/0_stateless/04266_trivial_ins... | true |
ClickHouse/ClickHouse | 107,384 | issue_to_patch | read auth_response length as UInt8 in MySQL handshake | `HandshakeResponse::readPayloadImpl` reads the `auth_response` length for the `CLIENT_SECURE_CONNECTION` path into a signed `char` and widens it with `static_cast<unsigned int>`. The matching writer emits this field as an unsigned byte (`static_cast<UInt8>(auth_response.size())`), so the two sides disagree once the hig... | e78a4dac750cb4e71fb1928c6e3d760817d45e78 | 4668a438051d5f17a5d7ecbb24eb2d380f8eb210 | diff --git a/src/Core/MySQL/PacketsConnection.cpp b/src/Core/MySQL/PacketsConnection.cpp
index 0cc97f6a8df2..db127898ab3a 100644
--- a/src/Core/MySQL/PacketsConnection.cpp
+++ b/src/Core/MySQL/PacketsConnection.cpp
@@ -148,9 +148,9 @@ void HandshakeResponse::readPayloadImpl(ReadBuffer & payload)
}
else if (ca... | [
"src/Core/MySQL/PacketsConnection.cpp",
"tests/queries/0_stateless/04328_mysql_handshake_auth_response_length.py",
"tests/queries/0_stateless/04328_mysql_handshake_auth_response_length.reference"
] | [
{
"comment": "```suggestion\n readBinary(len, payload);\n```",
"path": "src/Core/MySQL/PacketsConnection.cpp",
"hunk": "@@ -148,9 +148,9 @@ void HandshakeResponse::readPayloadImpl(ReadBuffer & payload)\n }\n else if (capability_flags & CLIENT_SECURE_CONNECTION)\n {\n- char len ... | diff --git a/tests/queries/0_stateless/04328_mysql_handshake_auth_response_length.py b/tests/queries/0_stateless/04328_mysql_handshake_auth_response_length.py
new file mode 100755
index 000000000000..6381721adf28
--- /dev/null
+++ b/tests/queries/0_stateless/04328_mysql_handshake_auth_response_length.py
@@ -0,0 +1,112 ... | true | |
ClickHouse/ClickHouse | 107,384 | comment_to_fix | read auth_response length as UInt8 in MySQL handshake | ```suggestion
readBinary(len, payload);
``` | e78a4dac750cb4e71fb1928c6e3d760817d45e78 | 4668a438051d5f17a5d7ecbb24eb2d380f8eb210 | diff --git a/src/Core/MySQL/PacketsConnection.cpp b/src/Core/MySQL/PacketsConnection.cpp
index 0cc97f6a8df2..db127898ab3a 100644
--- a/src/Core/MySQL/PacketsConnection.cpp
+++ b/src/Core/MySQL/PacketsConnection.cpp
@@ -148,9 +148,9 @@ void HandshakeResponse::readPayloadImpl(ReadBuffer & payload)
}
else if (ca... | [
"src/Core/MySQL/PacketsConnection.cpp"
] | [
{
"comment": "```suggestion\n readBinary(len, payload);\n```",
"path": "src/Core/MySQL/PacketsConnection.cpp",
"hunk": "@@ -148,9 +148,9 @@ void HandshakeResponse::readPayloadImpl(ReadBuffer & payload)\n }\n else if (capability_flags & CLIENT_SECURE_CONNECTION)\n {\n- char len ... | true | ||
ClickHouse/ClickHouse | 101,942 | issue_to_patch | OOM Canary
### Company or project name
ClickHouse
### Use case
`clickhouse-server` should be notified before the OOM killer has a chance to kill it. We can implement it by launching a small child process with an inflated OOM score adjustment. If the process is killed, we know that it was the OOM killer, and we can ... | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | Closes: https://github.com/ClickHouse/ClickHouse/issues/101749
### Changelog category (leave one):
- Experimental Feature
### Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added an experimental Linux OOM canary: a sacrificial child process that the Linux OOM killer ta... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt
index c44a71c1a85a..10300277822a 100644
--- a/programs/CMakeLists.txt
+++ b/programs/CMakeLists.txt
@@ -109,6 +109,7 @@ add_subdirectory (keeper-data-dumper)
add_subdirectory (keeper-utils)
add_subdirectory (local)
add_subdirectory (obfuscator)
+add_subd... | [
"programs/CMakeLists.txt",
"programs/main.cpp",
"programs/oom-canary/CMakeLists.txt",
"programs/oom-canary/OomCanary.cpp",
"programs/oom-canary/clickhouse-oom-canary.cpp",
"programs/server/Server.cpp",
"src/CMakeLists.txt",
"src/Common/FailPoint.cpp",
"src/Common/OOMCanary/OOMCanary.cpp",
"src/Com... | [
{
"comment": "`vfork` is unsafe here for a long-lived canary process and can block server startup.\n\nWith `vfork`, the parent is suspended until the child calls `execve` or `_exit`. In this implementation the child takes the `pid == 0` branch, enters `childMain`, and then loops forever in `sigsuspend` without ... | diff --git a/tests/integration/test_oom_canary/__init__.py b/tests/integration/test_oom_canary/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/tests/integration/test_oom_canary/configs/enable_off.xml b/tests/integration/test_oom_canary/configs/enable_off.xml
new file mode 100644
index 000... | true |
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `oom_canary_enable` defaults to `true`, so this high-impact behavior is enabled immediately for all deployments: once the canary receives `SIGKILL`, the server executes emergency actions (query cancellation, merge cancellation, crash-log path). For safer rollout, this should be opt-in first (for example default `false`... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index ee0a3d9a0d13..a818c288cec6 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -1505,6 +1505,45 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
```
)", 0) \
DECLARE(I... | [
"src/Core/ServerSettings.cpp"
] | [
{
"comment": "`oom_canary_enable` defaults to `true`, so this high-impact behavior is enabled immediately for all deployments: once the canary receives `SIGKILL`, the server executes emergency actions (query cancellation, merge cancellation, crash-log path). For safer rollout, this should be opt-in first (for e... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | This introduces high-impact server behavior (global query cancellation, merge cancellation, and a `system.crash_log` write path) behind a regular setting (`oom_canary_enable`) but without an experimental gate.
Per ClickHouse rollout rules for risky new server behavior, it should be guarded by an explicit `allow_experi... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index ee0a3d9a0d13..a818c288cec6 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -1505,6 +1505,45 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
```
)", 0) \
DECLARE(I... | [
"src/Core/ServerSettings.cpp"
] | [
{
"comment": "This introduces high-impact server behavior (global query cancellation, merge cancellation, and a `system.crash_log` write path) behind a regular setting (`oom_canary_enable`) but without an experimental gate.\n\nPer ClickHouse rollout rules for risky new server behavior, it should be guarded by a... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | This is experimentally gated behavior (`allow_experimental_oom_canary`) but the PR template still uses `Changelog category: New Feature` and leaves the documentation checkbox unchecked.
Per template/conventions, this should be categorized as `Experimental Feature`, and documentation should be provided (or the docs blo... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index ee0a3d9a0d13..a818c288cec6 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -1505,6 +1505,45 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
```
)", 0) \
DECLARE(I... | [
"src/Core/ServerSettings.cpp"
] | [
{
"comment": "This is experimentally gated behavior (`allow_experimental_oom_canary`) but the PR template still uses `Changelog category: New Feature` and leaves the documentation checkbox unchecked.\n\nPer template/conventions, this should be categorized as `Experimental Feature`, and documentation should be p... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | If `syscall_pidfd_open` fails, this branch goes straight to blocking `reapChild`. For failures like `ENOSYS` (kernel without `pidfd_open`) or `EMFILE`, the canary process is still alive in `pause`, so the monitor thread blocks forever here and `OOMCanary::stop` can hang on `join` during shutdown.
Please terminate the ... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/OOMCanary/OOMCanary.cpp b/src/Common/OOMCanary/OOMCanary.cpp
new file mode 100644
index 000000000000..69f795a2ba0e
--- /dev/null
+++ b/src/Common/OOMCanary/OOMCanary.cpp
@@ -0,0 +1,476 @@
+#include <Common/OOMCanary/OOMCanary.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Epoll.h>
+#include <Co... | [
"src/Common/OOMCanary/OOMCanary.cpp"
] | [
{
"comment": "If `syscall_pidfd_open` fails, this branch goes straight to blocking `reapChild`. For failures like `ENOSYS` (kernel without `pidfd_open`) or `EMFILE`, the canary process is still alive in `pause`, so the monitor thread blocks forever here and `OOMCanary::stop` can hang on `join` during shutdown.\... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `oom-canary` is built unconditionally, but this source is Linux-only (`sys/prctl.h`, `PR_SET_PDEATHSIG`, `oom_score_adj`, `close_range` syscall). On non-Linux builds this will fail at compile time.
Please gate this translation unit/target to Linux (or provide a non-Linux stub `mainEntryClickHouseOomCanary`), and keep ... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/oom-canary/OomCanary.cpp b/programs/oom-canary/OomCanary.cpp
new file mode 100644
index 000000000000..343410e486d6
--- /dev/null
+++ b/programs/oom-canary/OomCanary.cpp
@@ -0,0 +1,144 @@
+#include <Common/OOMCanaryExitCodes.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Exception.h>
+#include <IO... | [
"programs/oom-canary/OomCanary.cpp"
] | [
{
"comment": "`oom-canary` is built unconditionally, but this source is Linux-only (`sys/prctl.h`, `PR_SET_PDEATHSIG`, `oom_score_adj`, `close_range` syscall). On non-Linux builds this will fail at compile time.\n\nPlease gate this translation unit/target to Linux (or provide a non-Linux stub `mainEntryClickHou... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | The OOM response contract here includes more than `system.crash_log`: `onCanaryOOM` also calls `ProcessList::killAllQueries` and `MergeList::cancelAll`.
Current coverage only proves relaunch + crash-log insertion, so a regression where query/merge cancellation stops working would still pass.
Please add one focused as... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/tests/integration/test_oom_canary/test.py b/tests/integration/test_oom_canary/test.py
new file mode 100644
index 000000000000..149f61b5f84d
--- /dev/null
+++ b/tests/integration/test_oom_canary/test.py
@@ -0,0 +1,156 @@
+import threading
+import time
+import uuid
+from dataclasses import dataclass
+
+impor... | [
"tests/integration/test_oom_canary/test.py"
] | [
{
"comment": "The OOM response contract here includes more than `system.crash_log`: `onCanaryOOM` also calls `ProcessList::killAllQueries` and `MergeList::cancelAll`.\n\nCurrent coverage only proves relaunch + crash-log insertion, so a regression where query/merge cancellation stops working would still pass.\n\... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `MADV_POPULATE_WRITE` is selected by compile-time macro, but support is kernel-runtime dependent.
On older kernels (for example pre-5.14), `madvise(..., MADV_POPULATE_WRITE)` returns `EINVAL`; this path exits with `TRANSIENT`, and the monitor then burns through relaunch attempts and disables the canary permanently eve... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/oom-canary/OomCanary.cpp b/programs/oom-canary/OomCanary.cpp
new file mode 100644
index 000000000000..343410e486d6
--- /dev/null
+++ b/programs/oom-canary/OomCanary.cpp
@@ -0,0 +1,144 @@
+#include <Common/OOMCanaryExitCodes.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Exception.h>
+#include <IO... | [
"programs/oom-canary/OomCanary.cpp"
] | [
{
"comment": "`MADV_POPULATE_WRITE` is selected by compile-time macro, but support is kernel-runtime dependent.\n\nOn older kernels (for example pre-5.14), `madvise(..., MADV_POPULATE_WRITE)` returns `EINVAL`; this path exits with `TRANSIENT`, and the monitor then burns through relaunch attempts and disables th... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `close_range` is gated only at compile time here. If the binary is built with `__NR_close_range` but runs on an older kernel where the syscall is unavailable, this call returns `ENOSYS` and we silently keep all inherited file descriptors open.
That breaks the intended invariant that the canary process does not retain ... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/oom-canary/OomCanary.cpp b/programs/oom-canary/OomCanary.cpp
new file mode 100644
index 000000000000..343410e486d6
--- /dev/null
+++ b/programs/oom-canary/OomCanary.cpp
@@ -0,0 +1,144 @@
+#include <Common/OOMCanaryExitCodes.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Exception.h>
+#include <IO... | [
"programs/oom-canary/OomCanary.cpp"
] | [
{
"comment": "`close_range` is gated only at compile time here. If the binary is built with `__NR_close_range` but runs on an older kernel where the syscall is unavailable, this call returns `ENOSYS` and we silently keep all inherited file descriptors open.\n\nThat breaks the intended invariant that the canary ... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `max_fd` is hard-capped to `65536`, so descriptors above that are never closed in the canary process.
On deployments with high `max_open_files` (or simply many open descriptors), the canary can still inherit and keep parent sockets/files alive after relaunch, which breaks the isolation invariant and can retain resourc... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/oom-canary/OomCanary.cpp b/programs/oom-canary/OomCanary.cpp
new file mode 100644
index 000000000000..343410e486d6
--- /dev/null
+++ b/programs/oom-canary/OomCanary.cpp
@@ -0,0 +1,144 @@
+#include <Common/OOMCanaryExitCodes.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Exception.h>
+#include <IO... | [
"programs/oom-canary/OomCanary.cpp"
] | [
{
"comment": "`max_fd` is hard-capped to `65536`, so descriptors above that are never closed in the canary process.\n\nOn deployments with high `max_open_files` (or simply many open descriptors), the canary can still inherit and keep parent sockets/files alive after relaunch, which breaks the isolation invarian... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | Let's maybe log exception? | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/oom-canary/OomCanary.cpp b/programs/oom-canary/OomCanary.cpp
new file mode 100644
index 000000000000..343410e486d6
--- /dev/null
+++ b/programs/oom-canary/OomCanary.cpp
@@ -0,0 +1,144 @@
+#include <Common/OOMCanaryExitCodes.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Exception.h>
+#include <IO... | [
"programs/oom-canary/OomCanary.cpp"
] | [
{
"comment": "Let's maybe log exception?",
"path": "programs/oom-canary/OomCanary.cpp",
"hunk": "@@ -0,0 +1,112 @@\n+#include <Common/OOMCanaryExitCodes.h>\n+\n+#if defined(OS_LINUX)\n+\n+#include <IO/ReadHelpers.h>\n+#include <IO/WriteBufferFromFile.h>\n+#include <IO/WriteHelpers.h>\n+\n+#include <sys/... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | Let's log something | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/oom-canary/OomCanary.cpp b/programs/oom-canary/OomCanary.cpp
new file mode 100644
index 000000000000..343410e486d6
--- /dev/null
+++ b/programs/oom-canary/OomCanary.cpp
@@ -0,0 +1,144 @@
+#include <Common/OOMCanaryExitCodes.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Exception.h>
+#include <IO... | [
"programs/oom-canary/OomCanary.cpp"
] | [
{
"comment": "Let's log something",
"path": "programs/oom-canary/OomCanary.cpp",
"hunk": "@@ -0,0 +1,112 @@\n+#include <Common/OOMCanaryExitCodes.h>\n+\n+#if defined(OS_LINUX)\n+\n+#include <IO/ReadHelpers.h>\n+#include <IO/WriteBufferFromFile.h>\n+#include <IO/WriteHelpers.h>\n+\n+#include <sys/mman.h>... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | Let's log something | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/oom-canary/OomCanary.cpp b/programs/oom-canary/OomCanary.cpp
new file mode 100644
index 000000000000..343410e486d6
--- /dev/null
+++ b/programs/oom-canary/OomCanary.cpp
@@ -0,0 +1,144 @@
+#include <Common/OOMCanaryExitCodes.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Exception.h>
+#include <IO... | [
"programs/oom-canary/OomCanary.cpp"
] | [
{
"comment": "Let's log something",
"path": "programs/oom-canary/OomCanary.cpp",
"hunk": "@@ -0,0 +1,112 @@\n+#include <Common/OOMCanaryExitCodes.h>\n+\n+#if defined(OS_LINUX)\n+\n+#include <IO/ReadHelpers.h>\n+#include <IO/WriteBufferFromFile.h>\n+#include <IO/WriteHelpers.h>\n+\n+#include <sys/mman.h>... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | Do we need this lambda? | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp
index 8343f9411dbc..c56d0593780f 100644
--- a/programs/server/Server.cpp
+++ b/programs/server/Server.cpp
@@ -31,6 +31,7 @@
#include <Common/CurrentMemoryTracker.h>
#include <Common/MemoryTracker.h>
#include <Common/MemoryWorker.h>
+#include <Commo... | [
"programs/server/Server.cpp"
] | [
{
"comment": "Do we need this lambda?",
"path": "programs/server/Server.cpp",
"hunk": "@@ -3252,6 +3296,8 @@ try\n else\n global_context->cancelAllBackupsAndRestores();\n \n+ stop_oom_canary();",
"resolving_sha": "f6a6dce6c24bdd0f8a3630844943a0a43218c964",
... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | Why it should be in IO? | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ab469adee233..7e7318e148d3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -153,6 +153,7 @@ add_headers_and_sources(dbms Storages/ObjectStorage/DataLakes/Iceberg)
add_headers_and_sources(dbms Storages/ObjectStorage/DataLakes/DeltaLake)
add_headers... | [
"src/CMakeLists.txt"
] | [
{
"comment": "Why it should be in IO?",
"path": "src/CMakeLists.txt",
"hunk": "@@ -111,6 +111,8 @@ add_headers_and_sources(clickhouse_common_io IO/AzureBlobStorage)\n add_headers_and_sources(clickhouse_common_io Disks/DiskObjectStorage/ObjectStorages/AzureBlobStorage)\n list (REMOVE_ITEM clickhouse_comm... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | Why do we need both allow_experimental_oom_canary and oom_canary_enable? Looks a little bit overkill | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index ee0a3d9a0d13..a818c288cec6 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -1505,6 +1505,45 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
```
)", 0) \
DECLARE(I... | [
"src/Core/ServerSettings.cpp"
] | [
{
"comment": "Why do we need both allow_experimental_oom_canary and oom_canary_enable? Looks a little bit overkill",
"path": "src/Core/ServerSettings.cpp",
"hunk": "@@ -1495,6 +1495,38 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_\n ```\n )\", 0) \\\n DE... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | And also make sense to log total memory usage | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/OOMCanary/OOMCanary.cpp b/src/Common/OOMCanary/OOMCanary.cpp
new file mode 100644
index 000000000000..69f795a2ba0e
--- /dev/null
+++ b/src/Common/OOMCanary/OOMCanary.cpp
@@ -0,0 +1,476 @@
+#include <Common/OOMCanary/OOMCanary.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Epoll.h>
+#include <Co... | [
"src/Common/OOMCanary/OOMCanary.cpp"
] | [
{
"comment": "And also make sense to log total memory usage",
"path": "src/Common/OOMCanary/OOMCanary.cpp",
"hunk": "@@ -0,0 +1,395 @@\n+#include <Common/OOMCanary.h>\n+\n+#if defined(OS_LINUX)\n+\n+#include <Common/Epoll.h>\n+#include <Common/OOMCanaryExitCodes.h>\n+#include <Common/logger_useful.h>\n+... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | Maybe it is enough to mark it ONCE, that wait you don't need to disable it | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/FailPoint.cpp b/src/Common/FailPoint.cpp
index e5ff1302db09..d89c04afd094 100644
--- a/src/Common/FailPoint.cpp
+++ b/src/Common/FailPoint.cpp
@@ -179,6 +179,7 @@ static struct InitFiu
REGULAR(check_database_datalake_negative) \
REGULAR(restart_replica_fail_after_detach) \
REGULAR... | [
"src/Common/FailPoint.cpp"
] | [
{
"comment": "Maybe it is enough to mark it ONCE, that wait you don't need to disable it",
"path": "src/Common/FailPoint.cpp",
"hunk": "@@ -177,6 +177,7 @@ static struct InitFiu\n REGULAR(check_database_datalake_negative) \\\n REGULAR(restart_replica_fail_after_detach) \\\n REGULAR(database_... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | Also I guess it make sense to move this to the top | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/oom-canary/OomCanary.cpp b/programs/oom-canary/OomCanary.cpp
new file mode 100644
index 000000000000..343410e486d6
--- /dev/null
+++ b/programs/oom-canary/OomCanary.cpp
@@ -0,0 +1,144 @@
+#include <Common/OOMCanaryExitCodes.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Exception.h>
+#include <IO... | [
"programs/oom-canary/OomCanary.cpp"
] | [
{
"comment": "Also I guess it make sense to move this to the top",
"path": "programs/oom-canary/OomCanary.cpp",
"hunk": "@@ -0,0 +1,112 @@\n+#include <Common/OOMCanaryExitCodes.h>\n+\n+#if defined(OS_LINUX)\n+\n+#include <IO/ReadHelpers.h>\n+#include <IO/WriteBufferFromFile.h>\n+#include <IO/WriteHelper... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | The PR description/changelog text still references `allow_experimental_oom_canary`, but that setting is not present in the current code anymore (`src/Core/ServerSettings.cpp` only defines `oom_canary_enable` + related tuning settings).
Please update the PR template fields so release notes/documentation match the shipp... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index ee0a3d9a0d13..a818c288cec6 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -1505,6 +1505,45 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
```
)", 0) \
DECLARE(I... | [
"src/Core/ServerSettings.cpp"
] | [
{
"comment": "The PR description/changelog text still references `allow_experimental_oom_canary`, but that setting is not present in the current code anymore (`src/Core/ServerSettings.cpp` only defines `oom_canary_enable` + related tuning settings).\n\nPlease update the PR template fields so release notes/docum... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `oom_canary_max_rapid_relaunches` is documented as limiting consecutive relaunches under sustained memory pressure, but confirmed OOMs reset `attempt` in `OOMCanary::monitorThread` before the cap is checked. With `oom_canary_relaunch=1`, a canary killed by real cgroup OOM evidence repeatedly will always go through `att... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index ee0a3d9a0d13..a818c288cec6 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -1505,6 +1505,45 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
```
)", 0) \
DECLARE(I... | [
"src/Core/ServerSettings.cpp"
] | [
{
"comment": "`oom_canary_max_rapid_relaunches` is documented as limiting consecutive relaunches under sustained memory pressure, but confirmed OOMs reset `attempt` in `OOMCanary::monitorThread` before the cap is checked. With `oom_canary_relaunch=1`, a canary killed by real cgroup OOM evidence repeatedly will ... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | The OOM response is supposed to shed memory by cancelling running queries, but this call goes through the regular `ProcessList::killAllQueries` path, which first allocates/reserves a `std::vector<QueryStatusPtr>` proportional to the number of running queries before it cancels anything. Under the memory pressure that ju... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/OOMCanary/OOMCanary.cpp b/src/Common/OOMCanary/OOMCanary.cpp
new file mode 100644
index 000000000000..69f795a2ba0e
--- /dev/null
+++ b/src/Common/OOMCanary/OOMCanary.cpp
@@ -0,0 +1,476 @@
+#include <Common/OOMCanary/OOMCanary.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Epoll.h>
+#include <Co... | [
"src/Common/OOMCanary/OOMCanary.cpp"
] | [
{
"comment": "The OOM response is supposed to shed memory by cancelling running queries, but this call goes through the regular `ProcessList::killAllQueries` path, which first allocates/reserves a `std::vector<QueryStatusPtr>` proportional to the number of running queries before it cancels anything. Under the m... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `Epoll::add` and the following `Epoll::getManyReady` can throw after the canary child has already been spawned. Because `monitorThread` has no top-level cleanup for that per-child state, the `ThreadFromGlobalPool` job exits, `stop` later only joins the finished job, and the child remains alive/unmonitored until parent ... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/OOMCanary/OOMCanary.cpp b/src/Common/OOMCanary/OOMCanary.cpp
new file mode 100644
index 000000000000..69f795a2ba0e
--- /dev/null
+++ b/src/Common/OOMCanary/OOMCanary.cpp
@@ -0,0 +1,476 @@
+#include <Common/OOMCanary/OOMCanary.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Epoll.h>
+#include <Co... | [
"src/Common/OOMCanary/OOMCanary.cpp"
] | [
{
"comment": "`Epoll::add` and the following `Epoll::getManyReady` can throw after the canary child has already been spawned. Because `monitorThread` has no top-level cleanup for that per-child state, the `ThreadFromGlobalPool` job exits, `stop` later only joins the finished job, and the child remains alive/unm... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | BTW I think we should try to use "getCurrentExceptionMessage" here, since std::exception will not have any details that the DB::Exception has | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/programs/oom-canary/OomCanary.cpp b/programs/oom-canary/OomCanary.cpp
new file mode 100644
index 000000000000..343410e486d6
--- /dev/null
+++ b/programs/oom-canary/OomCanary.cpp
@@ -0,0 +1,144 @@
+#include <Common/OOMCanaryExitCodes.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Exception.h>
+#include <IO... | [
"programs/oom-canary/OomCanary.cpp"
] | [
{
"comment": "BTW I think we should try to use \"getCurrentExceptionMessage\" here, since std::exception will not have any details that the DB::Exception has",
"path": "programs/oom-canary/OomCanary.cpp",
"hunk": "@@ -0,0 +1,127 @@\n+#include <Common/OOMCanaryExitCodes.h>\n+\n+#if defined(OS_LINUX)\n+\n... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | ```suggestion
)", EXPERIMENTAL) \
``` | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index ee0a3d9a0d13..a818c288cec6 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -1505,6 +1505,45 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
```
)", 0) \
DECLARE(I... | [
"src/Core/ServerSettings.cpp"
] | [
{
"comment": "```suggestion\r\n )\", EXPERIMENTAL) \\\r\n```",
"path": "src/Core/ServerSettings.cpp",
"hunk": "@@ -1505,6 +1505,33 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_\n ```\n )\", 0) \\\n DECLARE(Int32, oom_score, getDefaultOomScore(), R\"(O... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `oom_canary_size` says the canary memory is allocated and locked, but the helper treats `mlock` as best-effort and ignores failures. With the default 100 MB size, many deployments will exceed `RLIMIT_MEMLOCK`, so operators can enable the canary believing the memory is locked when it is actually only touched and may be ... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index ee0a3d9a0d13..a818c288cec6 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -1505,6 +1505,45 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
```
)", 0) \
DECLARE(I... | [
"src/Core/ServerSettings.cpp"
] | [
{
"comment": "`oom_canary_size` says the canary memory is allocated and locked, but the helper treats `mlock` as best-effort and ignores failures. With the default 100 MB size, many deployments will exceed `RLIMIT_MEMLOCK`, so operators can enable the canary believing the memory is locked when it is actually on... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `oom_canary_relaunch` documents only the confirmed OOM path, but `monitorThread` relaunches after any child death that does not hit a permanent setup failure: manual `SIGKILL` without cgroup evidence, non-`SIGKILL` signals, and `TRANSIENT` exits all fall through to the relaunch/backoff block. The integration test also ... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index ee0a3d9a0d13..a818c288cec6 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -1505,6 +1505,45 @@ The policy on how to perform a scheduling of CPU slots specified by `concurrent_
```
)", 0) \
DECLARE(I... | [
"src/Core/ServerSettings.cpp"
] | [
{
"comment": "`oom_canary_relaunch` documents only the confirmed OOM path, but `monitorThread` relaunches after any child death that does not hit a permanent setup failure: manual `SIGKILL` without cgroup evidence, non-`SIGKILL` signals, and `TRANSIENT` exits all fall through to the relaunch/backoff block. The ... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | The canary monitor should catch failures from the whole thread body, not only from `ThreadFromGlobalPool` scheduling.
`monitorThread` starts by constructing `Epoll` and adding `shutdown_fd`; both operations can throw (`epoll_create1` / `epoll_ctl`, e.g. `EMFILE` or `ENOMEM`) before the per-child try/catch is reached. ... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/OOMCanary/OOMCanary.cpp b/src/Common/OOMCanary/OOMCanary.cpp
new file mode 100644
index 000000000000..69f795a2ba0e
--- /dev/null
+++ b/src/Common/OOMCanary/OOMCanary.cpp
@@ -0,0 +1,476 @@
+#include <Common/OOMCanary/OOMCanary.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Epoll.h>
+#include <Co... | [
"src/Common/OOMCanary/OOMCanary.cpp"
] | [
{
"comment": "The canary monitor should catch failures from the whole thread body, not only from `ThreadFromGlobalPool` scheduling.\n\n`monitorThread` starts by constructing `Epoll` and adding `shutdown_fd`; both operations can throw (`epoll_create1` / `epoll_ctl`, e.g. `EMFILE` or `ENOMEM`) before the per-chil... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | This makes the canary require `pidfd_open` support, but the user-facing contract only says Linux + cgroup v2 `memory.events`.
On Linux kernels before `pidfd_open` (`ENOSYS`) or environments where it is blocked, enabling `oom_canary_enable` will spawn the helper, immediately kill it here, and disable the feature even t... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/OOMCanary/OOMCanary.cpp b/src/Common/OOMCanary/OOMCanary.cpp
new file mode 100644
index 000000000000..69f795a2ba0e
--- /dev/null
+++ b/src/Common/OOMCanary/OOMCanary.cpp
@@ -0,0 +1,476 @@
+#include <Common/OOMCanary/OOMCanary.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Epoll.h>
+#include <Co... | [
"src/Common/OOMCanary/OOMCanary.cpp"
] | [
{
"comment": "This makes the canary require `pidfd_open` support, but the user-facing contract only says Linux + cgroup v2 `memory.events`.\n\nOn Linux kernels before `pidfd_open` (`ENOSYS`) or environments where it is blocked, enabling `oom_canary_enable` will spawn the helper, immediately kill it here, and di... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `oom_canary_max_rapid_relaunches` is documented as a rapid/consecutive relaunch guard, but this counter never resets after the canary has run stably. That makes it a lifetime death counter: for example, 11 unrelated OOMs or manual `SIGKILL`s spread over days will eventually disable the canary permanently, and the backo... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/OOMCanary/OOMCanary.cpp b/src/Common/OOMCanary/OOMCanary.cpp
new file mode 100644
index 000000000000..69f795a2ba0e
--- /dev/null
+++ b/src/Common/OOMCanary/OOMCanary.cpp
@@ -0,0 +1,476 @@
+#include <Common/OOMCanary/OOMCanary.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Epoll.h>
+#include <Co... | [
"src/Common/OOMCanary/OOMCanary.cpp"
] | [
{
"comment": "`oom_canary_max_rapid_relaunches` is documented as a rapid/consecutive relaunch guard, but this counter never resets after the canary has run stably. That makes it a lifetime death counter: for example, 11 unrelated OOMs or manual `SIGKILL`s spread over days will eventually disable the canary perm... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | The startup check accepts any cgroup v2 with `memory.events`, but the canary cannot protect the server when the same cgroup has `memory.oom.group=1`: on memcg OOM the kernel kills the whole cgroup as one unit, so the parent server is killed together with the sacrificial child and the monitor never reaches `onCanaryOOM`... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/OOMCanary/OOMCanary.cpp b/src/Common/OOMCanary/OOMCanary.cpp
new file mode 100644
index 000000000000..69f795a2ba0e
--- /dev/null
+++ b/src/Common/OOMCanary/OOMCanary.cpp
@@ -0,0 +1,476 @@
+#include <Common/OOMCanary/OOMCanary.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Epoll.h>
+#include <Co... | [
"src/Common/OOMCanary/OOMCanary.cpp"
] | [
{
"comment": "The startup check accepts any cgroup v2 with `memory.events`, but the canary cannot protect the server when the same cgroup has `memory.oom.group=1`: on memcg OOM the kernel kills the whole cgroup as one unit, so the parent server is killed together with the sacrificial child and the monitor never... | true | ||
ClickHouse/ClickHouse | 101,942 | comment_to_fix | Add OOM canary: a sacrificial child process to protect the server from the OOM killer | `readOOMKillCounter` uses `memory.events` as the OOM discriminator, but in cgroup v2 `memory.events` is hierarchical by default: an OOM kill in a descendant cgroup also advances this `oom_kill` counter. That breaks the "cgroup-local evidence" contract here. A manual `SIGKILL` of the canary racing with an OOM in a child... | 961aff5091dd55df14a173b7b3f58c1f9524b7e0 | f6a6dce6c24bdd0f8a3630844943a0a43218c964 | diff --git a/src/Common/OOMCanary/OOMCanary.cpp b/src/Common/OOMCanary/OOMCanary.cpp
new file mode 100644
index 000000000000..69f795a2ba0e
--- /dev/null
+++ b/src/Common/OOMCanary/OOMCanary.cpp
@@ -0,0 +1,476 @@
+#include <Common/OOMCanary/OOMCanary.h>
+
+#if defined(OS_LINUX)
+
+#include <Common/Epoll.h>
+#include <Co... | [
"src/Common/OOMCanary/OOMCanary.cpp"
] | [
{
"comment": "`readOOMKillCounter` uses `memory.events` as the OOM discriminator, but in cgroup v2 `memory.events` is hierarchical by default: an OOM kill in a descendant cgroup also advances this `oom_kill` counter. That breaks the \"cgroup-local evidence\" contract here. A manual `SIGKILL` of the canary racin... | true | ||
ClickHouse/ClickHouse | 107,420 | issue_to_patch | Skip 02947_parallel_replicas_remote on macOS (arm_darwin) | <!--
Linked issues and pull requests. Use full GitHub URLs, one relationship per line; delete the lines you don't need.
Related: https://github.com/ClickHouse/ClickHouse/pull/106689
-->
Related: https://github.com/ClickHouse/ClickHouse/pull/106689
### Changelog category (leave one):
- CI Fix or Improvement (changelo... | bf2051399e17d9e2b620d7d2c02568ff125011a6 | cd91d6e66e9de43f359a4b7fce79ad047ebf41a6 | diff --git a/ci/defs/darwin.skip b/ci/defs/darwin.skip
index d493e709843c..9bca9e93921e 100644
--- a/ci/defs/darwin.skip
+++ b/ci/defs/darwin.skip
@@ -1146,6 +1146,7 @@
02947_merge_tree_index_table_1
02947_merge_tree_index_table_2
02947_merge_tree_index_table_4
+02947_parallel_replicas_remote
02950_dictionary_ssd_c... | [
"ci/defs/darwin.skip"
] | [] | true | ||
ClickHouse/ClickHouse | 106,178 | issue_to_patch | Add embedded documentation for database engines | This is the second PR in the series that adds embedded, runtime-introspectable documentation to ClickHouse component registries. The first ([#106177](https://github.com/ClickHouse/ClickHouse/pull/106177)) did this for table engines; this one does it for database engines.
What it does:
- Attaches the shared `Documentat... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/docs/en/engines/database-engines/backup.md b/docs/en/engines/database-engines/backup.md
index 98fc17e402c3..cb3880d4c9c3 100644
--- a/docs/en/engines/database-engines/backup.md
+++ b/docs/en/engines/database-engines/backup.md
@@ -14,20 +14,13 @@ Database backup works with both incremental and non-increment... | [
"docs/en/engines/database-engines/backup.md",
"docs/en/engines/database-engines/datalake.md",
"docs/en/engines/database-engines/materialized-postgresql.md",
"docs/en/operations/system-tables/database_engines.md",
"src/Common/Documentation.h",
"src/Databases/DataLake/DatabaseDataLake.cpp",
"src/Databases... | [
{
"comment": "The page now documents the new `description`, `syntax`, `examples`, `introduced_in`, and `related` columns, but the example below still runs `SELECT *` and shows only the old `name` column. That result is no longer possible, so readers copying the docs will see a different shape. Please either mak... | diff --git a/tests/queries/0_stateless/02959_system_database_engines.sql b/tests/queries/0_stateless/02959_system_database_engines.sql
index 67cb20f04006..f973a1dbce51 100644
--- a/tests/queries/0_stateless/02959_system_database_engines.sql
+++ b/tests/queries/0_stateless/02959_system_database_engines.sql
@@ -1,1 +1,1 ... | true | |
ClickHouse/ClickHouse | 106,178 | comment_to_fix | Add embedded documentation for database engines | The page now documents the new `description`, `syntax`, `examples`, `introduced_in`, and `related` columns, but the example below still runs `SELECT *` and shows only the old `name` column. That result is no longer possible, so readers copying the docs will see a different shape. Please either make the example query se... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/docs/en/operations/system-tables/database_engines.md b/docs/en/operations/system-tables/database_engines.md
index 5f81c82f64c7..7ad26216b5ae 100644
--- a/docs/en/operations/system-tables/database_engines.md
+++ b/docs/en/operations/system-tables/database_engines.md
@@ -15,20 +15,25 @@ Contains the list of ... | [
"docs/en/operations/system-tables/database_engines.md"
] | [
{
"comment": "The page now documents the new `description`, `syntax`, `examples`, `introduced_in`, and `related` columns, but the example below still runs `SELECT *` and shows only the old `name` column. That result is no longer possible, so readers copying the docs will see a different shape. Please either mak... | true | ||
ClickHouse/ClickHouse | 106,178 | comment_to_fix | Add embedded documentation for database engines | The `related` column is documented as containing names of related database engines, but `MaterializedMySQL` is not registered in `DatabaseFactory` anywhere in this tree, so this value cannot be resolved back through `system.database_engines`. Please keep `related` limited to registered database engine names, or add a v... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/src/Databases/MySQL/DatabaseMySQL.cpp b/src/Databases/MySQL/DatabaseMySQL.cpp
index 0c798900f1b6..a9494fa2abd3 100644
--- a/src/Databases/MySQL/DatabaseMySQL.cpp
+++ b/src/Databases/MySQL/DatabaseMySQL.cpp
@@ -667,7 +667,176 @@ void registerDatabaseMySQL(DatabaseFactory & factory)
.supports_settin... | [
"src/Databases/MySQL/DatabaseMySQL.cpp"
] | [
{
"comment": "The `related` column is documented as containing names of related database engines, but `MaterializedMySQL` is not registered in `DatabaseFactory` anywhere in this tree, so this value cannot be resolved back through `system.database_engines`. Please keep `related` limited to registered database en... | true | ||
ClickHouse/ClickHouse | 106,178 | comment_to_fix | Add embedded documentation for database engines | `Filesystem` is always registered, but both `S3` and `HDFS` are behind `USE_AWS_S3` / `USE_HDFS`. In builds without either option, `system.database_engines` will contain the `Filesystem` row with `related = ['S3','HDFS']`, while those related targets have no row in the same system table. The new test only validates alw... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/src/Databases/DatabaseFilesystem.cpp b/src/Databases/DatabaseFilesystem.cpp
index f85f41e81d93..0f6173cb8615 100644
--- a/src/Databases/DatabaseFilesystem.cpp
+++ b/src/Databases/DatabaseFilesystem.cpp
@@ -268,6 +268,9 @@ void registerDatabaseFilesystem(DatabaseFactory & factory)
.supports_argumen... | [
"src/Databases/DatabaseFilesystem.cpp"
] | [
{
"comment": "`Filesystem` is always registered, but both `S3` and `HDFS` are behind `USE_AWS_S3` / `USE_HDFS`. In builds without either option, `system.database_engines` will contain the `Filesystem` row with `related = ['S3','HDFS']`, while those related targets have no row in the same system table. The new t... | true | ||
ClickHouse/ClickHouse | 106,178 | comment_to_fix | Add embedded documentation for database engines | This example still cannot produce the shown response. `Lazy` is not registered in this tree (the stateless test for this same filter expects only `Atomic` and `Ordinary`), and without `ORDER BY` the row order is not stable because `system.database_engines` is filled from an unordered factory map. Since this PR is alrea... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/docs/en/operations/system-tables/database_engines.md b/docs/en/operations/system-tables/database_engines.md
index 5f81c82f64c7..7ad26216b5ae 100644
--- a/docs/en/operations/system-tables/database_engines.md
+++ b/docs/en/operations/system-tables/database_engines.md
@@ -15,20 +15,25 @@ Contains the list of ... | [
"docs/en/operations/system-tables/database_engines.md"
] | [
{
"comment": "This example still cannot produce the shown response. `Lazy` is not registered in this tree (the stateless test for this same filter expects only `Atomic` and `Ordinary`), and without `ORDER BY` the row order is not stable because `system.database_engines` is filled from an unordered factory map. ... | true | ||
ClickHouse/ClickHouse | 106,178 | comment_to_fix | Add embedded documentation for database engines | The new `syntax` column should expose a structurally valid engine clause, but this value makes the second `Backup` argument a string literal. `parseArguments` passes that AST to `BackupInfo::fromAST`, which requires an `ASTFunction`, so `CREATE DATABASE ... ENGINE = Backup('db', 'backup_destination')` throws `Expected ... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/src/Databases/DatabaseBackup.cpp b/src/Databases/DatabaseBackup.cpp
index 74b63d8150db..a60fb82f166a 100644
--- a/src/Databases/DatabaseBackup.cpp
+++ b/src/Databases/DatabaseBackup.cpp
@@ -482,7 +482,106 @@ void registerDatabaseBackup(DatabaseFactory & factory)
return std::make_shared<DatabaseBac... | [
"src/Databases/DatabaseBackup.cpp"
] | [
{
"comment": "The new `syntax` column should expose a structurally valid engine clause, but this value makes the second `Backup` argument a string literal. `parseArguments` passes that AST to `BackupInfo::fromAST`, which requires an `ASTFunction`, so `CREATE DATABASE ... ENGINE = Backup('db', 'backup_destinatio... | true | ||
ClickHouse/ClickHouse | 106,178 | comment_to_fix | Add embedded documentation for database engines | The `description` field is now user-visible through `system.database_engines`, but this first `Backup` example is still not a valid `CREATE DATABASE` statement: the second argument is a string literal, and `parseArguments` passes it to `BackupInfo::fromAST`, which requires an `ASTFunction` and throws `Expected function... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/src/Databases/DatabaseBackup.cpp b/src/Databases/DatabaseBackup.cpp
index 74b63d8150db..a60fb82f166a 100644
--- a/src/Databases/DatabaseBackup.cpp
+++ b/src/Databases/DatabaseBackup.cpp
@@ -482,7 +482,106 @@ void registerDatabaseBackup(DatabaseFactory & factory)
return std::make_shared<DatabaseBac... | [
"src/Databases/DatabaseBackup.cpp"
] | [
{
"comment": "The `description` field is now user-visible through `system.database_engines`, but this first `Backup` example is still not a valid `CREATE DATABASE` statement: the second argument is a string literal, and `parseArguments` passes it to `BackupInfo::fromAST`, which requires an `ASTFunction` and thr... | true | ||
ClickHouse/ClickHouse | 106,178 | comment_to_fix | Add embedded documentation for database engines | The PR promises the dedicated database-engine pages are embedded into `system.database_engines`, but this `MySQL` copy is already stale: the current `docs/en/engines/database-engines/mysql.md` page includes `[SETTINGS enable_compression=0]` plus the `enable_compression` settings section, while the embedded `description... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/src/Databases/MySQL/DatabaseMySQL.cpp b/src/Databases/MySQL/DatabaseMySQL.cpp
index 0c798900f1b6..a9494fa2abd3 100644
--- a/src/Databases/MySQL/DatabaseMySQL.cpp
+++ b/src/Databases/MySQL/DatabaseMySQL.cpp
@@ -667,7 +667,176 @@ void registerDatabaseMySQL(DatabaseFactory & factory)
.supports_settin... | [
"src/Databases/MySQL/DatabaseMySQL.cpp"
] | [
{
"comment": "The PR promises the dedicated database-engine pages are embedded into `system.database_engines`, but this `MySQL` copy is already stale: the current `docs/en/engines/database-engines/mysql.md` page includes `[SETTINGS enable_compression=0]` plus the `enable_compression` settings section, while the... | true | ||
ClickHouse/ClickHouse | 106,178 | comment_to_fix | Add embedded documentation for database engines | This example creates `postgres_db`, but the query immediately uses `postgresql_db.postgres_table`. Since this block is now exposed through `system.database_engines.description`, the copied example references a database that was never created. Please make the database name consistent here and in `docs/en/engines/databas... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/src/Databases/PostgreSQL/DatabaseMaterializedPostgreSQL.cpp b/src/Databases/PostgreSQL/DatabaseMaterializedPostgreSQL.cpp
index 4031b373efb3..b17234d69570 100644
--- a/src/Databases/PostgreSQL/DatabaseMaterializedPostgreSQL.cpp
+++ b/src/Databases/PostgreSQL/DatabaseMaterializedPostgreSQL.cpp
@@ -568,7 +56... | [
"src/Databases/PostgreSQL/DatabaseMaterializedPostgreSQL.cpp"
] | [
{
"comment": "This example creates `postgres_db`, but the query immediately uses `postgresql_db.postgres_table`. Since this block is now exposed through `system.database_engines.description`, the copied example references a database that was never created. Please make the database name consistent here and in `d... | true | ||
ClickHouse/ClickHouse | 106,178 | comment_to_fix | Add embedded documentation for database engines | The embedded `description` is now exposed through `system.database_engines`, but this `sql` block still cannot be copied as a valid query: the statement ends with `:` instead of `;`, and the response table is inside the same `sql` fence. Please terminate the query with `;` and move the response to a `text` fence here a... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | 64398d8d8d683085114dd085d2c89e005c18fea6 | diff --git a/src/Databases/DatabaseBackup.cpp b/src/Databases/DatabaseBackup.cpp
index 74b63d8150db..a60fb82f166a 100644
--- a/src/Databases/DatabaseBackup.cpp
+++ b/src/Databases/DatabaseBackup.cpp
@@ -482,7 +482,106 @@ void registerDatabaseBackup(DatabaseFactory & factory)
return std::make_shared<DatabaseBac... | [
"src/Databases/DatabaseBackup.cpp"
] | [
{
"comment": "The embedded `description` is now exposed through `system.database_engines`, but this `sql` block still cannot be copied as a valid query: the statement ends with `:` instead of `;`, and the response table is inside the same `sql` fence. Please terminate the query with `;` and move the response to... | true | ||
ClickHouse/ClickHouse | 107,417 | issue_to_patch | Fix undefined behavior on a non-finite timestamp in prometheusQuery | <!--
Linked issues and pull requests. Use full GitHub URLs, one relationship per line; delete the lines you don't need.
-->
No related open issue found (searched parseTimeSeriesTypes / prometheusQuery UBSan / getFromFloat).
### Changelog category (leave one):
- Bug Fix (user-visible misbehavior in an official stable ... | 6a756730987624515ad9c08daab2b7831d343ba1 | f76710f11cd3d9f161f1bfda5c6dcab075e448ad | diff --git a/src/Parsers/Prometheus/parseTimeSeriesTypes.cpp b/src/Parsers/Prometheus/parseTimeSeriesTypes.cpp
index 9f1f69e5241d..bc140b6cbadf 100644
--- a/src/Parsers/Prometheus/parseTimeSeriesTypes.cpp
+++ b/src/Parsers/Prometheus/parseTimeSeriesTypes.cpp
@@ -46,6 +46,14 @@ namespace
template <is_decimal T>
... | [
"src/Parsers/Prometheus/parseTimeSeriesTypes.cpp",
"tests/queries/0_stateless/04337_prometheus_query_nan_timestamp.reference",
"tests/queries/0_stateless/04337_prometheus_query_nan_timestamp.sql"
] | [] | diff --git a/tests/queries/0_stateless/04337_prometheus_query_nan_timestamp.reference b/tests/queries/0_stateless/04337_prometheus_query_nan_timestamp.reference
new file mode 100644
index 000000000000..0b06b5563f22
--- /dev/null
+++ b/tests/queries/0_stateless/04337_prometheus_query_nan_timestamp.reference
@@ -0,0 +1,1... | true | |
ClickHouse/ClickHouse | 107,398 | issue_to_patch | Backport #107208 to 26.5: Do not narrow UnionStep pipeline when with read in order | Original pull-request https://github.com/ClickHouse/ClickHouse/pull/107208
Cherry-pick pull-request https://github.com/ClickHouse/ClickHouse/pull/107397
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you inte... | 503b8321beb136b493f594dd79efaa00bcf6c6c4 | cb0ec6adb2b8544935d15a7ee8842fc48273a28a | diff --git a/src/Core/Settings.cpp b/src/Core/Settings.cpp
index 8c17611c7a15..4329fa1aa1a9 100644
--- a/src/Core/Settings.cpp
+++ b/src/Core/Settings.cpp
@@ -5927,10 +5927,10 @@ Set default mode in INTERSECT query. Possible values: empty string, 'ALL', 'DIST
Set default mode in EXCEPT query. Possible values: empty st... | [
"src/Core/Settings.cpp",
"src/Interpreters/InterpreterSelectWithUnionQuery.cpp",
"src/Planner/Planner.cpp",
"src/Processors/QueryPlan/Optimizations/applyOrder.cpp",
"src/Processors/QueryPlan/Optimizations/filterPushDown.cpp",
"src/Processors/QueryPlan/Optimizations/liftUpUnion.cpp",
"src/Processors/Quer... | [] | diff --git a/tests/queries/0_stateless/04324_union_all_narrow_read_in_order.reference b/tests/queries/0_stateless/04324_union_all_narrow_read_in_order.reference
new file mode 100644
index 000000000000..f7432d7d09a5
--- /dev/null
+++ b/tests/queries/0_stateless/04324_union_all_narrow_read_in_order.reference
@@ -0,0 +1,8... | true | |
ClickHouse/ClickHouse | 104,558 | issue_to_patch | order by + limit applied before arrayJoin
### Company or project name
_No response_
### Describe what's wrong
It appears that "limit" is applied together with "order by" before "arrayJoin" is executed
### Does it reproduce on the most recent release?
Yes
### How to reproduce
Latest clickhouse version:
I would ... | Do not lift `arrayJoin` above `SortingStep` (issue #82279) | The `tryExecuteFunctionsAfterSorting` optimization in `src/Processors/QueryPlan/Optimizations/liftUpFunctions.cpp` splits the post-sort expression into a "needed for sorting" part (computes the sort keys, stays below `SortingStep`) and an "unneeded for sorting" part (lifted above `SortingStep`). It is unsound to lift `... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | fab23475deb70684d0dbccc0d18a7e25678d8983 | diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp
index 70111d67b637..2de69143a2f0 100644
--- a/src/Interpreters/InterpreterSelectQuery.cpp
+++ b/src/Interpreters/InterpreterSelectQuery.cpp
@@ -369,6 +369,23 @@ InterpreterSelectQuery::~InterpreterSelectQuery() = defa... | [
"src/Interpreters/InterpreterSelectQuery.cpp",
"src/Planner/PlannerJoinTree.cpp",
"src/Processors/QueryPlan/Optimizations/liftUpFunctions.cpp",
"src/Processors/QueryPlan/Optimizations/limitPushDown.cpp",
"src/Processors/QueryPlan/Optimizations/optimizeLazyMaterialization.cpp",
"src/Processors/QueryPlan/Op... | [
{
"comment": "This still leaves a row-truncating sort path uncovered. `pushLimitByIntoSort` runs later and can attach a per-stream `LIMIT BY` hint to this same `SortingStep` while `getLimit()` stays zero, so this guard lets `arrayJoin` be lifted above a sort that will still drop rows before expansion. For examp... | diff --git a/tests/queries/0_stateless/01533_multiple_nested.sql b/tests/queries/0_stateless/01533_multiple_nested.sql
index 12fd19228cda..b255002d385d 100644
--- a/tests/queries/0_stateless/01533_multiple_nested.sql
+++ b/tests/queries/0_stateless/01533_multiple_nested.sql
@@ -67,6 +67,9 @@ INSERT INTO nested SELECT n... | true |
ClickHouse/ClickHouse | 104,558 | comment_to_fix | Do not lift `arrayJoin` above `SortingStep` (issue #82279) | This still leaves a row-truncating sort path uncovered. `pushLimitByIntoSort` runs later and can attach a per-stream `LIMIT BY` hint to this same `SortingStep` while `getLimit()` stays zero, so this guard lets `arrayJoin` be lifted above a sort that will still drop rows before expansion. For example, with source rows o... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | fab23475deb70684d0dbccc0d18a7e25678d8983 | diff --git a/src/Processors/QueryPlan/Optimizations/liftUpFunctions.cpp b/src/Processors/QueryPlan/Optimizations/liftUpFunctions.cpp
index 68caafdb1b16..c43296be1aff 100644
--- a/src/Processors/QueryPlan/Optimizations/liftUpFunctions.cpp
+++ b/src/Processors/QueryPlan/Optimizations/liftUpFunctions.cpp
@@ -87,6 +87,22 @... | [
"src/Processors/QueryPlan/Optimizations/liftUpFunctions.cpp"
] | [
{
"comment": "This still leaves a row-truncating sort path uncovered. `pushLimitByIntoSort` runs later and can attach a per-stream `LIMIT BY` hint to this same `SortingStep` while `getLimit()` stays zero, so this guard lets `arrayJoin` be lifted above a sort that will still drop rows before expansion. For examp... | true | ||
ClickHouse/ClickHouse | 104,558 | comment_to_fix | Do not lift `arrayJoin` above `SortingStep` (issue #82279) | This regression only proves the new guard when the `MergeTree` read still has multiple streams: the bad plan needs the per-stream `LimitByTransform` to run before the lifted `arrayJoin`. The test creates four parts, but background merges are still enabled, so an unfixed build can become a false negative if those parts ... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | fab23475deb70684d0dbccc0d18a7e25678d8983 | diff --git a/tests/queries/0_stateless/04318_arrayjoin_after_sort_with_limit_by.sql b/tests/queries/0_stateless/04318_arrayjoin_after_sort_with_limit_by.sql
new file mode 100644
index 000000000000..607f77415449
--- /dev/null
+++ b/tests/queries/0_stateless/04318_arrayjoin_after_sort_with_limit_by.sql
@@ -0,0 +1,42 @@
+... | [
"tests/queries/0_stateless/04318_arrayjoin_after_sort_with_limit_by.sql"
] | [
{
"comment": "This regression only proves the new guard when the `MergeTree` read still has multiple streams: the bad plan needs the per-stream `LimitByTransform` to run before the lifted `arrayJoin`. The test creates four parts, but background merges are still enabled, so an unfixed build can become a false ne... | true | ||
ClickHouse/ClickHouse | 104,558 | comment_to_fix | Do not lift `arrayJoin` above `SortingStep` (issue #82279) | This no-join regression still goes through `SortingStep`, so it does not cover the same row-truncation invariant for a plain `LIMIT` above `arrayJoin`. The second-pass `optimizePrimaryKeyConditionAndLimit` walks from a `SourceStepWithFilterBase` through `ExpressionStep`s and calls `setLimit` when it sees the outer `Lim... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | fab23475deb70684d0dbccc0d18a7e25678d8983 | diff --git a/tests/queries/0_stateless/04220_arrayjoin_after_sort_with_limit.sql b/tests/queries/0_stateless/04220_arrayjoin_after_sort_with_limit.sql
new file mode 100644
index 000000000000..3e1e2f1a870d
--- /dev/null
+++ b/tests/queries/0_stateless/04220_arrayjoin_after_sort_with_limit.sql
@@ -0,0 +1,63 @@
+-- Regres... | [
"tests/queries/0_stateless/04220_arrayjoin_after_sort_with_limit.sql"
] | [
{
"comment": "This no-join regression still goes through `SortingStep`, so it does not cover the same row-truncation invariant for a plain `LIMIT` above `arrayJoin`. The second-pass `optimizePrimaryKeyConditionAndLimit` walks from a `SourceStepWithFilterBase` through `ExpressionStep`s and calls `setLimit` when ... | true | ||
ClickHouse/ClickHouse | 104,558 | comment_to_fix | Do not lift `arrayJoin` above `SortingStep` (issue #82279) | This only checks the select list, but `ARRAY JOIN` clauses are stored separately in `ASTSelectQuery::arrayJoinExpressionList`, so the direct source-limit path can still cap the source before expansion. For example, `SELECT number FROM numbers(100) ARRAY JOIN if(number < 3, [], [number]) AS x LIMIT 3` should skip the em... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | fab23475deb70684d0dbccc0d18a7e25678d8983 | diff --git a/src/Processors/QueryPlan/numbersLikeUtils.cpp b/src/Processors/QueryPlan/numbersLikeUtils.cpp
index 8536d181b9d7..55e6221a3bd3 100644
--- a/src/Processors/QueryPlan/numbersLikeUtils.cpp
+++ b/src/Processors/QueryPlan/numbersLikeUtils.cpp
@@ -4,6 +4,7 @@
#include <Core/Settings.h>
#include <Interpreters... | [
"src/Processors/QueryPlan/numbersLikeUtils.cpp"
] | [
{
"comment": "This only checks the select list, but `ARRAY JOIN` clauses are stored separately in `ASTSelectQuery::arrayJoinExpressionList`, so the direct source-limit path can still cap the source before expansion. For example, `SELECT number FROM numbers(100) ARRAY JOIN if(number < 3, [], [number]) AS x LIMIT... | true | ||
ClickHouse/ClickHouse | 104,558 | comment_to_fix | Do not lift `arrayJoin` above `SortingStep` (issue #82279) | This guard still misses `arrayJoin` when it is hidden behind a top-level `WITH` alias, because it only walks `query.select()` plus the explicit `ARRAY JOIN` clause. `ApplyWithAliasVisitor` keeps the alias expression in `query.with()`, so `WITH arrayJoin(if(number < 3, [], [number])) AS x SELECT x FROM numbers(100) LIMI... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | fab23475deb70684d0dbccc0d18a7e25678d8983 | diff --git a/src/Processors/QueryPlan/numbersLikeUtils.cpp b/src/Processors/QueryPlan/numbersLikeUtils.cpp
index 8536d181b9d7..55e6221a3bd3 100644
--- a/src/Processors/QueryPlan/numbersLikeUtils.cpp
+++ b/src/Processors/QueryPlan/numbersLikeUtils.cpp
@@ -4,6 +4,7 @@
#include <Core/Settings.h>
#include <Interpreters... | [
"src/Processors/QueryPlan/numbersLikeUtils.cpp"
] | [
{
"comment": "This guard still misses `arrayJoin` when it is hidden behind a top-level `WITH` alias, because it only walks `query.select()` plus the explicit `ARRAY JOIN` clause. `ApplyWithAliasVisitor` keeps the alias expression in `query.with()`, so `WITH arrayJoin(if(number < 3, [], [number])) AS x SELECT x ... | true | ||
ClickHouse/ClickHouse | 104,558 | comment_to_fix | Do not lift `arrayJoin` above `SortingStep` (issue #82279) | This still leaves another hard source-limit path uncovered. The new guard stops the `numbers` / `primes` construction-time limit, but simple queries also set `query_info.trivial_limit` through `InterpreterSelectQuery::maxBlockSizeByLimit` without checking whether the current `SELECT` contains `arrayJoin`. `StorageLoop`... | 3659e5601eac2078ed0f3ccef17d3e9ea9bebc3c | fab23475deb70684d0dbccc0d18a7e25678d8983 | diff --git a/src/Processors/QueryPlan/numbersLikeUtils.cpp b/src/Processors/QueryPlan/numbersLikeUtils.cpp
index 8536d181b9d7..55e6221a3bd3 100644
--- a/src/Processors/QueryPlan/numbersLikeUtils.cpp
+++ b/src/Processors/QueryPlan/numbersLikeUtils.cpp
@@ -4,6 +4,7 @@
#include <Core/Settings.h>
#include <Interpreters... | [
"src/Processors/QueryPlan/numbersLikeUtils.cpp"
] | [
{
"comment": "This still leaves another hard source-limit path uncovered. The new guard stops the `numbers` / `primes` construction-time limit, but simple queries also set `query_info.trivial_limit` through `InterpreterSelectQuery::maxBlockSizeByLimit` without checking whether the current `SELECT` contains `arr... | true | ||
ClickHouse/ClickHouse | 106,621 | issue_to_patch | Fix `Memory` table abort on `ALTER` commands with no per-row data effect (STID 2380-3043) | Fixes `STID: 2380-3043` (`Logical error: Mutation of \`Memory\` table produced incomplete output: block 0 has 0 rows, expected N`), reported by @alexey-milovidov on https://github.com/ClickHouse/ClickHouse/pull/106615 as a chronic `BuzzHouse` finding hitting master and 8+ unrelated PRs.
Per @alexey-milovidov directive... | e78a4dac750cb4e71fb1928c6e3d760817d45e78 | a2562ae47772b1636ed6b807d67418b4153ea9a0 | diff --git a/src/Storages/StorageMemory.cpp b/src/Storages/StorageMemory.cpp
index f0fc30d478b6..065a3f4fa691 100644
--- a/src/Storages/StorageMemory.cpp
+++ b/src/Storages/StorageMemory.cpp
@@ -249,24 +249,38 @@ void StorageMemory::mutate(const MutationCommands & commands, ContextPtr context
{
std::lock_guard lo... | [
"src/Storages/StorageMemory.cpp",
"tests/queries/0_stateless/04322_memory_mutate_no_op_commands_2380_3043.reference",
"tests/queries/0_stateless/04322_memory_mutate_no_op_commands_2380_3043.sql"
] | [
{
"comment": "This `MATERIALIZE_TTL` entry does not actually make `ALTER TABLE ... MATERIALIZE TTL` a no-op for `Memory`: `InterpreterAlterQuery::runCommandSegments` builds a `MutationsInterpreter` for validation before `StorageMemory::mutate` is called, and `MutationsInterpreter::prepare` still throws `Cannot ... | diff --git a/tests/queries/0_stateless/04322_memory_mutate_no_op_commands_2380_3043.reference b/tests/queries/0_stateless/04322_memory_mutate_no_op_commands_2380_3043.reference
new file mode 100644
index 000000000000..d0b25890f90e
--- /dev/null
+++ b/tests/queries/0_stateless/04322_memory_mutate_no_op_commands_2380_304... | true | |
ClickHouse/ClickHouse | 106,621 | comment_to_fix | Fix `Memory` table abort on `ALTER` commands with no per-row data effect (STID 2380-3043) | This `MATERIALIZE_TTL` entry does not actually make `ALTER TABLE ... MATERIALIZE TTL` a no-op for `Memory`: `InterpreterAlterQuery::runCommandSegments` builds a `MutationsInterpreter` for validation before `StorageMemory::mutate` is called, and `MutationsInterpreter::prepare` still throws `Cannot MATERIALIZE TTL as the... | e78a4dac750cb4e71fb1928c6e3d760817d45e78 | a2562ae47772b1636ed6b807d67418b4153ea9a0 | diff --git a/src/Storages/StorageMemory.cpp b/src/Storages/StorageMemory.cpp
index f0fc30d478b6..065a3f4fa691 100644
--- a/src/Storages/StorageMemory.cpp
+++ b/src/Storages/StorageMemory.cpp
@@ -249,24 +249,38 @@ void StorageMemory::mutate(const MutationCommands & commands, ContextPtr context
{
std::lock_guard lo... | [
"src/Storages/StorageMemory.cpp"
] | [
{
"comment": "This `MATERIALIZE_TTL` entry does not actually make `ALTER TABLE ... MATERIALIZE TTL` a no-op for `Memory`: `InterpreterAlterQuery::runCommandSegments` builds a `MutationsInterpreter` for validation before `StorageMemory::mutate` is called, and `MutationsInterpreter::prepare` still throws `Cannot ... | true | ||
ClickHouse/ClickHouse | 106,621 | comment_to_fix | Fix `Memory` table abort on `ALTER` commands with no per-row data effect (STID 2380-3043) | These `DROP_*` entries are not reached by user `ALTER` queries on `Memory`. `DROP INDEX`, `DROP PROJECTION`, and `DROP STATISTICS` are parsed into an `AlterCommands` segment, and `StorageMemory::checkAlterIsPossible` rejects those command types before `StorageMemory::mutate` is called. So the PR/changelog promise that ... | e78a4dac750cb4e71fb1928c6e3d760817d45e78 | a2562ae47772b1636ed6b807d67418b4153ea9a0 | diff --git a/src/Storages/StorageMemory.cpp b/src/Storages/StorageMemory.cpp
index f0fc30d478b6..065a3f4fa691 100644
--- a/src/Storages/StorageMemory.cpp
+++ b/src/Storages/StorageMemory.cpp
@@ -249,24 +249,38 @@ void StorageMemory::mutate(const MutationCommands & commands, ContextPtr context
{
std::lock_guard lo... | [
"src/Storages/StorageMemory.cpp"
] | [
{
"comment": "These `DROP_*` entries are not reached by user `ALTER` queries on `Memory`. `DROP INDEX`, `DROP PROJECTION`, and `DROP STATISTICS` are parsed into an `AlterCommands` segment, and `StorageMemory::checkAlterIsPossible` rejects those command types before `StorageMemory::mutate` is called. So the PR/c... | true | ||
ClickHouse/ClickHouse | 107,419 | issue_to_patch | Retry the changed-files GitHub API call and report failures clearly | <!--
Related: https://github.com/ClickHouse/ClickHouse/pull/74691
-->
`GH.get_changed_files` fetches the list of files a PR touches via `gh api .../pulls/<n>/files`. The `store_data` pre-hook fetches it once and stores it into the job KV data; several other workflow hooks (`pr_labels_and_category`, `team_notifications... | 1a5e24c889955eaff7e2e29e19e0074f30bf1322 | 653085058b9b2b5f932c03146f3ed39565d3225f | diff --git a/ci/jobs/scripts/workflow_hooks/feature_docs.py b/ci/jobs/scripts/workflow_hooks/feature_docs.py
index 11e1bd6488b7..f03428fbdb42 100644
--- a/ci/jobs/scripts/workflow_hooks/feature_docs.py
+++ b/ci/jobs/scripts/workflow_hooks/feature_docs.py
@@ -42,6 +42,11 @@ def check_docs():
info = Info()
if L... | [
"ci/jobs/scripts/workflow_hooks/feature_docs.py",
"ci/jobs/scripts/workflow_hooks/pr_labels_and_category.py",
"ci/jobs/scripts/workflow_hooks/team_notifications.py",
"ci/praktika/gh.py"
] | [
{
"comment": "This is the contract the PR fixes, but it is not covered by a focused regression test. A future change could reintroduce the original one-shot behavior and CI would only catch it during the next transient GitHub outage. Please add a small `ci/tests/test_gh.py` test that monkeypatches `Info` and `S... | true | ||
ClickHouse/ClickHouse | 107,419 | comment_to_fix | Retry the changed-files GitHub API call and report failures clearly | This is the contract the PR fixes, but it is not covered by a focused regression test. A future change could reintroduce the original one-shot behavior and CI would only catch it during the next transient GitHub outage. Please add a small `ci/tests/test_gh.py` test that monkeypatches `Info` and `Shell.get_res_stdout_st... | 1a5e24c889955eaff7e2e29e19e0074f30bf1322 | 653085058b9b2b5f932c03146f3ed39565d3225f | diff --git a/ci/praktika/gh.py b/ci/praktika/gh.py
index 90b67d88ced4..6646239ebccc 100644
--- a/ci/praktika/gh.py
+++ b/ci/praktika/gh.py
@@ -91,18 +91,30 @@ def get_changed_files(cls, strict=False) -> List[str]:
# HEAD, same as deleted files, which were always included.
jq_both_sides = ".filename, (... | [
"ci/praktika/gh.py"
] | [
{
"comment": "This is the contract the PR fixes, but it is not covered by a focused regression test. A future change could reintroduce the original one-shot behavior and CI would only catch it during the next transient GitHub outage. Please add a small `ci/tests/test_gh.py` test that monkeypatches `Info` and `S... | true | ||
ClickHouse/ClickHouse | 107,229 | issue_to_patch | Pass-through row count estimation for row-preserving transforming steps | Add pass-through for generic transform which preserve row count
From #106955
### Changelog category (leave one):
- Performance Improvement
### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes ... | 09c2cbb60368d15a866900aea3c073fa633825a2 | 890ce94bdcfb0cf2cfebe197e326e9f9d1bcb7c9 | diff --git a/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp b/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp
index c44104df03f4..d37f4bf3a162 100644
--- a/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp
+++ b/src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp
@@ -420,11 +420,16 @@ static ... | [
"src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp"
] | [
{
"comment": "Can't it change number of distinct values?",
"path": "src/Processors/QueryPlan/Optimizations/optimizeJoin.cpp",
"hunk": "@@ -420,11 +420,16 @@ static RelationStats estimateReadRowsCount(QueryPlan::Node & node, const Actions\n }\n return stats;\n }\n+\n #if CLICKHOUSE_CL... | true | ||
ClickHouse/ClickHouse | 107,388 | issue_to_patch | Data race on ServerSettings during reload
### Describe the bug
(From Claude)
This is a unsynchronized read/write race on the global ServerSettings object that lives inside ContextSharedPart.
Here's what's happening:
The writer (thread T812, ConfigReloader): During a config reload, Server.cpp:2482 calls Context::s... | Revert "Revert "Make getServerSetting return live values for runtime-changeable settings"" | Re-applies #105172 ("Make `getServerSetting` return live values for runtime-changeable settings"), which was reverted by #106930 because of a data race.
`getServerSetting` read the live value of runtime-changeable server settings by copy-constructing the whole `ServerSettings` struct from the reference returned by `Co... | 19059120f5e793db617f4370f6493365992fe4df | 02ce0c53642fe63bae3648444a0ee19fea98fffb | diff --git a/src/Core/ServerSettings.cpp b/src/Core/ServerSettings.cpp
index 664af43c27c8..4c5319cd8ead 100644
--- a/src/Core/ServerSettings.cpp
+++ b/src/Core/ServerSettings.cpp
@@ -30,9 +30,13 @@
#include <Common/MemoryTracker.h>
#include <Common/DNSResolver.h>
+#include <Common/ZooKeeper/ZooKeeper.h>
+#include <... | [
"src/Core/ServerSettings.cpp",
"src/Core/ServerSettings.h",
"src/Functions/getServerSetting.cpp",
"src/Interpreters/Context.cpp",
"src/Interpreters/Context.h",
"src/Storages/System/StorageSystemServerSettings.cpp",
"tests/queries/0_stateless/04241_get_server_setting_live_values.reference",
"tests/quer... | [
{
"comment": "This restores the unsynchronized `ServerSettings` snapshot that triggered `#106902`. `Context::getServerSettings` returns a reference to `shared->server_settings` without taking `shared->mutex`, but config reload still mutates that same object under the mutex via `Context::setS3QueueDisableStreami... | diff --git a/tests/queries/0_stateless/04241_get_server_setting_live_values.reference b/tests/queries/0_stateless/04241_get_server_setting_live_values.reference
new file mode 100644
index 000000000000..627e1097cda3
--- /dev/null
+++ b/tests/queries/0_stateless/04241_get_server_setting_live_values.reference
@@ -0,0 +1,5... | true |
ClickHouse/ClickHouse | 107,388 | comment_to_fix | Revert "Revert "Make getServerSetting return live values for runtime-changeable settings"" | This restores the unsynchronized `ServerSettings` snapshot that triggered `#106902`. `Context::getServerSettings` returns a reference to `shared->server_settings` without taking `shared->mutex`, but config reload still mutates that same object under the mutex via `Context::setS3QueueDisableStreaming` and `Context::setM... | 19059120f5e793db617f4370f6493365992fe4df | 02ce0c53642fe63bae3648444a0ee19fea98fffb | diff --git a/src/Functions/getServerSetting.cpp b/src/Functions/getServerSetting.cpp
index 8cdf1110564a..290f54c76d6e 100644
--- a/src/Functions/getServerSetting.cpp
+++ b/src/Functions/getServerSetting.cpp
@@ -70,7 +70,21 @@ class FunctionGetServerSetting final : public IFunction
std::string_view setting_na... | [
"src/Functions/getServerSetting.cpp"
] | [
{
"comment": "This restores the unsynchronized `ServerSettings` snapshot that triggered `#106902`. `Context::getServerSettings` returns a reference to `shared->server_settings` without taking `shared->mutex`, but config reload still mutates that same object under the mutex via `Context::setS3QueueDisableStreami... | true | ||
ClickHouse/ClickHouse | 93,830 | issue_to_patch | Support for ALTER TABLE ADD ENUM VALUES | ### Changelog category (leave one):
- New Feature
### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md):
Implement `ADD ENUM VALUES` in `ALTER TABLE` queries to simplify appending... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/docs/en/sql-reference/data-types/enum.md b/docs/en/sql-reference/data-types/enum.md
index 5f330bcd8766..ecbc90e8bc42 100644
--- a/docs/en/sql-reference/data-types/enum.md
+++ b/docs/en/sql-reference/data-types/enum.md
@@ -162,3 +162,26 @@ Enum values are also convertible to numeric types using the `toT` fu... | [
"docs/en/sql-reference/data-types/enum.md",
"docs/en/sql-reference/statements/alter/column.md",
"src/DataTypes/DataTypeEnum.cpp",
"src/DataTypes/DataTypeEnum.h",
"src/DataTypes/EnumValues.cpp",
"src/DataTypes/EnumValues.h",
"src/Parsers/ASTAlterQuery.cpp",
"src/Parsers/ASTAlterQuery.h",
"src/Parsers... | [
{
"comment": "I think about syntax. We never had function in `expression` of MODIFY COLUMN\r\nhttps://clickhouse.com/docs/sql-reference/statements/alter/column#modify-column. \r\n\r\nHave you seen any examples of similar logic in other DBMS?",
"path": "docs/en/sql-reference/data-types/enum.md",
"hunk": ... | diff --git a/tests/queries/0_stateless/04307_add_to_enum.reference b/tests/queries/0_stateless/04307_add_to_enum.reference
new file mode 100644
index 000000000000..39a4e9ed5ed6
--- /dev/null
+++ b/tests/queries/0_stateless/04307_add_to_enum.reference
@@ -0,0 +1,92 @@
+======= NULLABLE ===============
+======= Enum ==... | true | |
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | ```suggestion
There is a syntax sugar to add new values to enum using ALTER [MODIFY COLUMN ADD ENUM VALUES](../../sql-reference/statements/alter/column.md#modify-column-add-enum-values)
``` | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/docs/en/sql-reference/data-types/enum.md b/docs/en/sql-reference/data-types/enum.md
index 5f330bcd8766..ecbc90e8bc42 100644
--- a/docs/en/sql-reference/data-types/enum.md
+++ b/docs/en/sql-reference/data-types/enum.md
@@ -162,3 +162,26 @@ Enum values are also convertible to numeric types using the `toT` fu... | [
"docs/en/sql-reference/data-types/enum.md"
] | [
{
"comment": "```suggestion\nThere is a syntax sugar to add new values to enum using ALTER [MODIFY COLUMN ADD ENUM VALUES](../../sql-reference/statements/alter/column.md#modify-column-add-enum-values)\n```",
"path": "docs/en/sql-reference/data-types/enum.md",
"hunk": "@@ -164,3 +164,26 @@ Enum values ar... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | Typo: `is_nullale` β `is_nullable` | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp
index 3863adc67515..387e0f5e55c2 100644
--- a/src/Storages/AlterCommands.cpp
+++ b/src/Storages/AlterCommands.cpp
@@ -81,6 +81,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;... | [
"src/Storages/AlterCommands.cpp"
] | [
{
"comment": "Typo: `is_nullale` β `is_nullable`",
"path": "src/Storages/AlterCommands.cpp",
"hunk": "@@ -1363,6 +1373,76 @@ void AlterCommands::prepare(const StorageInMemoryMetadata & metadata)\n command.default_expression = column_from_table.default_desc.expression;\n ... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | Perhaps it would be great to also add an existing enum value (e.g. `'Four' = 4`) to verify it's a noop. | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/tests/queries/0_stateless/04307_add_to_enum.sql.j2 b/tests/queries/0_stateless/04307_add_to_enum.sql.j2
new file mode 100644
index 000000000000..250dd7fdf109
--- /dev/null
+++ b/tests/queries/0_stateless/04307_add_to_enum.sql.j2
@@ -0,0 +1,129 @@
+{% for NULLABLE_START, NULLABLE_END in {'' : '', 'Nullable(... | [
"tests/queries/0_stateless/04307_add_to_enum.sql.j2"
] | [
{
"comment": "Perhaps it would be great to also add an existing enum value (e.g. `'Four' = 4`) to verify it's a noop.",
"path": "tests/queries/0_stateless/04307_add_to_enum.sql.j2",
"hunk": "@@ -0,0 +1,45 @@\n+{% for NULLABLE_START, NULLABLE_END in {'' : '', 'Nullable(' : ')'}.items() -%}\n+SELECT '====... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | `add_enum_values` is cloned and formatted, but `ASTAlterCommand::forEachPointerToChild` is not updated for it. During generic AST rewrites, `children` may be replaced while this typed field stays stale, which can desynchronize the command state. Please add `f(nullptr, &add_enum_values)` (and, for consistency, `f(nullpt... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Parsers/ASTAlterQuery.cpp b/src/Parsers/ASTAlterQuery.cpp
index e0a808c98056..17a8e6ca3420 100644
--- a/src/Parsers/ASTAlterQuery.cpp
+++ b/src/Parsers/ASTAlterQuery.cpp
@@ -67,6 +67,8 @@ ASTPtr ASTAlterCommand::clone() const
res->rename_to = res->children.emplace_back(rename_to->clone()).get(... | [
"src/Parsers/ASTAlterQuery.cpp"
] | [
{
"comment": "`add_enum_values` is cloned and formatted, but `ASTAlterCommand::forEachPointerToChild` is not updated for it. During generic AST rewrites, `children` may be replaced while this typed field stays stale, which can desynchronize the command state. Please add `f(nullptr, &add_enum_values)` (and, for ... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | ### ADD ENUM VALUES silently drops column default expressions
**High Severity**
<!-- DESCRIPTION START -->
The `add_enum_values` processing sets `command.data_type` *after* the default-expression preservation check. The preservation check at the start of the `has_column` block (`if (command.data_type && !command.defa... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp
index 3863adc67515..387e0f5e55c2 100644
--- a/src/Storages/AlterCommands.cpp
+++ b/src/Storages/AlterCommands.cpp
@@ -81,6 +81,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;... | [
"src/Storages/AlterCommands.cpp"
] | [
{
"comment": "### ADD ENUM VALUES silently drops column default expressions\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nThe `add_enum_values` processing sets `command.data_type` *after* the default-expression preservation check. The preservation check at the start of the `has_column` block (`if (command... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | ### Overflow error message reports wrong value for relative enums
**Medium Severity**
<!-- DESCRIPTION START -->
In `mergeEnumTypes`, when `is_relative` is true, the overflow error message reports `val` (the original auto-assigned value, e.g., 1) instead of `candidate64` (the actual computed value, e.g., 128). A user... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/DataTypes/DataTypeEnum.cpp b/src/DataTypes/DataTypeEnum.cpp
index 682cb3106b26..e401538cfdc8 100644
--- a/src/DataTypes/DataTypeEnum.cpp
+++ b/src/DataTypes/DataTypeEnum.cpp
@@ -16,6 +16,7 @@
#include <Interpreters/Context.h>
#include <Core/Settings.h>
+#include <algorithm>
#include <limits>
@... | [
"src/DataTypes/DataTypeEnum.cpp"
] | [
{
"comment": "### Overflow error message reports wrong value for relative enums\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nIn `mergeEnumTypes`, when `is_relative` is true, the overflow error message reports `val` (the original auto-assigned value, e.g., 1) instead of `candidate64` (the actual compute... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | When `ADD ENUM VALUES` sets `command.data_type` here, `default_kind`/`default_expression` are still unset for this command. Later, `AlterCommand::apply` treats any `data_type` change as a default rewrite (`if (default_expression || data_type)`), so this path can silently drop an existing `DEFAULT`/`MATERIALIZED`/`ALIAS... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp
index 3863adc67515..387e0f5e55c2 100644
--- a/src/Storages/AlterCommands.cpp
+++ b/src/Storages/AlterCommands.cpp
@@ -81,6 +81,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;... | [
"src/Storages/AlterCommands.cpp"
] | [
{
"comment": "When `ADD ENUM VALUES` sets `command.data_type` here, `default_kind`/`default_expression` are still unset for this command. Later, `AlterCommand::apply` treats any `data_type` change as a default rewrite (`if (default_expression || data_type)`), so this path can silently drop an existing `DEFAULT`... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | ### Assertion doesn't guard against type with ADD ENUM VALUES
**Low Severity**
<!-- DESCRIPTION START -->
The `chassert` verifying that column type isn't populated alongside special modifiers checks `command->remove_property`, `command_settings_changes`, and `command_settings_resets`, but omits `command_add_enum_valu... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Parsers/ParserAlterQuery.cpp b/src/Parsers/ParserAlterQuery.cpp
index 866ce4286351..e2bd193b1a2d 100644
--- a/src/Parsers/ParserAlterQuery.cpp
+++ b/src/Parsers/ParserAlterQuery.cpp
@@ -45,6 +45,7 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
ParserKeyword s_m... | [
"src/Parsers/ParserAlterQuery.cpp"
] | [
{
"comment": "### Assertion doesn't guard against type with ADD ENUM VALUES\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe `chassert` verifying that column type isn't populated alongside special modifiers checks `command->remove_property`, `command_settings_changes`, and `command_settings_resets`, but o... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | β οΈ `DataTypeEnum.h` is a high-fanout header, and adding a direct include of `Parsers/IAST.h` here increases transitive compile cost across many translation units. Please switch this to a forward declaration include (for example `Parsers/IAST_fwd.h`) and keep the full parser header out of this core type header. | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/DataTypes/DataTypeEnum.h b/src/DataTypes/DataTypeEnum.h
index 86baf4238f9a..8e5222499559 100644
--- a/src/DataTypes/DataTypeEnum.h
+++ b/src/DataTypes/DataTypeEnum.h
@@ -1,8 +1,10 @@
#pragma once
+#include <vector>
#include <DataTypes/IDataType.h>
#include <DataTypes/EnumValues.h>
#include <Colum... | [
"src/DataTypes/DataTypeEnum.h"
] | [
{
"comment": "β οΈ `DataTypeEnum.h` is a high-fanout header, and adding a direct include of `Parsers/IAST.h` here increases transitive compile cost across many translation units. Please switch this to a forward declaration include (for example `Parsers/IAST_fwd.h`) and keep the full parser header out of this core... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | π‘ Typo in SQL syntax example: `ADD ENUM VALUES (EnumName [= number] , ...]);` has an extra `]` before `);`. It should be `ADD ENUM VALUES (EnumName [= number], ...);`. | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/docs/en/sql-reference/statements/alter/column.md b/docs/en/sql-reference/statements/alter/column.md
index f845210447bc..39f8fa02bb7c 100644
--- a/docs/en/sql-reference/statements/alter/column.md
+++ b/docs/en/sql-reference/statements/alter/column.md
@@ -29,6 +29,7 @@ The following actions are supported:
-... | [
"docs/en/sql-reference/statements/alter/column.md"
] | [
{
"comment": "π‘ Typo in SQL syntax example: `ADD ENUM VALUES (EnumName [= number] , ...]);` has an extra `]` before `);`. It should be `ADD ENUM VALUES (EnumName [= number], ...);`.",
"path": "docs/en/sql-reference/statements/alter/column.md",
"hunk": "@@ -275,6 +282,24 @@ Reset column setting `max_com... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | ### Duplicate default expression preservation block after enum merge
**Low Severity**
<!-- DESCRIPTION START -->
The block at lines 1512β1516 (`if (command.data_type && !command.default_expression && ...)`) is an exact duplicate of the block at lines 1435β1439. The second copy was added to handle the case where `comm... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp
index 3863adc67515..387e0f5e55c2 100644
--- a/src/Storages/AlterCommands.cpp
+++ b/src/Storages/AlterCommands.cpp
@@ -81,6 +81,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;... | [
"src/Storages/AlterCommands.cpp"
] | [
{
"comment": "### Duplicate default expression preservation block after enum merge\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe block at lines 1512β1516 (`if (command.data_type && !command.default_expression && ...)`) is an exact duplicate of the block at lines 1435β1439. The second copy was added to ... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | β οΈ `ADD ENUM VALUES` validates the enum payload before validating that the target column is actually `Enum`. In this block, `tryCreateAddToEnumType` runs before checking `eti.enum_type`, so for non-enum columns an out-of-range literal (e.g. `1000`) throws `ARGUMENT_OUT_OF_BOUND` instead of the expected `ILLEGAL_COLUMN`... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp
index 3863adc67515..387e0f5e55c2 100644
--- a/src/Storages/AlterCommands.cpp
+++ b/src/Storages/AlterCommands.cpp
@@ -81,6 +81,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;... | [
"src/Storages/AlterCommands.cpp"
] | [
{
"comment": "β οΈ `ADD ENUM VALUES` validates the enum payload before validating that the target column is actually `Enum`. In this block, `tryCreateAddToEnumType` runs before checking `eti.enum_type`, so for non-enum columns an out-of-range literal (e.g. `1000`) throws `ARGUMENT_OUT_OF_BOUND` instead of the exp... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | `ADD ENUM VALUES` currently uses one global relative flag for the whole list. If any explicit assignment appears, earlier implicit entries are treated as absolute, so valid mixed forms can fail (for example, base max 2 with `ADD ENUM VALUES` using implicit first and explicit later maps the implicit value to 1 instead o... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/DataTypes/DataTypeEnum.cpp b/src/DataTypes/DataTypeEnum.cpp
index 682cb3106b26..e401538cfdc8 100644
--- a/src/DataTypes/DataTypeEnum.cpp
+++ b/src/DataTypes/DataTypeEnum.cpp
@@ -16,6 +16,7 @@
#include <Interpreters/Context.h>
#include <Core/Settings.h>
+#include <algorithm>
#include <limits>
@... | [
"src/DataTypes/DataTypeEnum.cpp"
] | [
{
"comment": "`ADD ENUM VALUES` currently uses one global relative flag for the whole list. If any explicit assignment appears, earlier implicit entries are treated as absolute, so valid mixed forms can fail (for example, base max 2 with `ADD ENUM VALUES` using implicit first and explicit later maps the implici... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | β οΈ Test coverage misses an important error-priority case for `ADD ENUM VALUES` on non-enum columns.
This test checks `ILLEGAL_COLUMN` only for an in-range value (`'A' = 1`). Please add a companion case with an out-of-range literal (for example `1000`) and still expect `ILLEGAL_COLUMN`.
Without this, a regression can ... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/tests/queries/0_stateless/04307_add_to_enum.sql.j2 b/tests/queries/0_stateless/04307_add_to_enum.sql.j2
new file mode 100644
index 000000000000..250dd7fdf109
--- /dev/null
+++ b/tests/queries/0_stateless/04307_add_to_enum.sql.j2
@@ -0,0 +1,129 @@
+{% for NULLABLE_START, NULLABLE_END in {'' : '', 'Nullable(... | [
"tests/queries/0_stateless/04307_add_to_enum.sql.j2"
] | [
{
"comment": "β οΈ Test coverage misses an important error-priority case for `ADD ENUM VALUES` on non-enum columns.\n\nThis test checks `ILLEGAL_COLUMN` only for an in-range value (`'A' = 1`). Please add a companion case with an out-of-range literal (for example `1000`) and still expect `ILLEGAL_COLUMN`.\n\nWitho... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | `autoAssignNumberForEnum` now rejects any explicit assignment after a leading implicit prefix when the explicit value is `<= relative_max`.
That introduces a backward-compatibility regression in general `Enum` parsing (not only `ADD ENUM VALUES`): declarations with intentionally absolute explicit values (for example n... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/DataTypes/DataTypeEnum.cpp b/src/DataTypes/DataTypeEnum.cpp
index 682cb3106b26..e401538cfdc8 100644
--- a/src/DataTypes/DataTypeEnum.cpp
+++ b/src/DataTypes/DataTypeEnum.cpp
@@ -16,6 +16,7 @@
#include <Interpreters/Context.h>
#include <Core/Settings.h>
+#include <algorithm>
#include <limits>
@... | [
"src/DataTypes/DataTypeEnum.cpp"
] | [
{
"comment": "`autoAssignNumberForEnum` now rejects any explicit assignment after a leading implicit prefix when the explicit value is `<= relative_max`.\n\nThat introduces a backward-compatibility regression in general `Enum` parsing (not only `ADD ENUM VALUES`): declarations with intentionally absolute explic... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | β οΈ Documentation and examples in this PR show that `ADD ENUM VALUES` also works for `Nullable(Enum*)`, but this sentence mentions only non-nullable enum types. Please mention `Nullable(Enum)`, `Nullable(Enum8)`, and `Nullable(Enum16)` to avoid user confusion.
| 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/docs/en/sql-reference/statements/alter/column.md b/docs/en/sql-reference/statements/alter/column.md
index f845210447bc..39f8fa02bb7c 100644
--- a/docs/en/sql-reference/statements/alter/column.md
+++ b/docs/en/sql-reference/statements/alter/column.md
@@ -29,6 +29,7 @@ The following actions are supported:
-... | [
"docs/en/sql-reference/statements/alter/column.md"
] | [
{
"comment": "β οΈ Documentation and examples in this PR show that `ADD ENUM VALUES` also works for `Nullable(Enum*)`, but this sentence mentions only non-nullable enum types. Please mention `Nullable(Enum)`, `Nullable(Enum8)`, and `Nullable(Enum16)` to avoid user confusion.\n",
"path": "docs/en/sql-reference... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | Small docs typo: `syntax sugar` is usually written as `syntactic sugar`.
| 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/docs/en/sql-reference/data-types/enum.md b/docs/en/sql-reference/data-types/enum.md
index 5f330bcd8766..ecbc90e8bc42 100644
--- a/docs/en/sql-reference/data-types/enum.md
+++ b/docs/en/sql-reference/data-types/enum.md
@@ -162,3 +162,26 @@ Enum values are also convertible to numeric types using the `toT` fu... | [
"docs/en/sql-reference/data-types/enum.md"
] | [
{
"comment": "Small docs typo: `syntax sugar` is usually written as `syntactic sugar`.\n",
"path": "docs/en/sql-reference/data-types/enum.md",
"hunk": "@@ -164,3 +164,26 @@ Enum values are also convertible to numeric types using the `toT` function, wher\n The Enum type can be changed without cost using ... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | ```suggestion
factory.registerDataType("Enum16", [](const ASTPtr & arguments)
{
return createExact<DataTypeEnum16>(arguments, false);
});
``` | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/DataTypes/DataTypeEnum.cpp b/src/DataTypes/DataTypeEnum.cpp
index 682cb3106b26..e401538cfdc8 100644
--- a/src/DataTypes/DataTypeEnum.cpp
+++ b/src/DataTypes/DataTypeEnum.cpp
@@ -16,6 +16,7 @@
#include <Interpreters/Context.h>
#include <Core/Settings.h>
+#include <algorithm>
#include <limits>
@... | [
"src/DataTypes/DataTypeEnum.cpp"
] | [
{
"comment": "```suggestion\n factory.registerDataType(\"Enum16\", [](const ASTPtr & arguments)\n {\n return createExact<DataTypeEnum16>(arguments, false);\n });\n```",
"path": "src/DataTypes/DataTypeEnum.cpp",
"hunk": "@@ -332,17 +362,88 @@ static DataTypePtr create(const ASTPtr & argum... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | ```suggestion
factory.registerDataType("Enum", [](const ASTPtr & arguments)
{
return create(arguments, false);
});
``` | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/DataTypes/DataTypeEnum.cpp b/src/DataTypes/DataTypeEnum.cpp
index 682cb3106b26..e401538cfdc8 100644
--- a/src/DataTypes/DataTypeEnum.cpp
+++ b/src/DataTypes/DataTypeEnum.cpp
@@ -16,6 +16,7 @@
#include <Interpreters/Context.h>
#include <Core/Settings.h>
+#include <algorithm>
#include <limits>
@... | [
"src/DataTypes/DataTypeEnum.cpp"
] | [
{
"comment": "```suggestion\n factory.registerDataType(\"Enum\", [](const ASTPtr & arguments)\n {\n return create(arguments, false);\n });\n```",
"path": "src/DataTypes/DataTypeEnum.cpp",
"hunk": "@@ -332,17 +362,88 @@ static DataTypePtr create(const ASTPtr & arguments)\n Int64 v... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | ```suggestion
``` | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp
index 3863adc67515..387e0f5e55c2 100644
--- a/src/Storages/AlterCommands.cpp
+++ b/src/Storages/AlterCommands.cpp
@@ -81,6 +81,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;... | [
"src/Storages/AlterCommands.cpp"
] | [
{
"comment": "```suggestion\n```",
"path": "src/Storages/AlterCommands.cpp",
"hunk": "@@ -1437,12 +1447,82 @@ void AlterCommands::prepare(const StorageInMemoryMetadata & metadata, bool share\n if (has_column)\n {\n const auto & column_from_table = columns.get(comm... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | Small docs typo in the syntax snippet: there is an extra space before the comma in ``'EnumName' [= number] , ...``.
Could you change it to ``'EnumName' [= number], ...`` for consistency with the rest of SQL syntax docs?
| 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/docs/en/sql-reference/statements/alter/column.md b/docs/en/sql-reference/statements/alter/column.md
index f845210447bc..39f8fa02bb7c 100644
--- a/docs/en/sql-reference/statements/alter/column.md
+++ b/docs/en/sql-reference/statements/alter/column.md
@@ -29,6 +29,7 @@ The following actions are supported:
-... | [
"docs/en/sql-reference/statements/alter/column.md"
] | [
{
"comment": "Small docs typo in the syntax snippet: there is an extra space before the comma in ``'EnumName' [= number] , ...``.\n\nCould you change it to ``'EnumName' [= number], ...`` for consistency with the rest of SQL syntax docs?\n",
"path": "docs/en/sql-reference/statements/alter/column.md",
"hu... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | `prepare` merges this `ADD ENUM VALUES` payload against `column_from_table`, but `column_from_table` comes from the original `columns` snapshot and that snapshot is never advanced after earlier commands in the same `ALTER`. For example, `ALTER TABLE t MODIFY COLUMN x ADD ENUM VALUES('a'), MODIFY COLUMN x ADD ENUM VALUE... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp
index 3863adc67515..387e0f5e55c2 100644
--- a/src/Storages/AlterCommands.cpp
+++ b/src/Storages/AlterCommands.cpp
@@ -81,6 +81,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;... | [
"src/Storages/AlterCommands.cpp"
] | [
{
"comment": "`prepare` merges this `ADD ENUM VALUES` payload against `column_from_table`, but `column_from_table` comes from the original `columns` snapshot and that snapshot is never advanced after earlier commands in the same `ALTER`. For example, `ALTER TABLE t MODIFY COLUMN x ADD ENUM VALUES('a'), MODIFY C... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | `ADD ENUM VALUES` still derives from a stale snapshot when it follows a normal type `MODIFY COLUMN` in the same `ALTER`. This line advances `columns` only after an `ADD ENUM VALUES`; a preceding command like `MODIFY COLUMN x Enum8('a' = 1, 'b' = 2), MODIFY COLUMN x ADD ENUM VALUES('c')` leaves `columns` at the original... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp
index 3863adc67515..387e0f5e55c2 100644
--- a/src/Storages/AlterCommands.cpp
+++ b/src/Storages/AlterCommands.cpp
@@ -81,6 +81,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;... | [
"src/Storages/AlterCommands.cpp"
] | [
{
"comment": "`ADD ENUM VALUES` still derives from a stale snapshot when it follows a normal type `MODIFY COLUMN` in the same `ALTER`. This line advances `columns` only after an `ADD ENUM VALUES`; a preceding command like `MODIFY COLUMN x Enum8('a' = 1, 'b' = 2), MODIFY COLUMN x ADD ENUM VALUES('c')` leaves `co... | true | ||
ClickHouse/ClickHouse | 93,830 | comment_to_fix | Support for ALTER TABLE ADD ENUM VALUES | This guard is global for the whole `ALTER`, so it rejects independent column changes that should not interact. For example, `ALTER TABLE t MODIFY COLUMN y UInt16, MODIFY COLUMN x ADD ENUM VALUES('b')` now throws `NOT_IMPLEMENTED` just because a previous command modified any column type, even though the stale-snapshot p... | 8a69decd78adb17700abfad4538c5d3750226194 | 07520f54fbc7a36adc637c461574cfc15b3a8c8e | diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp
index 3863adc67515..387e0f5e55c2 100644
--- a/src/Storages/AlterCommands.cpp
+++ b/src/Storages/AlterCommands.cpp
@@ -81,6 +81,7 @@ namespace ErrorCodes
extern const int NOT_IMPLEMENTED;
extern const int ALTER_OF_COLUMN_IS_FORBIDDEN;... | [
"src/Storages/AlterCommands.cpp"
] | [
{
"comment": "This guard is global for the whole `ALTER`, so it rejects independent column changes that should not interact. For example, `ALTER TABLE t MODIFY COLUMN y UInt16, MODIFY COLUMN x ADD ENUM VALUES('b')` now throws `NOT_IMPLEMENTED` just because a previous command modified any column type, even thoug... | true | ||
ClickHouse/ClickHouse | 58,957 | issue_to_patch | Parse detached part name properly in case of `tryN` suffix | ### 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):
Make possible to drop detached parts with the `tryN` suffix.
### Documentation entry for user-facing changes
... | b06c9fc1e8d0589a2689a964f841dfd2c4dde43b | 5a97c47f8cc44684f949f702e24274d41258eb00 | diff --git a/src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp b/src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp
index c4e6846a48d1..03d3c603fb41 100644
--- a/src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp
+++ b/src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp
@@ -146,7 +146,7 @@ String DataPartStorag... | [
"src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp",
"src/Storages/MergeTree/MergeTreeData.cpp",
"src/Storages/MergeTree/MergeTreePartInfo.cpp",
"src/Storages/MergeTree/MergeTreePartInfo.h",
"src/Storages/StorageReplicatedMergeTree.cpp",
"tests/queries/0_stateless/04063_drop_detached_part_with_try_n_su... | [
{
"comment": "```suggestion\n chassert(dir_name.size() >= 2);\n```",
"path": "src/Storages/MergeTree/MergeTreePartInfo.cpp",
"hunk": "@@ -343,7 +346,18 @@ DetachedPartInfo DetachedPartInfo::parseDetachedPartName(\n part_info.disk = disk;\n part_info.dir_name = dir_name;\n \n- /// First... | diff --git a/tests/queries/0_stateless/04063_drop_detached_part_with_try_n_suffix.reference b/tests/queries/0_stateless/04063_drop_detached_part_with_try_n_suffix.reference
new file mode 100644
index 000000000000..8accb1745c93
--- /dev/null
+++ b/tests/queries/0_stateless/04063_drop_detached_part_with_try_n_suffix.refe... | true | |
ClickHouse/ClickHouse | 58,957 | comment_to_fix | Parse detached part name properly in case of `tryN` suffix | ```suggestion
chassert(dir_name.size() >= 2);
``` | b06c9fc1e8d0589a2689a964f841dfd2c4dde43b | 5a97c47f8cc44684f949f702e24274d41258eb00 | diff --git a/src/Storages/MergeTree/MergeTreePartInfo.cpp b/src/Storages/MergeTree/MergeTreePartInfo.cpp
index 346b4bb09d75..c41ab2b4fcc1 100644
--- a/src/Storages/MergeTree/MergeTreePartInfo.cpp
+++ b/src/Storages/MergeTree/MergeTreePartInfo.cpp
@@ -1,9 +1,12 @@
#include <Storages/MergeTree/MergeTreePartInfo.h>
+
+#i... | [
"src/Storages/MergeTree/MergeTreePartInfo.cpp"
] | [
{
"comment": "```suggestion\n chassert(dir_name.size() >= 2);\n```",
"path": "src/Storages/MergeTree/MergeTreePartInfo.cpp",
"hunk": "@@ -343,7 +346,18 @@ DetachedPartInfo DetachedPartInfo::parseDetachedPartName(\n part_info.disk = disk;\n part_info.dir_name = dir_name;\n \n- /// First... | true | ||
ClickHouse/ClickHouse | 58,957 | comment_to_fix | Parse detached part name properly in case of `tryN` suffix | `parseDetachedPartName` currently strips `"_try"` even when there are no trailing digits (e.g. `all_0_0_0_try`), because `std::all_of` on an empty range returns `true`. It also only accepts up to two digits, while the suffix name is `tryN`.
This can misclassify malformed detached directory names as valid and still mis... | b06c9fc1e8d0589a2689a964f841dfd2c4dde43b | 5a97c47f8cc44684f949f702e24274d41258eb00 | diff --git a/src/Storages/MergeTree/MergeTreePartInfo.cpp b/src/Storages/MergeTree/MergeTreePartInfo.cpp
index 346b4bb09d75..c41ab2b4fcc1 100644
--- a/src/Storages/MergeTree/MergeTreePartInfo.cpp
+++ b/src/Storages/MergeTree/MergeTreePartInfo.cpp
@@ -1,9 +1,12 @@
#include <Storages/MergeTree/MergeTreePartInfo.h>
+
+#i... | [
"src/Storages/MergeTree/MergeTreePartInfo.cpp"
] | [
{
"comment": "`parseDetachedPartName` currently strips `\"_try\"` even when there are no trailing digits (e.g. `all_0_0_0_try`), because `std::all_of` on an empty range returns `true`. It also only accepts up to two digits, while the suffix name is `tryN`.\n\nThis can misclassify malformed detached directory na... | true | ||
ClickHouse/ClickHouse | 58,957 | comment_to_fix | Parse detached part name properly in case of `tryN` suffix | Please extend this regression test with boundary cases for the new suffix parser behavior:
- a malformed name without trailing digits (for example `all_0_0_0_try`) should stay invalid and not be treated as `tryN`;
- a multi-digit suffix (for example `all_0_0_0_try100`) should be accepted and droppable.
Without these ... | b06c9fc1e8d0589a2689a964f841dfd2c4dde43b | 5a97c47f8cc44684f949f702e24274d41258eb00 | diff --git a/tests/queries/0_stateless/04063_drop_detached_part_with_try_n_suffix.sh b/tests/queries/0_stateless/04063_drop_detached_part_with_try_n_suffix.sh
new file mode 100755
index 000000000000..d233b70f1e30
--- /dev/null
+++ b/tests/queries/0_stateless/04063_drop_detached_part_with_try_n_suffix.sh
@@ -0,0 +1,130 ... | [
"tests/queries/0_stateless/04063_drop_detached_part_with_try_n_suffix.sh"
] | [
{
"comment": "Please extend this regression test with boundary cases for the new suffix parser behavior:\n\n- a malformed name without trailing digits (for example `all_0_0_0_try`) should stay invalid and not be treated as `tryN`;\n- a multi-digit suffix (for example `all_0_0_0_try100`) should be accepted and d... | true | ||
ClickHouse/ClickHouse | 58,957 | comment_to_fix | Parse detached part name properly in case of `tryN` suffix | This makes `all_0_0_0_try1` a valid detached part with an empty `prefix`, but `ATTACH PARTITION ALL` still passes `part_info.dir_name` to `ActiveDataPartSet::tryAdd` / `getContainingPart` in `MergeTreeData::tryLoadPartsToAttach`. Those methods call `MergeTreePartInfo::fromPartName`, so the original suffixed directory n... | b06c9fc1e8d0589a2689a964f841dfd2c4dde43b | 5a97c47f8cc44684f949f702e24274d41258eb00 | diff --git a/src/Storages/MergeTree/MergeTreePartInfo.cpp b/src/Storages/MergeTree/MergeTreePartInfo.cpp
index 346b4bb09d75..c41ab2b4fcc1 100644
--- a/src/Storages/MergeTree/MergeTreePartInfo.cpp
+++ b/src/Storages/MergeTree/MergeTreePartInfo.cpp
@@ -1,9 +1,12 @@
#include <Storages/MergeTree/MergeTreePartInfo.h>
+
+#i... | [
"src/Storages/MergeTree/MergeTreePartInfo.cpp"
] | [
{
"comment": "This makes `all_0_0_0_try1` a valid detached part with an empty `prefix`, but `ATTACH PARTITION ALL` still passes `part_info.dir_name` to `ActiveDataPartSet::tryAdd` / `getContainingPart` in `MergeTreeData::tryLoadPartsToAttach`. Those methods call `MergeTreePartInfo::fromPartName`, so the origina... | true | ||
ClickHouse/ClickHouse | 58,957 | comment_to_fix | Parse detached part name properly in case of `tryN` suffix | `has_try_suffix` is only checked in `MergeTreeData::tryLoadPartsToAttach`, but `StorageReplicatedMergeTree::attachPartHelperFoundValidPart` has a separate detached-part candidate scan for `ATTACH_PART` log entries and still keeps any part with `valid_name && prefix.empty`. With this parser, a leftover `all_0_0_0_try1` ... | b06c9fc1e8d0589a2689a964f841dfd2c4dde43b | 5a97c47f8cc44684f949f702e24274d41258eb00 | diff --git a/src/Storages/MergeTree/MergeTreePartInfo.h b/src/Storages/MergeTree/MergeTreePartInfo.h
index 599093d820cc..f1ca8c0e2529 100644
--- a/src/Storages/MergeTree/MergeTreePartInfo.h
+++ b/src/Storages/MergeTree/MergeTreePartInfo.h
@@ -183,6 +183,12 @@ struct DetachedPartInfo : public MergeTreePartInfo
/// ... | [
"src/Storages/MergeTree/MergeTreePartInfo.h"
] | [
{
"comment": "`has_try_suffix` is only checked in `MergeTreeData::tryLoadPartsToAttach`, but `StorageReplicatedMergeTree::attachPartHelperFoundValidPart` has a separate detached-part candidate scan for `ATTACH_PART` log entries and still keeps any part with `valid_name && prefix.empty`. With this parser, a left... | true | ||
ClickHouse/ClickHouse | 97,014 | issue_to_patch | Fix bugfix validation failing due to git ownership check in Docker | ## Summary
- The `find_master_builds` function (introduced in #96868) runs `git log origin/master` inside Docker containers that run as root, but the repository is owned by the `ubuntu` user
- Git's ownership check blocks the command, returning empty output, so no master commits are found and the job crashes with `asse... | d0534d76c0718cf7d990e929bf22660641ae4a90 | 75f70593f94f80f92b7be4250fa0de20ce47d032 | diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index 4133e1e09402..980b5711112e 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -1698,7 +1698,7 @@ jobs:
PYTHONUNBUFFERED=1 python3 -m praktika run 'Integration tests (amd_asan_ub... | [
".github/workflows/pull_request.yml",
"ci/defs/job_configs.py",
"ci/jobs/functional_tests.py",
"ci/jobs/integration_test_job.py",
"ci/jobs/scripts/bugfix_validation.py",
"ci/jobs/scripts/clickhouse_proc.py",
"ci/jobs/scripts/workflow_hooks/store_data.py"
] | [
{
"comment": "this job stage checks crashes which are, in context of bugfix validation, \"success\" case (bug reproduced), the stage supposed to be executed for every build for job to work correctly\n",
"path": "ci/jobs/functional_tests.py",
"hunk": "",
"resolving_sha": "75f70593f94f80f92b7be4250fa0... | diff --git a/ci/jobs/integration_test_job.py b/ci/jobs/integration_test_job.py
index e10e26c92b5f..1afe89c6a602 100644
--- a/ci/jobs/integration_test_job.py
+++ b/ci/jobs/integration_test_job.py
@@ -8,6 +8,7 @@
from more_itertools import tail
+from ci.jobs.scripts.bugfix_validation import BUGFIX_BUILD_TYPES, find_... | true | |
ClickHouse/ClickHouse | 97,014 | comment_to_fix | Fix bugfix validation failing due to git ownership check in Docker | this job stage checks crashes which are, in context of bugfix validation, "success" case (bug reproduced), the stage supposed to be executed for every build for job to work correctly
| d0534d76c0718cf7d990e929bf22660641ae4a90 | 75f70593f94f80f92b7be4250fa0de20ce47d032 | diff --git a/ci/jobs/functional_tests.py b/ci/jobs/functional_tests.py
index a6b7388b8ce8..345fe10eaf8d 100644
--- a/ci/jobs/functional_tests.py
+++ b/ci/jobs/functional_tests.py
@@ -5,6 +5,7 @@
import subprocess
from pathlib import Path
+from ci.jobs.scripts.bugfix_validation import BUGFIX_BUILD_TYPES, find_master... | [
"ci/jobs/functional_tests.py"
] | [
{
"comment": "this job stage checks crashes which are, in context of bugfix validation, \"success\" case (bug reproduced), the stage supposed to be executed for every build for job to work correctly\n",
"path": "ci/jobs/functional_tests.py",
"hunk": "",
"resolving_sha": "75f70593f94f80f92b7be4250fa0... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.