Skip to content

Add Simple Streaming implementation#57830

Open
Michicosun wants to merge 89 commits intoClickHouse:masterfrom
Michicosun:issues/42990/simple_streaming
Open

Add Simple Streaming implementation#57830
Michicosun wants to merge 89 commits intoClickHouse:masterfrom
Michicosun:issues/42990/simple_streaming

Conversation

@Michicosun
Copy link
Copy Markdown
Member

@Michicosun Michicosun commented Dec 13, 2023

Changelog category (leave one):

  • New Feature

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

add streaming mode for every table engine via 2 processors in pipeline

example select:

set allow_experimental_streaming=1;
set allow_experimental_analyzer=1;

CREATE TABLE test (a String, b UInt64) ENGINE = MergeTree() ORDER BY a;

-- infinite query
SELECT a, b * b FROM test STREAM;

insert works as usual

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Dec 13, 2023
@robot-ch-test-poll robot-ch-test-poll added the pr-feature Pull request with new product feature label Dec 13, 2023
@robot-ch-test-poll
Copy link
Copy Markdown
Contributor

robot-ch-test-poll commented Dec 13, 2023

This is an automated comment for commit 210d0b7 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
A SyncThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS❌ 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
Mergeable CheckChecks if all other necessary checks are successful❌ failure
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests❌ failure
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors❌ failure
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❌ 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
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
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
PR CheckThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stateless testsRuns stateless 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

@Michicosun Michicosun force-pushed the issues/42990/simple_streaming branch from 0b00b24 to 3622f90 Compare January 29, 2024 20:22
Copy link
Copy Markdown
Member

@al13n321 al13n321 left a comment

Choose a reason for hiding this comment

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

The changes look great! Sorry for the slow response. Please resolve the conflicts, update SettingsChangesHistory.h, optionally address the new nitpicks, and should be good to go.

{
buffer << "stream: " << has_stream;

buffer << "final: " << has_final;
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.

Suggested change
buffer << "final: " << has_final;
buffer << ", final: " << has_final;

buffer << "STREAM";

if (has_final)
buffer << "FINAL";
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.

Need a space between STREAM and FINAL, and update the conditions for the two buffer << ' ' calls below (or extract it into a helper lambda add_space_if_needed() or something). (Though ... STREAM FINAL is not a valid query, it's not obvious that this method can't get called before the query is rejected.)

}},
{"24.3", {{"s3_connect_timeout_ms", 1000, 1000, "Introduce new dedicated setting for s3 connection timeout"},
{"allow_experimental_shared_merge_tree", false, true, "The setting is obsolete"},
{"allow_experimental_streaming", false, false, "Allow to use Streaming Queries"},
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.

Need to move it to the current month. (We'll probably merge this within a month, so it won't have to be moved again.)


if (table_expression_modifiers && table_expression_modifiers->hasStream())
throw Exception(ErrorCodes::ILLEGAL_PREWHERE,
"PREWHERE does not supported for Streaming Queries");
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.

Suggested change
"PREWHERE does not supported for Streaming Queries");
"PREWHERE is not supported for Streaming Queries");

storage->getStorageID().getNameForLogs());
if (table_node->hasTableExpressionModifiers() && table_node->getTableExpressionModifiers()->hasStream())
throw Exception(ErrorCodes::ILLEGAL_PREWHERE,
"PREWHERE does not supported for Streaming Queries");
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.

Suggested change
"PREWHERE does not supported for Streaming Queries");
"PREWHERE is not supported for Streaming Queries");

storage->getStorageID().getNameForLogs());
if (table_function_node->hasTableExpressionModifiers() && table_function_node->getTableExpressionModifiers()->hasStream())
throw Exception(ErrorCodes::ILLEGAL_PREWHERE,
"PREWHERE does not supported for Streaming Queries");
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.

Suggested change
"PREWHERE does not supported for Streaming Queries");
"PREWHERE is not supported for Streaming Queries");

getStorageID().getFullTableName(), data_path_in_backup);
}

StorageSnapshotPtr IStorage::getStorageSnapshot(const StorageMetadataPtr & metadata_snapshot, ContextPtr query_context) const
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.

Can't these 3 methods just use default argument value instead of separate overloads?

virtual StorageSnapshotPtr getStorageSnapshot(const StorageMetadataPtr & metadata_snapshot, ContextPtr query_context, const StorageSnapshotSettings & additional_settings = {}) const;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

actually it is because of clang-tidy warning: Default arguments on virtual or override methods are prohibited

Comment on lines +198 to +200
/// if block is added: push current_block to all subscribers under the same lock as commit.
/// But there may be a race between insert and creating a new subscription, in which case
/// the block may already have been cleared, but this is normal, because this is concurrent operations.
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.

I would've liked to know how this translates to actual guarantees provided by streaming queries? Is this correct?:

Suggested change
/// if block is added: push current_block to all subscribers under the same lock as commit.
/// But there may be a race between insert and creating a new subscription, in which case
/// the block may already have been cleared, but this is normal, because this is concurrent operations.
/// If block is added: push current_block to all subscribers under the same lock as commit.
/// This ensures that streaming query receives each block at most once: either from the
/// initial read or from stream.
/// But there may be a race between insert and creating a new subscription, in which case
/// the block may already have been cleared, but this is normal: it's ok for streaming query
/// to miss a block that was inserted concurrently with starting the streaming query.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That is absolutely correct! The main idea that in case of concurrent insert (block P) and starting streaming query, it may not read the block P.

@Michicosun
Copy link
Copy Markdown
Member Author

@al13n321 thank you for review!!

But I'm not recommend you to merge this pr, because:

  • I have complete implementation of streaming queries with cursors in different pr and it has no conflicts.
  • In this pr ReplicatedMergeTree is not supported and it cannot be, because streaming queries from replicated tables require cursors.

I see that issues are not critical, so maybe you can also check out final pr? 63312

I just merged this pr and queue mode into single and above that implemented cursors. Because commits are the same, I do not close previous prs, to make easier review.

Sorry about this move, but I needed to provide the final implementation of streaming queries read mechanics by the end of May (At least in the form of a pull request).

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Jul 30, 2024

Dear @al13n321, 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.

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-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants