Skip to content

Add test: StorageEmbeddedRocksDB::optimize PARTITION/FINAL/DEDUPLICATE/CLEANUP rejection branches untested - #104204

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr101108
May 6, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr101108

Conversation

@clickgapai

@clickgapai clickgapai commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path(s), found during automated review of PR #101108.
That PR PR fixes a race in StorageSystemRocksDB::fillData: when querying system.rocksdb, a concurrent DROP TABLE could leave the EmbeddedRocksDB instance shut down between the table-listing pass and the getRocksDBStatistics call, which then returned nullptr and hit a LOGICAL_ERROR throw. The f

1. StorageEmbeddedRocksDB::optimize PARTITION/FINAL/DEDUPLICATE/CLEANUP rejection branches untested
src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp:429, src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp:432
Risk: Call chain: parser builds ASTOptimizeQuery with partition/final/deduplicate/cleanup flags → InterpreterOptimizeQuery::execute → StorageEmbeddedRocksDB::optimize(query, metadata, partition **What's unique vs PR tests:** PR's own test 04094_rocksdb_system_table_race.shonly issues plainOPTIMIZE TABLE ... rocksdb_race(no modifiers), so it exercises only the success path throughCompactRangeplus the race-only
Tags: -- Tags: no-fasttest, use-rocksdb — no-fasttest: EmbeddedRocksDB engine is not built in the fasttest profile (consistent with all existing rocksdb tests, e.g., 02811_invalid_embedded_rocksdb_create.sql, 02892_rocksdb_trivial_count.sql).; use-rocksdb: Test creates an EmbeddedRocksDB table; the standard tag for rocksdb-dependent tests (matches 01504_rocksdb, 01686_rocksdb, 02910_rocksdb_optimize, 02956_rocksdb_*).
Try it on ClickHouse Fiddle

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.346

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

clickhouse-gh Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4e0497e]

Summary: ✅


AI Review

Summary

This PR adds a new stateless RocksDB test that verifies OPTIMIZE with unsupported modifiers (PARTITION, FINAL, DEDUPLICATE, CLEANUP) is rejected for EmbeddedRocksDB, while plain OPTIMIZE still succeeds. I did not find correctness, safety, or test-quality issues in the added coverage.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label May 6, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, check why "Code review" has failed. Likely, we need to add retries in some of the GitHub-related commands inside it. Send a PR.

@clickgapai

clickgapai commented May 6, 2026 •

Copy link
Copy Markdown
Contributor Author

This automated ClickGap comment is withdrawn — it surfaced internal tooling detail or was posted incompletely, and isn't actionable as written. Please disregard. (ClickGap's output guard now prevents this.)

1 similar comment
@clickgapai

clickgapai commented May 6, 2026 •

Copy link
Copy Markdown
Contributor Author

This automated ClickGap comment is withdrawn — it surfaced internal tooling detail or was posted incompletely, and isn't actionable as written. Please disregard. (ClickGap's output guard now prevents this.)

@groeneai

groeneai commented May 6, 2026

Copy link
Copy Markdown
Collaborator

@alexey-milovidov — investigated. The "Code Review" failure on this PR was a
transient GitHub authorization error inside the Copilot CLI on the 1st attempt
(job 74589889048,
log at 10:08:14Z):

Authorization error, you may need to run /login (Request ID: F924:13DD23:...)
ERROR: command failed after 1/1 attempt(s), exit code: 1
ERROR: Copilot did not write ./ci/tmp/copilot_review.md
RuntimeError: Copilot did not write ./ci/tmp/copilot_review.md

Copilot had been running for 1m 9s and reading source files — then the GitHub
API auth path inside it briefly failed and the whole job exited. The 3rd
workflow attempt re-ran Code Review at 11:03:54Z and finished cleanly without
any code change, confirming the failure was transient.

Fix PR up at #104227 — wraps the gh-auth + copilot subprocess in a 3-attempt
retry loop with exponential backoff, and adds GH.get_output_with_retries
so all GitHub-API reads in ci/praktika/gh.py (post_*_comment,
get_pr_*, pr_has_conflicts) retry on transient gh failures instead of
silently returning "" and corrupting downstream logic.

Once #104227 lands, this PR's Code Review check should be robust to similar
transient blips. Your underlying coverage gap finding here looks unchanged
either way — the AI review verdict on a clean re-run was "Approve".

@alexey-milovidov alexey-milovidov self-assigned this May 6, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 6, 2026
Merged via the queue into ClickHouse:master with commit c68e7fd May 6, 2026
178 of 326 checks passed
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 6, 2026
pull Bot pushed a commit to sonvt1710/ClickHouse that referenced this pull request May 6, 2026
The Code Review job's Copilot CLI subprocess occasionally hits transient
GitHub authorization errors mid-run, e.g.

    [10:08:14] Authorization error, you may need to run /login (Request ID: F924:13DD23:...)
    [10:08:14] ERROR: command failed after 1/1 attempt(s), exit code: 1
    [10:08:14] ERROR: Copilot did not write ./ci/tmp/copilot_review.md
    RuntimeError: Copilot did not write ./ci/tmp/copilot_review.md

(seen on PR ClickHouse#104204 attempt 2 of run 25428876194; attempt 3 of the same
run completed cleanly.) Without retries, a single transient blip from the
GitHub auth path inside Copilot is enough to mark "Code Review" as `FAIL`
and post `Mergeable Check: Failed: Code Review, Dropped: 71`.

Two fixes:

1. `ci/jobs/copilot_review_job.py`: wrap the gh-auth + copilot subprocess
   sequence in a 3-attempt retry loop with exponential backoff. Each
   attempt re-fetches the secret, re-runs `gh auth login` against a fresh
   `GH_CONFIG_DIR`, and re-invokes Copilot. An attempt counts as success
   only if the subprocess exits 0 AND `REVIEW_FILE` is written non-empty
   — auth failures inside Copilot don't surface as exceptions, only as
   exit code != 0 and a missing review file.

2. `ci/praktika/gh.py`: add `GH.get_output_with_retries(cmd)` helper that
   mirrors `do_command_with_retries` but returns stdout. Use it for every
   GitHub-API read that previously called bare `Shell.get_output(cmd)`:
   `post_pr_comment`, `post_fresh_comment`, `post_updateable_comment`,
   `get_pr_contributors`, `get_pr_labels`, `get_pr_title_body_labels`,
   `get_pr_label_assigner`, `get_pr_diff`, `pr_has_conflicts`. These
   would previously return `""` on transient `gh` failures and either
   propagate as `json.loads('')` errors or silently misclassify the PR
   (e.g. miss an existing comment and post a duplicate). Same
   non-retryable error classes as `do_command_with_retries`
   (`Validation Failed`, `Bad credentials`, `Resource not accessible`).

Also harden `post_updateable_comment` against malformed JSON: catch
`json.JSONDecodeError` and treat it as "no existing comments" rather
than crashing the caller.

Reported-by: alexey-milovidov <ClickHouse#104204 (comment)>
Session-ID: cron:clickhouse-ci-task-worker:20260506-131500

Co-Authored-By: Claude Opus 4.7 <[email protected]>
devcrafter pushed a commit that referenced this pull request May 7, 2026
The Code Review job's Copilot CLI subprocess occasionally hits transient
GitHub authorization errors mid-run, e.g.

    [10:08:14] Authorization error, you may need to run /login (Request ID: F924:13DD23:...)
    [10:08:14] ERROR: command failed after 1/1 attempt(s), exit code: 1
    [10:08:14] ERROR: Copilot did not write ./ci/tmp/copilot_review.md
    RuntimeError: Copilot did not write ./ci/tmp/copilot_review.md

(seen on PR #104204 attempt 2 of run 25428876194; attempt 3 of the same
run completed cleanly.) Without retries, a single transient blip from the
GitHub auth path inside Copilot is enough to mark "Code Review" as `FAIL`
and post `Mergeable Check: Failed: Code Review, Dropped: 71`.

Two fixes:

1. `ci/jobs/copilot_review_job.py`: wrap the gh-auth + copilot subprocess
   sequence in a 3-attempt retry loop with exponential backoff. Each
   attempt re-fetches the secret, re-runs `gh auth login` against a fresh
   `GH_CONFIG_DIR`, and re-invokes Copilot. An attempt counts as success
   only if the subprocess exits 0 AND `REVIEW_FILE` is written non-empty
   — auth failures inside Copilot don't surface as exceptions, only as
   exit code != 0 and a missing review file.

2. `ci/praktika/gh.py`: add `GH.get_output_with_retries(cmd)` helper that
   mirrors `do_command_with_retries` but returns stdout. Use it for every
   GitHub-API read that previously called bare `Shell.get_output(cmd)`:
   `post_pr_comment`, `post_fresh_comment`, `post_updateable_comment`,
   `get_pr_contributors`, `get_pr_labels`, `get_pr_title_body_labels`,
   `get_pr_label_assigner`, `get_pr_diff`, `pr_has_conflicts`. These
   would previously return `""` on transient `gh` failures and either
   propagate as `json.loads('')` errors or silently misclassify the PR
   (e.g. miss an existing comment and post a duplicate). Same
   non-retryable error classes as `do_command_with_retries`
   (`Validation Failed`, `Bad credentials`, `Resource not accessible`).

Also harden `post_updateable_comment` against malformed JSON: catch
`json.JSONDecodeError` and treat it as "no existing comments" rather
than crashing the caller.

Reported-by: alexey-milovidov <#104204 (comment)>
Session-ID: cron:clickhouse-ci-task-worker:20260506-131500

Co-Authored-By: Claude Opus 4.7 <[email protected]>
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-not-for-changelog This PR should not be mentioned in the changelog 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.

5 participants