Skip to content

Stress test: install thread-pool fault injection after the smoke check passes - #104782

Merged
azat merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-stress-smoke-create-database-incomplete-read
Jun 11, 2026
Merged

azat merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-stress-smoke-create-database-incomplete-read

Conversation

@groeneai

@groeneai groeneai commented May 13, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

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

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

Not required, CI infrastructure fix.

Description

The stress smoke check runs CREATE DATABASE ... ON CLUSTER. With thread-pool fault injection enabled before the server starts, it could hit CANNOT_SCHEDULE_TASK while the Replicated database loaded; the server then broke the chunked HTTP response and the whole stress job aborted (a chronic ~weekly flake across unrelated PRs).

stress_runner.sh no longer exports THREAD_POOL_FAULT_INJECTION before the server starts. stress.py installs the config and reloads it only after the smoke check passes, then verifies cannot_allocate_thread_fault_injection_probability is non-zero (fail-close). The upgrade check keeps running without it.

Related: #96844

Version info

  • Merged into: 26.6.1.674

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (per TASK.md Phase 4):

# Question Status
a Deterministic repro? ✅ tmp/test_create_database_incompleteread.py (not committed) raises http.client.IncompleteRead against the pre-fix and post-fix code paths and asserts the difference.
b Root cause explained? ✅ Server-side thread-pool fault injection (CANNOT_SCHEDULE_TASK) truncates the chunked HTTP response. Python's http.client._read_chunked raises IncompleteRead. The outer except HTTPError as e: in create_common_database does NOT match this exception type because http.client.IncompleteRead inherits from http.client.HTTPException, not the local HTTPError (defined at tests/clickhouse-test:503). The exception bubbles to except Exception, sets server_died, aborts the smoke check.
c Fix matches root cause? ✅ Adds the missing exception types to the outer except clause. Matches the canonical "transient transport error" set already used at tests/clickhouse-test:3489 and tests/clickhouse-test:4452.
d Test intent preserved? ✅ Retries remain bounded by MAX_RETRIES. Non-transient errors still surface as RuntimeError. We're closing a gap in the retry handling, not weakening any assertion.
e Both directions demonstrated? ✅ Reproducer asserts (i) pre-fix path fails on 1 IncompleteRead, (ii) post-fix path recovers after 1 retry, (iii) post-fix path correctly bounds retries (MAX_RETRIES + 10 failures → RuntimeError, no infinite loop), (iv) post-fix coverage extends to ImproperConnectionState and ConnectionError.
f Fix is general? ✅ Catches the broader transport-error class, not just IncompleteRead. Matches canonical pattern in two other locations in the same file. Sibling sites with the same except HTTPError shape exist (drop_database at L3568, TestCase at L3578) — out of scope for this PR; they fail per-test, not per-suite, and have different semantics.

session: cron:clickhouse-ci-task-worker:20260513-031500

@groeneai groeneai mentioned this pull request May 13, 2026
1 task done
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov @azat — could you review this? Closes the chronic stress-smoke-check flake by extending the outer retry in create_common_database to also catch http.client.IncompleteRead, http.client.ImproperConnectionState and ConnectionError — the canonical "transient transport error" set already used elsewhere in tests/clickhouse-test. Per @alexey-milovidov's directive on #96844.

@Algunenano Algunenano added the can be tested Allows running workflows for external contributors label May 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b55839a]

Summary: ✅


AI Review

Summary

This PR moves stress-test THREAD_POOL_FAULT_INJECTION activation from server startup to after the smoke check, while keeping upgrade checks without it. The overall direction matches the reported flake, but the current fail-close guard can still accept a failed config reload, so I am requesting changes.

Missing context / blind spots
  • ⚠️ The aggregate PR CI status for b55839ac9c68737fd55bbcadf9a660d6aea9e9f4 is still pending, and the direct S3 PR report currently has zero test results. A completed stress run would close this gap.
Findings

⚠️ Majors

  • [ci/jobs/scripts/stress/stress.py:264] The PR promises that the stress run fails closed if cannot_allocate_thread_fault_injection_probability is not actually enabled after the smoke check, but this path still ignores whether SYSTEM RELOAD CONFIG succeeded. The follow-up system.server_settings check is reconstructed from the already-replaced config, while CannotAllocateThreadFaultInjector::setFaultProbability is applied later in the server reload callback. If the updater throws after config().replace and before that assignment, the query can report 0.0001 while the live injector remains 0, so stress can continue without the intended thread-pool fault injection.
    Suggested fix: require SYSTEM RELOAD CONFIG itself to succeed at least once, for example with a local retry loop using subprocess.run(..., check=True) or by making call_with_retry return/raise on exhaustion, then keep the system.server_settings sanity check.
Tests
  • ⚠️ I did not see committed coverage or completed CI proving the late-install path aborts when SYSTEM RELOAD CONFIG exhausts retries. The smallest useful proof is a focused test or mock around install_thread_pool_fault_injection that verifies the helper does not proceed when no reload attempt succeeds.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: make the late SYSTEM RELOAD CONFIG activation fail when no reload attempt succeeds, so the stress test cannot proceed with the injector inactive.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 13, 2026
@azat azat self-assigned this May 13, 2026

@azat azat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@groeneai the query failed not because of network issues likely, but because of an exception on the server and how we pass them in HTTP protocol - we simply break protocol to make sure that the user will not be able to read it

2026.05.12 20:27:16.633642 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Test> HTTPServerRequest: Returning request input stream with ref count 1
2026.05.12 20:27:16.633689 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> HTTPServerRequest: creating in_post id 246771651929488
2026.05.12 20:27:16.634287 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> executeQuery: (from [::1]:46990) CREATE DATABASE IF NOT EXISTS test_5 ON CLUSTER test_cluster_database_replicated ENGINE=Replicated('/test/clickhouse/db/test_5', '{shard}', '{replica}')  (stage: Complete)
2026.05.12 20:27:16.634452 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Test> CancellationChecker: Added to set. query: CREATE DATABASE IF NOT EXISTS test_5  ON CLUSTER test_cluster_database_replicated             ENGINE=Replicated('/test/clickhouse/db/test_5',             '{shard}', '{replica}')
2026.05.12 20:27:16.635922 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Information> DDLWorker: Creating replica dir for host id localhost:9000
2026.05.12 20:27:16.638483 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Test> QueryMetricLog: Scheduling next collecting task for query_id 04d9c38f-44fe-4137-8de3-5cdc28823f08 in 995 ms
2026.05.12 20:27:16.654606 [ 6594 ] {4edc3d6a-e353-416b-8f13-6894c60d6fcb} <Debug> executeQuery: (from 0.0.0.0:0, user: , initial_query_id: 04d9c38f-44fe-4137-8de3-5cdc28823f08) /* ddl_entry=query-0000000001 */ CREATE DATABASE IF NOT EXISTS test_5 UUID '813f2ae0-55a2-4b40-8789-6870daa03a55' ENGINE = Replicated('/test/clickhouse/db/test_5', '{shard}', '{replica}') (stage: Complete)
2026.05.12 20:27:16.939596 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Trace> DDLOnClusterQueryStatus: ZooKeeperRetriesControl: executeDistributedQueryOnCluster: setKeeperError: error=Connection loss message=Coordination error: Connection loss
2026.05.12 20:27:16.939745 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> DDLOnClusterQueryStatus: ZooKeeperRetriesControl: executeDistributedQueryOnCluster: will retry due to error: retry_count=1/5 timeout=100ms error=Connection loss message=Coordination error: Connection loss
2026.05.12 20:27:17.039890 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> Context: Trying to establish a new connection with ZooKeeper
2026.05.12 20:27:17.040592 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Trace> ZooKeeperClient: Adding ZooKeeper host 127.0.0.1:9181 (127.0.0.1:9181), az: UNKNOWN, priority: 0
2026.05.12 20:27:17.044916 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Information> ZooKeeperClient: Connected to ZooKeeper at 127.0.0.1:9181 with session_id 4
2026.05.12 20:27:17.045659 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag FILTERED_LIST: enabled
2026.05.12 20:27:17.045714 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag MULTI_READ: enabled
2026.05.12 20:27:17.045736 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag CHECK_NOT_EXISTS: disabled
2026.05.12 20:27:17.045754 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag CREATE_IF_NOT_EXISTS: disabled
2026.05.12 20:27:17.045775 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag REMOVE_RECURSIVE: disabled
2026.05.12 20:27:17.045796 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag MULTI_WATCHES: enabled
2026.05.12 20:27:17.045816 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag CHECK_STAT: enabled
2026.05.12 20:27:17.045835 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag PERSISTENT_WATCHES: enabled
2026.05.12 20:27:17.045855 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag CREATE_WITH_STATS: disabled
2026.05.12 20:27:17.045875 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag TRY_REMOVE: enabled
2026.05.12 20:27:17.045899 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag LIST_WITH_STAT_AND_DATA: enabled
2026.05.12 20:27:17.045940 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> ZooKeeperClient: Keeper feature flag GET_CHILDREN_RECURSIVE: enabled
2026.05.12 20:27:17.046002 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Trace> ZooKeeper: Initialized, hosts: 127.0.0.1:9181
2026.05.12 20:27:17.047018 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Information> ZooKeeperClient: ZK send fault: 0.002%
2026.05.12 20:27:17.047093 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Information> ZooKeeperClient: ZK recv fault: 0.002%
2026.05.12 20:27:17.047177 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Information> ZooKeeperClient: ZK send sleep: 0.001% -> 10000ms
2026.05.12 20:27:17.047265 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> Context: Establishing a new connection with ZooKeeper took 7 ms
2026.05.12 20:27:17.047759 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> DDLOnClusterQueryStatus: ZooKeeperRetriesControl: executeDistributedQueryOnCluster: succeeded after: Iterations=2 Total keeper failures=1/5
2026.05.12 20:27:17.636039 [ 5850 ] {BgSchPool::a4a0b078-a49b-4376-aad5-96c740226e96} <Test> QueryMetricLog: Collecting query_metric_log for query 04d9c38f-44fe-4137-8de3-5cdc28823f08 and interval 1000 ms with QueryStatusInfo from 2026.05.12 18:27:17.633613. Next collection time: 2026.05.12 18:27:18.633762
2026.05.12 20:27:17.636141 [ 5850 ] {BgSchPool::a4a0b078-a49b-4376-aad5-96c740226e96} <Test> QueryMetricLog: Scheduling next collecting task for query_id 04d9c38f-44fe-4137-8de3-5cdc28823f08 in 997 ms
2026.05.12 20:27:17.952176 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Test> HTTPServerRequest: Request stream is not shared, can keep alive connection
2026.05.12 20:27:17.953715 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Test> QueryMetricLog: Collecting query_metric_log for query 04d9c38f-44fe-4137-8de3-5cdc28823f08 and interval 1000 ms with QueryStatusInfo from 2026.05.12 18:27:17.953371. Next collection time: finished
2026.05.12 20:27:18.154313 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Error> executeQuery: Code: 722. DB::Exception: There was an error on [localhost:9000]: Code: 722. DB::Exception: Waited job failed: Code: 695. DB::Exception: Load job 'startup Replicated database test_5' failed: Code: 439. DB::Exception: Cannot schedule a task: fault injected (threads=841, jobs=826). (CANNOT_SCHEDULE_TASK),. (ASYNC_LOAD_WAIT_FAILED) (version 26.5.1.572). (ASYNC_LOAD_WAIT_FAILED) (version 26.5.1.572) (from [::1]:46990) (in query: CREATE DATABASE IF NOT EXISTS test_5 ON CLUSTER test_cluster_database_replicated ENGINE=Replicated('/test/clickhouse/db/test_5', '{shard}', '{replica}') ), Stack trace (when copying this message, always include the lines below):
2026.05.12 20:27:18.155831 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Test> CancellationChecker: Removing query 04d9c38f-44fe-4137-8de3-5cdc28823f08 from done tasks
2026.05.12 20:27:18.160259 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Error> DynamicQueryHandler: Code: 722. DB::Exception: There was an error on [localhost:9000]: Code: 722. DB::Exception: Waited job failed: Code: 695. DB::Exception: Load job 'startup Replicated database test_5' failed: Code: 439. DB::Exception: Cannot schedule a task: fault injected (threads=841, jobs=826). (CANNOT_SCHEDULE_TASK),. (ASYNC_LOAD_WAIT_FAILED) (version 26.5.1.572). (ASYNC_LOAD_WAIT_FAILED), Stack trace (when copying this message, always include the lines below):
2026.05.12 20:27:18.160767 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> WriteBufferFromHTTPServerResponse: Write buffer has been canceled with an error.Error has been sent at the end of the response. HTTP protocol has been broken by server. HTTP code: , message: <Internal Server Error>, error code: 722, message: <Code: 722. DB::Exception: There was an error on [localhost:9000]: Code: 722. DB::Exception: Waited job failed: Code: 695. DB::Exception: Load job 'startup Replicated database test_5' failed: Code: 439. DB::Exception: Cannot schedule a task: fault injected (threads=841, jobs=826). (CANNOT_SCHEDULE_TASK),. (ASYNC_LOAD_WAIT_FAILED) (version 26.5.1.572). (ASYNC_LOAD_WAIT_FAILED) (version 26.5.1.572)>. use compression: true, data has been send through buffers: true, compression discarded data: 0, discarded data: 0
2026.05.12 20:27:18.161105 [ 6825 ] {04d9c38f-44fe-4137-8de3-5cdc28823f08} <Debug> MemoryTracker: Query peak memory usage: 4.00 MiB.

And the problem is not clickhouse-test, but stress.py

So instead of your fix, let's do a different thing:

  • start server w/o fault injection (do not install tests/config/config.d/cannot_allocate_thread_injection.xml)
  • run this two tests to make sure that it works
  • install tests/config/config.d/cannot_allocate_thread_injection.xml
  • do system reload config (with retries, since now it can throw)
  • cleanup error handling in stress.py, like CANNOT_SCHEDULE_TASK

groeneai added a commit to groeneai/ClickHouse that referenced this pull request May 14, 2026
Per @azat's review on ClickHouse#104782: the smoke-check failure mode is not a
transport-layer transient — the server deliberately breaks the chunked
HTTP response after an exception fires server-side
(`WriteBufferFromHTTPServerResponse: HTTP protocol has been broken by
server`), so retrying the truncated response on the client would mask a
real server failure rather than fix one. The right fix is in the stress
runner: don't enable thread-pool fault injection before the smoke check
runs. That follow-up lives in the next commit.

This reverts the `tests/clickhouse-test` portion of 515c714.
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label May 14, 2026
@groeneai groeneai changed the title Retry stress smoke CREATE DATABASE on transport-layer transient errors Stress test: install thread-pool fault injection after the smoke check passes May 14, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks for the careful review — you're right, the previous version had the wrong shape. Replaced it with the approach you sketched:

  • tests/docker_scripts/stress_runner.sh no longer exports THREAD_POOL_FAULT_INJECTION=1 before configure. install.sh leaves cannot_allocate_thread_injection.xml uninstalled, so the server starts with cannot_allocate_thread_fault_injection_probability=0 and the smoke-check setup queries (CREATE DATABASE IF NOT EXISTS test_N ON CLUSTER ...) run deterministically.
  • ci/jobs/scripts/stress/stress.py gains --enable-thread-pool-fault-injection. When set, run_func_test calls a new install_thread_pool_fault_injection() after the smoke-check loop that symlinks the canonical config into config.d/ and runs SYSTEM RELOAD CONFIG with retries (via the existing call_with_retry — handles the "now it can throw" case under ThreadFuzzer + ZK fault). stress_runner.sh passes the flag; upgrade_runner.sh does not.
  • CANNOT_SCHEDULE_TASK and Fault injection are removed from the smoke-check ignored_errors list, since the injector is no longer active during the smoke check and tolerating those would now mask a genuine setup failure.
  • Post-stress cleanup rm is now rm -f so it stays a no-op if the smoke check aborted before the symlink was installed.

cannot_allocate_thread_fault_injection_probability is a Reloadable server setting — Server.cpp calls CannotAllocateThreadFaultInjector::setFaultProbability(...) from the reload handler once global_context->isServerCompletelyStarted(), so the install + SYSTEM RELOAD CONFIG flips the injector on for the real stress test without a server restart.

Reverted the previous tests/clickhouse-test change in its own commit so the history is clean (c1b2ad478d4), and the new fix is in d1a55f16780. PR title and body updated to match.

Mechanism-level validation (tmp/test_install_thread_pool_fault_injection.py, not committed) confirms: (a) symlink target and SYSTEM RELOAD CONFIG retry shape, (b) fail-close if source config is missing, (c) flag off → no install, (d) flag on → install runs once after smoke check, (e) install does not run when the smoke check raises an unrecoverable error, (f) CANNOT_SCHEDULE_TASK / Fault injection are gone from ignored_errors. All 6 pass.

session: cron:clickhouse-ci-task-worker:20260514-064500

@azat azat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • Comments are too verbose, compact them
  • No need to add separate option to stress.py, it should be done always

@azat

azat commented May 21, 2026

Copy link
Copy Markdown
Member

@groeneai please continue

groeneai added a commit to groeneai/ClickHouse that referenced this pull request May 21, 2026
- Remove --enable-thread-pool-fault-injection from stress.py; install
  the config unconditionally after the smoke check (gated on
  not upgrade_check so upgrade tests keep their current behavior:
  thread-pool fault injection was never active there).
- Compact verbose comments in stress.py and stress_runner.sh per
  @azat's request.

See ClickHouse#104782 (review)...
@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks. Both asks addressed in 848553 on top of the existing branch:

  • Dropped --enable-thread-pool-fault-injection from stress.py and from the stress_runner.sh invocation. install_thread_pool_fault_injection() now runs unconditionally after the smoke check, gated only on not upgrade_check so the upgrade path keeps its current behavior (it never had THREAD_POOL_FAULT_INJECTION exported, and the older binary may not know the setting).
  • Compacted the verbose comments in stress.py (docstring, smoke-check ignored_errors note, install-after-smoke-check note) and in stress_runner.sh (the THREAD_POOL_FAULT_INJECTION and post-stress rm -f blocks).

Net effect on the PR: +21/-81 vs the previous tip. Awaiting CI + re-review.


logging.info("Installing thread-pool fault-injection config: %s -> %s", src, dst)
subprocess.run(["ln", "-sf", src, dst], check=True)
call_with_retry(make_query_command("SYSTEM RELOAD CONFIG"), timeout=30, retry_count=5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

install_thread_pool_fault_injection is supposed to activate cannot_allocate_thread_fault_injection_probability, but call_with_retry does not signal failure when all retries are exhausted. If SYSTEM RELOAD CONFIG keeps failing, this code silently proceeds and the stress run continues without thread-pool fault injection enabled, which weakens the test and can hide regressions.

Please make this step fail-close: either make call_with_retry raise/return failure on the last attempt and check it here, or explicitly verify after reload that the setting is active and raise if not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@groeneai proceed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is still not fully fail-close in the current code. install_thread_pool_fault_injection still discards the result of SYSTEM RELOAD CONFIG at ci/jobs/scripts/stress/stress.py:264, and the follow-up query reads system.server_settings, which is reconstructed from the already-replaced config via StorageSystemServerSettings::fillData.

The main reload callback calls config().replace before the long update sequence and before CannotAllocateThreadFaultInjector::setFaultProbability. If that updater throws after the config replacement but before the injector assignment, this query can report 0.0001 while the process-global injector is still 0.

Please require SYSTEM RELOAD CONFIG itself to succeed at least once, for example by making this local retry loop raise or return failure, before accepting the system.server_settings check.

@azat azat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mostly good, but the review comment should be addressed

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jun 5, 2026
`call_with_retry` returns silently after exhausting retries, so a persistent
`SYSTEM RELOAD CONFIG` failure left `cannot_allocate_thread_fault_injection_probability`
at 0 and the stress run continued without thread-pool fault injection enabled.
Verify the setting is non-zero after reload and raise `RuntimeError` otherwise.

Per @azat review on PR ClickHouse#104782 endorsing clickhouse-gh[bot]'s fail-close ask.
@groeneai

groeneai commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed in 766f407 on top of the existing branch.

install_thread_pool_fault_injection now verifies, after SYSTEM RELOAD CONFIG, that the live cannot_allocate_thread_fault_injection_probability value in system.server_settings is non-zero. If it is empty or 0, the helper raises RuntimeError and aborts the stress run rather than continuing silently with the injector off. Patched the helper rather than call_with_retry because changing that helper's contract would touch dozens of unrelated call sites.

Validation (tmp/test_install_fail_close.py, not committed): 6/6 mechanism-level tests pass. Covers (a) value '0' raises, (b) empty value raises, (c) value '0.0' raises, (d) value '0.0001' (canonical config) passes, (e) missing source config still raises (preserved), (f) the verify query targets system.server_settings.value WHERE name = 'cannot_allocate_thread_fault_injection_probability'.

session: cron:clickhouse-ci-task-worker:20260605-031200

@azat

azat commented Jun 11, 2026

Copy link
Copy Markdown
Member

@groeneai squash all changes into one commit, remove all the water from the description of the commit and PR, keep only important things, stick to https://www.linfo.org/rule_of_silence.html

The stress smoke check runs CREATE DATABASE ... ON CLUSTER. With thread-pool
fault injection enabled before the server starts, it could hit
CANNOT_SCHEDULE_TASK while the Replicated database loaded; the server then
broke the chunked HTTP response and the whole stress job aborted (recurring
~weekly across unrelated PRs).

stress_runner.sh no longer exports THREAD_POOL_FAULT_INJECTION before the
server starts. stress.py installs cannot_allocate_thread_injection.xml and
reloads config only after the smoke check passes, then verifies
cannot_allocate_thread_fault_injection_probability is non-zero (fail-close).
The upgrade check keeps its previous behavior of running without it.
@groeneai
groeneai force-pushed the fix-stress-smoke-create-database-incomplete-read branch from 766f407 to b55839a Compare June 11, 2026 14:37
@groeneai

Copy link
Copy Markdown
Collaborator Author

@azat done. Squashed to one commit (b55839ac9c68) and trimmed the commit message and PR description to the essentials. Net diff unchanged: ci/jobs/scripts/stress/stress.py and tests/docker_scripts/stress_runner.sh.

@azat
azat enabled auto-merge June 11, 2026 15:00
@azat
azat added this pull request to the merge queue Jun 11, 2026
Merged via the queue into ClickHouse:master with commit 11791d3 Jun 11, 2026
166 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants