Skip to content

Return retryable HTTP 503 on remote-write async insert flush timeout - #117632

Merged
vitlibar merged 1 commit into
ClickHouse:masterfrom
vitlibar:timeseries-remote-write-timeout-503
Sep 3, 2026
Merged

vitlibar merged 1 commit into
ClickHouse:masterfrom
vitlibar:timeseries-remote-write-timeout-503

Conversation

@vitlibar

@vitlibar vitlibar commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

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 into CHANGELOG.md):

Return retryable 503 Service Unavailable on remote-write async insert flush timeout.

Earlier it returned HTTP 408 Request Timeout, which was bad because Prometheus Remote Write compatible senders retry write requests only on HTTP 5xx responses (and sometimes HTTP 429) (docs) so HTTP 408 was not retryable


Workflow [PR]
Sync PR [sync-upstream/pr/117632]

Version info

  • Merged into: 26.9.1.588 (included in 26.9 and later)

@clickhouse-gh

clickhouse-gh Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0036062]

Summary: ✅


AI Review

Summary

The code change itself looks correct: it introduces a dedicated ASYNC_INSERT_FLUSH_TIMEOUT error for Prometheus remote write, maps that error to HTTP 503 Service Unavailable, and adds an integration test that proves the request times out while the async insert is still flushed later. I did not find a correctness issue in the implementation, but the PR metadata should be adjusted because this path is still explicitly experimental.

PR Metadata

Changelog category is not correct. Bug Fix is reserved for user-visible misbehavior in an official stable release, while the affected TimeSeries / Prometheus remote-write surface is still documented as experimental. Use this exact replacement instead:

### Changelog category (leave one):
- Experimental Feature

Changelog entry is required for Experimental Feature. The current first paragraph is specific enough, but note that the second paragraph is ignored by the changelog script because the blank line ends collection. If you want the retry behavior to appear in the published changelog, replace the entry with:

Prometheus remote write now returns retryable `503 Service Unavailable` when an async insert flush times out, so compatible senders retry the write instead of dropping it.
Final Verdict

Code looks good. I would merge after fixing the changelog category, and optionally folding the retry rationale into the first changelog-entry paragraph.

LLVM Coverage Report

Measured on commit 0036062.

Metric Baseline Current Δ
Lines 88.60% 88.60% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 80.90% 81.00% +0.10%

Changed lines: Changed C/C++ lines covered: 14/15 (93.33%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 2, 2026
@vitlibar vitlibar added the comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... label Sep 2, 2026
@vitlibar
vitlibar force-pushed the timeseries-remote-write-timeout-503 branch from 54f360e to 0036062 Compare September 2, 2026 08:20
@clickhouse-gh

clickhouse-gh Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 003606261 with master f17bffbc7 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

9 translation units recompiled, 13 s compile time in total, 8 of them have a recent master baseline.

Job report

@vitlibar

vitlibar commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

@groeneai Investigate CI failures and suggest fixes

@groeneai

groeneai commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

CI on 003606261

Two failures, both pre-existing on master and independent of this diff (a new error code, its HTTP mapping and one integration test cannot reach either code path). Performance Comparison is not a failure: the summary bullet is just the dashboard link, all six arm_release shards passed and amd_release was skipped. Both Bugfix validation (integration tests, *) arms are green in the right direction: test_async_insert_flush_timeout_returns_503 failed on master HEAD there, so the new test does pin the bug.

Check Failure Attribution Owner / suggested fix
Stress test (amd_debug) logical error Not-ready Set is passed as the second argument for function 'globalNotIn' (STID 0250-4e52) pre-existing, 218 unrelated pull requests in 30d fixing PR #112968 (open)
Stateless tests (amd_debug, parallel) 04865_cancel_mutation_in_subquery_minmax_projection transient, global thread pool saturation re-run; optional hardening below (my test)

Not-ready Set (report). That STID pools several distinct mechanisms, so I read the chain in this job's own fatal log rather than trusting the name: Functions/in.cpp:128 -> VirtualColumnUtils.cpp:163 filterBlockWithExpression -> :419 getFilterByPathAndFileIndexes -> VirtualColumnUtils.h:136 filterByPathOrFile -> StorageObjectStorageSource.cpp:581 createFileIterator -> ReadFromObjectStorageStep.cpp:179 createIterator, reached from executeASTFuzzerQueries. So object-storage _path pruning ran at pipeline-build time against a globalNotIn set that ReadFromObjectStorageStep::applyFilters deliberately leaves unbuilt. That is exactly the route @ alexey-milovidov's #112968 fixes: it quotes the same assert and adds 04669_object_storage_path_filter_global_in. Open since 2026-08-02, labelled blocker.

Breadth over 30 days: 275 failure rows for the STID across 218 distinct pull requests and 12 true-master runs; 165 of those rows carry the VirtualColumnUtils frames above, 80 of them on globalNotIn. On Stress test (amd_debug) alone it hit 45 of 4450 trees in 14 days, so a re-run clears it in roughly 99 cases out of 100. Nothing to do on your side; it will keep appearing until #112968 lands.

04865 (report). No assertion of the test failed: stdout matched the reference in full (1, 0, 15 120, 7, 1) and the recorded reason is having stderror. The stderr came from the bounded wait loop at line 85, whose SYSTEM FLUSH LOGS part_log; SELECT countIf(errorCodeToName(error) = 'ABORTED') > 0 FROM system.part_log ... threw Code: 439. Cannot schedule a task: no free thread (timeout=60000000) (threads=3, jobs=3). (CANNOT_SCHEDULE_TASK) on one attempt. The loop compares stdout only, so it retried and succeeded, which is why the output is complete.

Mechanism: that run drew --max_threads 3, so MergeTreeDataSelectExecutor::filterPartsByPrimaryKeyAndSkipIndexes took the parallel branch and built a 3-thread pool for index analysis over system.part_log. That pool borrows threads from the global pool and uses scheduleOrThrow on purpose, to avoid blocking forever when the global pool is saturated (the comment at MergeTreeDataSelectExecutor.cpp:1277), with the wait bounded by lock_acquire_timeout, which CI pins to 60 s in tests/config/users.d/limits.yaml:53. The global pool stayed full for those 60 s. Nothing about a remote-write error code can influence that.

Rate: 5328 OK and this single FAIL on that job in 14 days, this exact thread pool signature appears once fleet-wide in 7 days, and the runner's own randomized-settings diagnosis re-ran the test 10 times with the same settings for 10 passes. A re-run is enough.

The test is mine (it came with #114463), so the suggested fix is on me. Its three wait loops (lines 48, 63, 85) each already fail loudly with their own message on timeout, so a per-attempt server error has no reason to reach stderr; redirecting stderr inside those loops removes this whole class. The narrower alternative is SETTINGS max_threads = 1 on the system.part_log probe, which takes the serial branch at MergeTreeDataSelectExecutor.cpp:1263 and never borrows from the global pool. At one occurrence in 7 days I am not raising it as work of its own, but say the word and I will send it.

@clickhouse-gh

clickhouse-gh Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 40 queries analysed

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: b8b71b46-a4e4-4537-a453-9c4257031034
  • MIRAI run: 6836f938-efbc-42f9-b1f0-847277c82beb
  • PR check IDs:
    • clickbench_891485_1788360210
    • clickbench_891491_1788360210
    • clickbench_891703_1788360223
    • tpch_adapted_1_official_891765_1788360226
    • tpch_adapted_1_official_891918_1788360245
    • tpch_adapted_1_official_892097_1788360334

@clickhouse-gh

clickhouse-gh Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

PromQL Compliance Report

Baseline: S3 master f17bffbc7

Metric Baseline Current Δ
Score 77.74% 77.74% +0.00%
Passed 419 419 +0
Failed 3 3 +0
Unsupported 117 117 +0

Note: score is unchanged vs baseline.

Uploaded compliance JSON for this PR commit

@vitlibar
vitlibar added this pull request to the merge queue Sep 3, 2026
Merged via the queue into ClickHouse:master with commit a748a45 Sep 3, 2026
342 of 344 checks passed
@vitlibar
vitlibar deleted the timeseries-remote-write-timeout-503 branch September 3, 2026 11:18
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants