Skip to content

Write view refreshes to query_log, pre-check permissions - #71333

Merged
al13n321 merged 34 commits into
masterfrom
rmvlog
Mar 19, 2025
Merged

al13n321 merged 34 commits into
masterfrom
rmvlog

Conversation

@al13n321

@al13n321 al13n321 commented Nov 1, 2024

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Improvement

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

Refreshes of refreshable materialized views now appear in system.query_log.


The new query_log rows have: interface = 9, client_name = 'refreshable materialized view', log_comment = 'refresh of <db>.<table>'.

Also improved error handling and permission handling a little.

@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-improvement Pull request with some product improvements label Nov 1, 2024
@robot-ch-test-poll

robot-ch-test-poll commented Nov 1, 2024 •

Copy link
Copy Markdown
Contributor

This is an automated comment for commit 9e63bf4 with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
Successful checks
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

@vdimir vdimir self-assigned this Nov 4, 2024
if (!lock.owns_lock())
lock.lock();
scheduling.stop_requested = true;
scheduling.unexpected_error = getCurrentExceptionMessage(true);

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.

Does getCurrentExceptionMessage work properly outside of catch ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is inside catch.

@al13n321

Copy link
Copy Markdown
Contributor Author

The failed check is #69519

@clickhouse-gh

clickhouse-gh Bot commented Feb 4, 2025

Copy link
Copy Markdown
Contributor

Dear @vdimir, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@clickhouse-gh

clickhouse-gh Bot commented Feb 14, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [29c45be]

@vdimir vdimir self-assigned this Feb 19, 2025
@al13n321

Copy link
Copy Markdown
Contributor Author

I kinda need this to get merged to avoid stacking another PR on top of it, so I'll resort to updating the PR with 'merge master' commits lots of times in hopes of winning the CI lottery, because making the next RMV change seems more urgent than fixing CI.

@al13n321

Copy link
Copy Markdown
Contributor Author

Something strange happened in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=71333&sha=2308a35006d8880b7934f0d16e4e4f7cc608b431&name_0=PR&name_1=Stress%20test%20%28debug%29 , I couldn't figure it out.
0. There's RMV test_1_03258.v

  1. drop database test_1_03258 starts. It tries to drop the RMV and its inner table.
  2. Fault injection does this: InterpreterDropQuery: Replace DROP TABLE query to TRUNCATE TABLE for table test_1_03258..inner_id.64df4171-ae7b-432c-8149-ecf783101f61
  3. The db drop query says this: DatabaseCatalog: Done waiting for the table 64df4171-ae7b-432c-8149-ecf783101f61 to be dropped. The outcome: table dropped successfully, where 64df4171-ae7b-432c-8149-ecf783101f61 is presumably the UUID of test_1_03258.v
  4. The drop then fails the expected way (given the fault injection above): New table appeared in database being dropped or detached., with stack trace containing detachDatabase.
  5. But it appears that the table 64df4171-ae7b-432c-8149-ecf783101f61 still exists in the database, after its IStorage::shutdown() was called. E.g. there's this query: system refresh view test_1_03258.v that failed with this error: Refreshable view test_1_03258.v (64df4171-ae7b-432c-8149-ecf783101f61) doesn't exist., which means that (a) the table exists in the database (otherwise where would the UUID in the error message come from?), (b) the table doesn't exist in RefreshSet (presumably because shutdown() was called).
  6. But in the code I don't see how that is possible. InterpreterDropQuery::executeToDatabaseImpl calls detachDatabase after dropping (executeToTableImpl) all tables. And yet the table wasn't dropped.

Added a workaround to RefreshTask as this seems unrelated to this PR.

@al13n321
al13n321 added this pull request to the merge queue Mar 19, 2025
Merged via the queue into master with commit b0ccdf6 Mar 19, 2025
@al13n321
al13n321 deleted the rmvlog branch March 19, 2025 05:30
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 19, 2025
tryLogCurrentException(&Poco::Logger::get("StorageMaterializedView"), "Failed to drop temporary table after refresh");
auto query_for_logging = drop_query->formatForLogging(refresh_context->getSettingsRef()[Setting::log_queries_cut_to_length]);
UInt64 normalized_query_hash = normalizedQueryHash(query_for_logging, false);
logExceptionBeforeStart(query_for_logging, normalized_query_hash, refresh_context, drop_query, nullptr, stopwatch.elapsedMilliseconds());

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.

FYI #83277

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements 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.

6 participants