Skip to content

SSH interface with PTY#48902

Merged
nikitamikhaylov merged 19 commits intoClickHouse:masterfrom
InfJoker:ssh-protocol-with-pty
Jan 8, 2025
Merged

SSH interface with PTY#48902
nikitamikhaylov merged 19 commits intoClickHouse:masterfrom
InfJoker:ssh-protocol-with-pty

Conversation

@InfJoker
Copy link
Copy Markdown
Contributor

@InfJoker InfJoker commented Apr 18, 2023

Changelog category (leave one):

  • New Feature

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

SSH interface has been added. It is now possible to connect to the ClickHouse server using any SSH client and execute queries in an interactive fashion using PTY with an embedded clickhouse-client.

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/

CI Settings (Only check the boxes if you know what you are doing)

All builds in Builds_1 and Builds_2 stages are always mandatory
and will run independently of the checks below:

  • Allow: All Required Checks
  • Allow: Stateless tests
  • Allow: Stateful tests
  • Allow: Integration Tests
  • Allow: Performance tests
  • Allow: All Builds
  • Allow: batch 1, 2 for multi-batch jobs
  • Allow: batch 3, 4, 5, 6 for multi-batch jobs

  • Exclude: Style check
  • Exclude: Fast test
  • Exclude: All with ASAN
  • Exclude: All with TSAN, MSAN, UBSAN, Coverage
  • Exclude: All with aarch64
  • Exclude: All with release
  • Exclude: All with debug

  • Run only fuzzers related jobs (libFuzzer fuzzers, AST fuzzers, etc.)
  • Exclude: AST fuzzers

  • Do not test
  • Woolen Wolfdog
  • Upload binaries for special builds
  • Disable merge-commit
  • Disable CI cache

@robot-ch-test-poll4 robot-ch-test-poll4 added pr-feature Pull request with new product feature submodule changed At least one submodule changed in this PR. labels Apr 18, 2023
@InfJoker InfJoker force-pushed the ssh-protocol-with-pty branch from c02f767 to 572c17b Compare April 18, 2023 14:55
@Avogar Avogar added the can be tested Allows running workflows for external contributors label Apr 18, 2023
@InfJoker InfJoker force-pushed the ssh-protocol-with-pty branch from 572c17b to 0af463d Compare May 7, 2023 15:49
@robot-ch-test-poll
Copy link
Copy Markdown
Contributor

robot-ch-test-poll commented May 7, 2023

This is an automated comment for commit 32d1c06 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
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
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
BuzzHouse (asan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (debug)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (msan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (tsan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
BuzzHouse (ubsan)There's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns 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
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

@InfJoker InfJoker force-pushed the ssh-protocol-with-pty branch 4 times, most recently from e3c09d2 to 2d7ff44 Compare May 12, 2023 08:52
@InfJoker InfJoker force-pushed the ssh-protocol-with-pty branch 9 times, most recently from 888573b to d431854 Compare May 15, 2023 15:47
@InfJoker InfJoker changed the title [WIP] Ssh protocol with pty Ssh protocol with pty May 15, 2023
@InfJoker InfJoker marked this pull request as ready for review May 15, 2023 17:50
@InfJoker InfJoker force-pushed the ssh-protocol-with-pty branch 2 times, most recently from 4026e62 to 4f028f4 Compare May 31, 2023 09:06
@antonio2368 antonio2368 self-assigned this Jun 10, 2023
@InfJoker InfJoker force-pushed the ssh-protocol-with-pty branch from 4f028f4 to 019f5f5 Compare June 12, 2023 20:37
Copy link
Copy Markdown
Member

@antonio2368 antonio2368 left a comment

Choose a reason for hiding this comment

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

A lot of changes!
there are a lot of comments but the majority of them are just code-style comments and general C++ rules for our repo.

Please go through https://clickhouse.com/docs/en/development/style and apply fixes where necessary.

@InfJoker InfJoker force-pushed the ssh-protocol-with-pty branch 2 times, most recently from 6ef2e11 to a675f2b Compare June 17, 2023 20:55
int out_fd_,
int err_fd_)
: LineReader(history_file_path_, multiline_, std::move(extenders_), std::move(delimiters_), input_stream_, output_stream_, in_fd_)
, rx(input_stream_, output_stream_, in_fd_, out_fd_, err_fd_)
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 will not work untill replxx is patched

@nikitamikhaylov
Copy link
Copy Markdown
Member

nikitamikhaylov commented Jan 7, 2025

I see that 01700_deltasum is broken in master along with test_memory_limit/test.py::test_multiple_queries.

The TSAN failure looks related. Looking.

@nikitamikhaylov
Copy link
Copy Markdown
Member

Stateless tests (asan) - #74287

@nikitamikhaylov
Copy link
Copy Markdown
Member

So, another iteration:

  • test_async_insert_adaptive_busy_timeout/test.py::test_compare_parallel_inserts_durations_for_adaptive_and_fixed_async_timeouts is super flaky in recent days.
  • 02871_peak_threads_usage failed in another PR in a recent week.

Given that these changes tend to conflict much, I will override the Mergable Check. As an excuse I will take a look at all the flaky tests later.

return ssh_key_type_to_char(ssh_key_type(key));
}

void SSHKey::setNeedsDeallocation(bool needs_deallocation_)
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.

SSH key is a duplicate of src/SSH/SSHPublicKey. Further refactoring should remove this

LOG_TRACE(log, "TCP Request. Address: {}", socket.peerAddress().toString());
::ssh::libsshLogger::initialize();
::ssh::SSHSession session;
session.disableSocketOwning();
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.

for this I remember writing a monkey test that will run session and abrupt session 100 times - then double free happens. It might have been deleted. This is important since when I was making a poc libssh owns socket and will free it out without this patch InfJoker/libssh-clickhouse-patch@11289d6

Comment on lines +48 to +50
/// NOP. The embedded client runs inside the server process which has its own signal handlers.
/// Thus we cannot override it in any way.
void setupSignalHandler() override {}
Copy link
Copy Markdown
Contributor Author

@InfJoker InfJoker Feb 2, 2025

Choose a reason for hiding this comment

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

@nikitamikhaylov for this ClientBase has a method

bool tryStopQuery() { return query_interrupt_handler.tryStop(); }
which is called by ClientApplicationBase on signal interrupt
if (base->tryStopQuery())
.

But since we can't setup signal handlers in a single process with database -> we should process charecters in SSHPtyHandler and if Ctrl-C is intercepted -> stop current query by calling mentioned method in ClientBase.

Or the other way around it is to spawn client in different process and figure out a way to talk with db back and forth

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 manual approve Manual approve required to run CI pr-feature Pull request with new product feature 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.

10 participants