Skip to content

Retry functional tests on server (total) memory limit exceeded - #110503

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/ci-retry-total-memory-oom
Jul 15, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/ci-retry-total-memory-oom

Conversation

@groeneai

@groeneai groeneai commented Jul 15, 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):

...

Description

Retry a functional test that fails purely because the server-global (total) memory tracker fired under heavy parallel co-scheduling.

On the ASan functional shards, many tests run concurrently against one shared server. When co-scheduled queries push total RSS toward the shared server cap, the OvercommitTracker kills queries across all co-scheduled tests with Code: 241 ... (total) memory limit exceeded ... OvercommitTracker decision. This is a co-scheduling artifact, not a fault of the individual test, so it should be retried like the other transient heavy-load errors already in MESSAGES_TO_RETRY.

Observed on 2026-07-15 01:00-04:45 UTC: the Stateless tests (amd_asan_ubsan, distributed plan, parallel) job reddened on master and 15+ PRs with ~40 unrelated trivial tests per run failing with Code 241, all in a short window (7-day baseline for this lane is 2-10 Code-241 fails/day; the burst was ~1959, then self-resolved). Sample: (total) memory limit exceeded: would use 5.03 GiB ..., current RSS: 39.37 GiB, maximum: 41.84 GiB. OvercommitTracker decision.

The (total) prefix is set only by the server-global tracker (programs/server/Server.cpp, total_memory_tracker.setDescription("(total)")). Per-query and per-user memory-limit exceptions say Query/User, never (total), so tests that legitimately assert a per-query/per-user limit are not affected and no test asserts the (total) string. This is the zero-throughput-cost complement to #107441 (which lowered concurrency on the azure ASan shard): it absorbs residual transient total-memory OOM on any ASan shard without reducing concurrency on healthy runs.

Version info

  • Merged into: 26.7.1.993 (included in 26.7 and later)

The server-global (total) memory tracker can fire under heavy parallel
co-scheduling on ASan shards: the OvercommitTracker kills queries across
all co-scheduled tests once total RSS nears the shared server cap. This is
a co-scheduling artifact, not a per-test fault, so retry it like the other
transient heavy-load errors in MESSAGES_TO_RETRY. The (total) prefix is
emitted only by the server-global tracker, so per-query/per-user limit
tests are unaffected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The exact CIDB failure string (total) memory limit exceeded ... OvercommitTracker decision now deterministically matches need_retry(); a per-query/per-user ... memory limit exceeded does not. Demonstrated in a unit-style harness driving the runner's MESSAGES_TO_RETRY (total-OOM -> retry True; per-query/per-user -> retry False).
b Root cause explained? On ASan shards many tests share one server. Co-scheduled queries (~19 at 0.6 concurrency) push server total RSS to 39.37/41.84 GiB; the server-global (total) tracker's OvercommitTracker kills queries across all co-scheduled tests with Code 241. This is a co-scheduling artifact, not a per-test fault, so it must be retried like the other transient heavy-load errors.
c Fix matches root cause? Yes. Adds "(total) memory limit exceeded" to MESSAGES_TO_RETRY, targeting exactly the server-global co-scheduling OOM. Zero-throughput-cost complement to #107441 (which cut concurrency on the azure ASan shard).
d Test intent preserved? Yes. The retry only fires on the (total) server-global message. Per-query/per-user memory-limit tests emit Query/User, never (total), so their assertions are untouched; no test asserts the (total) string.
e Demonstrated both directions? Yes. total-OOM -> retry (True); per-query and per-user memory-limit -> no retry (False).
f Fix is general, not a narrow patch? N/A (CI test-runner change, not a code bug). The single retry entry covers every ASan shard hitting the same server-global OOM, not just the one lane observed.
g Generalizes across inputs? N/A (CI test-runner change, not a code bug).
h Backward compatible? N/A (CI test-runner change, no user-facing behavior, no settings/format).
i Invariants and contracts preserved? Yes. (total) is emitted only by the server-global tracker (programs/server/Server.cpp, total_memory_tracker.setDescription("(total)")), so retrying on it cannot mask a real per-query assertion; MAX_RETRIES and --dont_retry_failures still bound the retry loop.

Session id: cron:clickhouse-worker-slot-2:20260715-054600

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv @leshikus — could you review this? It adds the server-global (total) memory limit exceeded (OvercommitTracker) message to MESSAGES_TO_RETRY so functional tests that fail purely from co-scheduling total-RSS pressure on ASan shards get retried, instead of reddening dozens of unrelated tests. Complements #107441; the (total) prefix is emitted only by the server-global tracker, so per-query/per-user memory-limit tests are unaffected.

@leshikus leshikus left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks ok; the only problem I see if the test is badly written and requires too much memory - this will cause a lot of retries. But we should fix the test in this case, shouldn't we.

@leshikus leshikus added can be tested Allows running workflows for external contributors and removed can be tested Allows running workflows for external contributors labels Jul 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [56ea866]

Summary: ✅


AI Review

Summary

This PR retries functional-test failures whose output contains (total) memory limit exceeded to absorb transient shared-server OOMs on ASan shards. The implementation is broader than that contract: it also matches clickhouse-local's own global-memory exceptions, so it can hide real functional regressions rather than only retrying shared-server co-scheduling artifacts. Verdict: request changes.

Findings

⚠️ Majors

  • [tests/clickhouse-test:128] The bare (total) memory limit exceeded token is not specific to the shared clickhouse-server failure mode described in the PR. clickhouse-local also emits (total) for max_server_memory_usage failures (programs/local/LocalServer.cpp:1359), and functional tests already exercise that path (tests/queries/0_stateless/04117_max_threads_min_free_memory_per_thread.sh:10-21, tests/queries/0_stateless/03196_local_memory_limit.sh:7). Because need_retry is a plain substring match, a real clickhouse-local product regression can now be retried as infrastructure noise. Suggested fix: narrow the retry to the server-specific form that includes the OvercommitTracker decision suffix (programs/server/Server.cpp:2569-2570, src/Common/MemoryTracker.cpp:460-473), or otherwise add context that excludes clickhouse-local global-memory failures.
Final Verdict
  • Status: ⚠️ Request changes

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 15, 2026
@leshikus leshikus added the can be tested Allows running workflows for external contributors label Jul 15, 2026
Comment thread tests/clickhouse-test
# tests once total RSS nears the shared server cap. Emitted only by the global
# tracker (programs/server/Server.cpp: setDescription("(total)")), never by a
# per-query/per-user limit, so retrying cannot mask a real per-query assertion.
"(total) memory limit exceeded",

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.

(total) is not unique to the shared clickhouse-server failure mode described in the PR. clickhouse-local also sets the global tracker description to "(total)" in programs/local/LocalServer.cpp:1359, and we already have functional tests that run clickhouse-local under --max_server_memory_usage (for example tests/queries/0_stateless/04117_max_threads_min_free_memory_per_thread.sh:10-21 and tests/queries/0_stateless/03196_local_memory_limit.sh:7).

Because need_retry is just a substring match, a real clickhouse-local regression that hits its own global memory cap will now be retried as CI noise. The server-only part of the ASan incident is the OvercommitTracker decision suffix: clickhouse-server wires total_memory_tracker.setOvercommitTracker(...) in programs/server/Server.cpp:2569-2570, clickhouse-local does not, and MemoryTracker only appends that suffix when an overcommit tracker actually fired (src/Common/MemoryTracker.cpp:460-473). Please narrow the retry token to the server-specific form instead of the bare (total) memory limit exceeded.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 56ea866

Every failure below has an owner: a fixing PR, or a full-effort fix task. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
CH Inc sync — CH Inc sync (private, not actionable)

All other jobs passed (70 pass, 104 skipped). Approved by @leshikus.

Session id: cron:our-pr-ci-monitor:20260715-103000

@alexey-milovidov alexey-milovidov self-assigned this Jul 15, 2026
@alexey-milovidov
alexey-milovidov merged commit bb9c5e5 into ClickHouse:master Jul 15, 2026
345 of 347 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 15, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jul 16, 2026
Pick up ClickHouse#110503 (retry functional tests on server total memory limit exceeded)
so the amd_asan_ubsan distributed-plan lane no longer reds on the 2026-07-15
fleet-wide Code-241 OOM.
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jul 27, 2026
Pick up the fleet-wide stateless-test host OOM mitigations (ClickHouse#110503, ClickHouse#110574)
so CI on this branch produces real signal.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…total-memory-oom

Retry functional tests on server (total) memory limit exceeded
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Pick up ClickHouse#110503 (retry functional tests on server total memory limit exceeded)
so the amd_asan_ubsan distributed-plan lane no longer reds on the 2026-07-15
fleet-wide Code-241 OOM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-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