Skip to content

Do not run the inserts of test 05239_written_rows_quota_interval_rollover asynchronously - #124935

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-05239-quota-rollover-sync-inserts
Oct 10, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-05239-quota-rollover-sync-inserts

Conversation

@groeneai

@groeneai groeneai commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #118272

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

Make the inserts of test 05239_written_rows_quota_interval_rollover synchronous, so it does not miss its quota intervals in the AsyncInsert CI lane.

Description

Failing jobs (identical diff: the first reference line is missing): #123849, #123041, both Stateless tests (arm_binary, AsyncInsert, s3 storage, parallel).

In the AsyncInsert lane the test's inserts go through the async insert queue, and an async insert is accounted to the quota when its batch is flushed. The flush waits for the queue shard's adaptive busy timeout, which the other tests of a parallel run keep near its 5000 ms cap (timeouts.xml). In the failing job every insert took 4.2-5 s, so the second insert of each attempt was accounted in [END+10, END+15) instead of [END+5, END+10) and all 10 attempts missed. The runner's reruns passed later on an idle shard.

The three inserts now use SETTINGS async_insert = 0 (as in b6bd3c8 for 05321). Quota accounting goes through the same CountingTransform call on both paths, so the test still covers the rollover defect it was written for.

Validation: with async_insert=1, async_insert_use_adaptive_busy_timeout=0, async_insert_busy_timeout_max_ms=4500 the old test fails with the CI diff (21 inserts of ~4.5 s, each with an AsyncInsertFlush in system.query_log) and the new one passes; removing either loop pin brings the failure back. 50/50 randomized runs pass, with and without async_insert=1.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.2029-master (included in 26.10 and later)

In the AsyncInsert CI lane the test's inserts went through the async insert
queue, and an async insert is accounted to the quota when its batch is
flushed. The flush waits for the queue shard's adaptive busy timeout, which
the other tests of a parallel run keep close to its 5000 ms cap
(`async_insert_busy_timeout_ms` in tests/config/users.d/timeouts.xml). Every
insert then took 4.2-5 s, so the second insert of each attempt was accounted
in [END+10, END+15) instead of [END+5, END+10), and all 10 attempts missed
the intervals the scenario needs.

Pin `async_insert = 0` on the three inserts, so each one is accounted while
it runs. Quota accounting is done by the same CountingTransform call on the
synchronous and the asynchronous path, so the test still covers the interval
rollover defect it was written for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Oct 9, 2026
@groeneai

groeneai commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings), plus my own cold review of the diff (0 findings).

# Sev Finding Verdict Evidence / action
- - No findings - -

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261009-142900

@groeneai

groeneai commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. async_insert=1, async_insert_use_adaptive_busy_timeout=0, async_insert_busy_timeout_max_ms=4500 makes every insert wait 4.5 s; the old test then fails with the CI diff (161 s, all 10 attempts missed).
b Root cause explained? An async insert is accounted to the quota when its batch is flushed; under a hot queue shard that is 4.2-5 s late, so the second insert is always accounted one 5 s interval too late.
c Fix matches root cause? Yes. The three inserts are synchronous, so each is accounted while it runs; no bound, retry count or tag changed.
d Test intent preserved / new tests added? Yes. The covered defect is in the quota's batch accounting, reached through the same CountingTransform call on both paths; reference unchanged; the test still runs in the AsyncInsert lane.
e Both directions demonstrated? Yes. Old test FAIL, new test OK with the same command; removing either loop pin fails again.
f Fix is general across code paths? N/A (test-only). 05320 has no INSERT; other quota tests with inserts have no wall-clock interval oracle.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). 50/50 randomized runs pass, with and without async_insert=1.
h Backward compatible? (maintainer-approved exception only) N/A (test-only, no setting or format change).
i Invariants and contracts preserved? N/A (no source change); every insert of the test is now accounted at the time it runs.

Session id: cron:clickhouse-impl-slot-6:20261009-140400

@clickhouse-gh

clickhouse-gh Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [35eec7f]

Summary: ✅


AI Review

Summary

This PR makes the three INSERT statements in tests/queries/0_stateless/05239_written_rows_quota_interval_rollover.sh explicitly synchronous so the test keeps exercising the quota-interval rollover invariant instead of the async-insert queue's busy-timeout behavior in the AsyncInsert CI lane. I found no correctness or coverage regression in the change: the test still goes through the same CountingTransform-based written_rows / written_bytes accounting path that the quota bug lives on, and the current Praktika report for the PR is green.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 9, 2026
@Algunenano Algunenano self-assigned this Oct 9, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 625c8f4

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / 05210_lightweight_update_materialized_cte_in_ignore flaky, not from this PR, which only changes 05239: Code: 60 ... Unknown table expression identifier '_materialized_cte_c_...' when a reused MATERIALIZED CTE is read through parallel replicas with a local plan. 45 PRs and 2 master runs show it since 2026-10-08 #123121 (mine, open)
Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2) / 05316_secret_arguments_declared_by_engines not from this PR: the test came with #123364, and under DatabaseReplicated its last query_log check counts the CREATE DICTIONARY row twice (0 2 instead of 0 1; the password stays hidden) #124928 (external, merged 17:58Z). The tested merge commit 458e462e8b78 predates that merge, so I will merge master here to pick it up
Mergeable Check, PR praktika rollups of the two rows above #123121 (mine, open), #124928 (external, merged)
Sync - CH Inc sync (private, not actionable by me)

Session id: cron:our-pr-ci-monitor:20261010-020010

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 comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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