Skip to content

Fix limit and offset settings for secondary queries.#59018

Closed
yakov-olkhovskiy wants to merge 7 commits into
masterfrom
fix-system-settings-context
Closed

Fix limit and offset settings for secondary queries.#59018
yakov-olkhovskiy wants to merge 7 commits into
masterfrom
fix-system-settings-context

Conversation

@yakov-olkhovskiy

@yakov-olkhovskiy yakov-olkhovskiy commented Jan 20, 2024

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

Fix - for all secondary queries limit and offset should be reset in context. Table system.setting should take values from query context.

closes #58918

@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-bugfix Pull request with bugfix, not backported by default label Jan 20, 2024
@robot-ch-test-poll2

robot-ch-test-poll2 commented Jan 20, 2024

Copy link
Copy Markdown
Contributor

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

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

Successful checks
Check nameDescriptionStatus
A SyncThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
Bugfix validate checkChecks that either a new test (functional or integration) or there some changed tests that fail with the binary built on master branch✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process✅ 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. Integrational 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
Mergeable CheckChecks if all other necessary checks are successful✅ 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
SQLTestThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
SQLancerFuzzing tests that detect logical bugs with SQLancer tool✅ success
SqllogicRun clickhouse on the sqllogic test set against sqlite and checks that all statements are passed✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ 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
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❌ failure
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR⏳ pending
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests❌ failure
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors❌ failure

@alexey-milovidov alexey-milovidov removed the pr-bugfix Pull request with bugfix, not backported by default label Jan 20, 2024
@alexey-milovidov

Copy link
Copy Markdown
Member

@yakov-olkhovskiy It is intended to work this way. You can change it, but it should be labeled as a backward incompatible change and we should add a compatibility setting.

@alexey-milovidov alexey-milovidov left a comment

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.

Test needed.

@yakov-olkhovskiy

Copy link
Copy Markdown
Member Author

@alexey-milovidov yes, I already somehow investigated this - the test which is failing seems to indicate that it was intended at least at some point, but I find it inconsistent - we have context itself, then query context, session context and global context within - I don't exactly understand what the difference then and the usage seems inconsistent - I want to discuss it with the team to decide how we want it...

@alexey-milovidov

Copy link
Copy Markdown
Member

Yes, I also checked... the reason I tell is because I remember how, and why I've added this table :)

So, when it was developed, the intent was to show the settings effective for this particular query from system.settings.
The motivation is - these are the most "deep" settings, that we can get. They include the most overrides possible, so it is like the most information that we can show.

Then I checked the docs, and it stated that it shows session-level settings, which is surprising. Maybe it was lost when the docs were written.

I don't mind changing this behavior, so your change is good for me.
But what is the problem with Analyzer?

@alexey-milovidov alexey-milovidov self-assigned this Jan 20, 2024
@yakov-olkhovskiy

Copy link
Copy Markdown
Member Author

In analyzer we calculate effective limit and offset as a query expression and put it into query tree, and remove from setting to prevent further interference:
https://github.com/ClickHouse/ClickHouse/blob/master/src/Analyzer/QueryTreeBuilder.cpp#L247-L249

Of course this problem can be addressed differently - instead removing from settings I can find further interference and prevent it... I think it's a better approach than changing meaning of system.settings. Will do this.

@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-improvement Pull request with some product improvements label Feb 9, 2024
@yakov-olkhovskiy
yakov-olkhovskiy marked this pull request as ready for review February 9, 2024 15:18
@yakov-olkhovskiy yakov-olkhovskiy changed the title Fix - system.settings table retrieves data from its own query context. Analyzer fix - preserve global context 'limit' and 'offset' settings. Feb 9, 2024
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added pr-bugfix Pull request with bugfix, not backported by default and removed pr-improvement Pull request with some product improvements labels Feb 10, 2024
@yakov-olkhovskiy yakov-olkhovskiy changed the title Analyzer fix - preserve global context 'limit' and 'offset' settings. Fix limit and offset settings for secondary queries. Feb 14, 2024
@alexey-milovidov

Copy link
Copy Markdown
Member

A test has failed.

@yakov-olkhovskiy
yakov-olkhovskiy marked this pull request as draft April 11, 2024 12:39
@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2024

Copy link
Copy Markdown
Contributor

Dear @yakov-olkhovskiy, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

1 similar comment
@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

Dear @yakov-olkhovskiy, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

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

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

system.settings values for limit and offset are incorrect with the analyzer

4 participants