Commit Graph

604 Commits

Author SHA1 Message Date
凌涛
bd78af435d update code and add document 2021-09-30 04:51:02 +08:00
Artur
fcebf7b985 correct tests 2021-09-29 11:29:24 +00:00
凌涛
c298fba774 Support HSTS in Clickhouse HTTP server 2021-09-29 16:37:48 +08:00
Nikolai Kochetov
78a7665f43 Merge branch 'master' into rewrite-pushing-to-views 2021-09-27 10:56:50 +03:00
Nikolai Kochetov
09232788c0 Fix GRPC tests. 2021-09-27 10:55:33 +03:00
Azat Khuzhin
b3d1bfc67a Send UNKNOWN_DATABASE to the client (via TCP)
Before this patch:

    $ clickhouse-client --database foo -q 'select 1'
    Code: 32. DB::Exception: Attempt to read after eof: while receiving packet from localhost:9000. (ATTEMPT_TO_READ_AFTER_EOF)

After:

    $ clickhouse-client --database foo -q 'select 1'
    Received exception from server (version 21.11.1):
    Code: 81. DB::Exception: Received from localhost:9000. DB::Exception: Database foo doesn't exist. (UNKNOWN_DATABASE)
    (query: select 1)

Fixes: #26864 (cc @vitlibar)
2021-09-26 23:45:29 +03:00
Nikolai Kochetov
efbd8e4911 Remove ExceptionHandlingSink. 2021-09-26 17:54:59 +03:00
Alexey Milovidov
cd7f9d981c Remove ya.make 2021-09-25 04:22:54 +03:00
Filatenkov Artur
7bbd08cb5d
Update HTTPHandler.cpp 2021-09-24 15:40:27 +03:00
Artur
e5c49c2e86 Merge branch 'add_CORS' of https://github.com/FArthur-cmd/ClickHouse into add_CORS 2021-09-22 17:15:54 +00:00
Artur
ce4193fe95 small refactoring 2021-09-22 17:10:15 +00:00
Filatenkov Artur
1fe4555dec
Merge branch 'ClickHouse:master' into add_CORS 2021-09-22 19:55:15 +03:00
Artur
2ad7641e7f activate add_http_cors_header by default. 2021-09-22 16:54:36 +00:00
Nikolai Kochetov
eed4e8c754 Fix progress for insert select. 2021-09-22 16:29:58 +03:00
Artur
36223b5f23 update comments for filter 2021-09-22 12:30:55 +00:00
Artur
2cffa98a60 add test and comments in config 2021-09-22 12:22:21 +00:00
Nikolai Kochetov
81bf13a247 Refactor pushing to views. 2021-09-22 13:57:00 +03:00
Artur
c8892ec7a7 add options support 2021-09-22 10:34:48 +00:00
Nikolai Kochetov
db6f1e198c Add cancell callback to completed executor. 2021-09-21 19:37:32 +03:00
Artur
82a849ba8e add options method 2021-09-18 09:36:02 +00:00
Nikolai Kochetov
a8c3b02598 Merge branch 'master' into rewrite-pushing-to-views 2021-09-17 15:38:11 +03:00
Nikolai Kochetov
58bb5fe462 Fix some tests. 2021-09-17 14:40:03 +03:00
Azat Khuzhin
60013cff1a Do not call finalize() for HTTP buffer multiple times
Before only non-compressed was flushed, and so after compressed will
write to non-compressed and this will trigger multiple finalize() for
raw buffer, fix this, but adding Output::finalize() that take care of
all buffers.

This should fix CI failure [1] and also not only CI failures but also an
assert() that had been added in the previous commit.

    2021-09-05 15:08:43 00429_long_http_bufferization:                                          [ FAIL ] 6.68 sec. - return code 1
    2021-09-05 15:08:43 cmp: EOF on /tmp/clickhouse-test/0_stateless/test_e4xs61/res3 after byte 1048576, in line 4127
    2021-09-05 15:08:43 , result:

    The problem was with the following query:

        curl -q -sS 'http://localhost:8123/?database=default&log_comment=/src/ch/clickhouse/tests/queries/0_stateless/00429_long_http_bufferization.sh&max_block_size=500000&compress=1&buffer_size=1048576&wait_end_of_query=1' -d 'SELECT greatest(toUInt8(1), toUInt8(intHash64(number))) FROM system.numbers LIMIT 1500000 FORMAT RowBinary' | clickhouse-compressor --decompress | less

    It returns less rows.

  [1]: https://clickhouse-test-reports.s3.yandex.net/28604/1f34fd9a9eaff19fde0199f78b45656ab74f0590/functional_stateless_tests_(release).html#fail1
2021-09-16 22:36:09 +03:00
Azat Khuzhin
9bb9d5952b Catch write-after-finalize bugs in WriteBufferFromHTTPServerResponse 2021-09-16 22:35:51 +03:00
Azat Khuzhin
7b741c28e4 Do not try to write HTTP response after exception
CI reports [1]:

    [ 25285 ] {} <Trace> DynamicQueryHandler: Request URI: /?database=test_27&log_comment=/usr/share/clickhouse-test/queries/0_stateless/00429_long_http_bufferization.sh&max_block_size=500000&compress=1&buffer_size=1500000&wait_end_of_query=1
    ...
    [ 25285 ] {ee96eb9c-44cc-4b76-9f30-3cc545a5506f} <Debug> executeQuery: (from [::1]:41578) (comment: /usr/share/clickhouse-test/queries/0_stateless/00429_long_http_bufferization.sh) SELECT greatest(toUInt8(1), toUInt8(intHash64(number))) FROM system.numbers LIMIT 1048576 FORMAT RowBinary
    [ 25285 ] {ee96eb9c-44cc-4b76-9f30-3cc545a5506f} <Information> executeQuery: Read 1500000 rows, 11.44 MiB in 63.924507821 sec., 23465 rows/sec., 183.32 KiB/sec.
    [ 25285 ] {ee96eb9c-44cc-4b76-9f30-3cc545a5506f} <Debug> DynamicQueryHandler: Done processing query
    ...
    [ 455 ] {} <Fatal> BaseDaemon: Code: 24. DB::Exception: Cannot write to ostream at offset 2097152. (CANNOT_WRITE_TO_OSTREAM), Stack trace (when copying this message, always include the lines below):
    [ 455 ] {} <Fatal> BaseDaemon:
    [ 455 ] {} <Fatal> BaseDaemon: 0. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/exception:0: Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x18fa949b in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 1. ./obj-x86_64-linux-gnu/../src/Common/Exception.cpp:59: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x99f38dc in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 2. ./obj-x86_64-linux-gnu/../src/IO/WriteBufferFromOStream.cpp:0: DB::WriteBufferFromOStream::nextImpl() @ 0x9adf185 in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 3. ./obj-x86_64-linux-gnu/../src/IO/BufferBase.h:39: DB::WriteBufferFromHTTPServerResponse::nextImpl() @ 0x15b71ec0 in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 4. ./obj-x86_64-linux-gnu/../src/IO/WriteBuffer.h:0: DB::WriteBuffer::write(char const*, unsigned long) @ 0x99be96a in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 5. ./obj-x86_64-linux-gnu/../src/Compression/CompressedWriteBuffer.cpp:36: DB::CompressedWriteBuffer::nextImpl() @ 0x1436ca4d in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 6. ./obj-x86_64-linux-gnu/../src/IO/BufferBase.h:39: DB::CompressedWriteBuffer::~CompressedWriteBuffer() @ 0x1436cd8f in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 7. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2615: std::__1::__shared_ptr_emplace<DB::CompressedWriteBuffer, std::__1::allocator<DB::CompressedWriteBuffer> >::__on_zero_shared() @ 0x15a88ee8 in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 8. ./obj-x86_64-linux-gnu/../contrib/libcxx/include/memory:2518: DB::HTTPHandler::handleRequest(DB::HTTPServerRequest&, DB::HTTPServerResponse&) @ 0x15b0566b in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 9. ./obj-x86_64-linux-gnu/../src/Server/HTTP/HTTPServerConnection.cpp:0: DB::HTTPServerConnection::run() @ 0x15b6ba61 in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 10. ./obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerConnection.cpp:57: Poco::Net::TCPServerConnection::start() @ 0x18ec71a3 in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 11. ./obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerDispatcher.cpp:114: Poco::Net::TCPServerDispatcher::run() @ 0x18ec7930 in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 12. ./obj-x86_64-linux-gnu/../contrib/poco/Foundation/include/Poco/ScopedLock.h:36: Poco::PooledThread::run() @ 0x1903e042 in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 13. ./obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Thread.cpp:56: Poco::(anonymous namespace)::RunnableHolder::run() @ 0x1903c4d0 in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 14. ./obj-x86_64-linux-gnu/../contrib/poco/Foundation/include/Poco/SharedPtr.h:277: Poco::ThreadImpl::runnableEntry(void*) @ 0x1903ac48 in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 15. __tsan_thread_start_func @ 0x990a76d in /usr/bin/clickhouse
    [ 455 ] {} <Fatal> BaseDaemon: 16. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
    [ 455 ] {} <Fatal> BaseDaemon: 17. clone @ 0x122293 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
    [ 455 ] {} <Fatal> BaseDaemon:  (version 21.10.1.7997)
    [ 25878 ] {} <Fatal> BaseDaemon: ########################################
    [ 25878 ] {} <Fatal> BaseDaemon: (version 21.10.1.7997, build id: DB9812D7EA89EB06D2C7243F5C8BD293AA9BA37D) (from thread 25285) (query_id: ee96eb9c-44cc-4b76-9f30-3cc545a5506f) Received signal Aborted (6)
    [ 25878 ] {} <Fatal> BaseDaemon:
    [ 25878 ] {} <Fatal> BaseDaemon: Stack trace: 0x7efe2a35818b 0x7efe2a337859 0x990ff6e 0x13fa707d 0x1bb17614 0x1bb17507 0x999c97b 0x1436cf11 0x15a88ee8 0x15b0566b 0x15b6ba61 0x18ec71a3 0x18ec7930 0x1903e042 0x1903c4d0 0x1903ac48 0x990a76d 0x7efe2a50d609 0x7efe2a434293
    [ 25878 ] {} <Fatal> BaseDaemon: 5. raise @ 0x4618b in /usr/lib/x86_64-linux-gnu/libc-2.31.so
    [ 25878 ] {} <Fatal> BaseDaemon: 6. abort @ 0x25859 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
    [ 450 ] {} <Fatal> Application: Child process was terminated by signal 6.

  [1]: https://clickhouse-test-reports.s3.yandex.net/28604/d6e86dab2754dbea3ed19d9ae72276e7d161aef1/stress_test_(thread).html#fail1
2021-09-16 22:35:51 +03:00
Azat Khuzhin
230f29ac4e Always flush buffer while handling HTTP queries
This will avoid possible std::terminate, like in [1]:

  [1]: https://github.com/ClickHouse/ClickHouse/pull/24023#issuecomment-842979875
2021-09-16 22:35:50 +03:00
Azat Khuzhin
47ad10061b Reduce scope for HTTPHandler::trySendExceptionToClient() 2021-09-16 22:35:50 +03:00
Nikolai Kochetov
341553febd Fix build. 2021-09-16 20:40:42 +03:00
Anton Popov
dfbb1ffec0
Merge pull request #27537 from CurtizJ/merging-20557
Merging #20557 (Asynchronous inserts)
2021-09-16 03:08:34 +03:00
Nikita Mikhaylov
6bf5b4cf2d
Merge pull request #28953 from vitlibar/allow-change-server-side-compression-from-client
gRPC: Allow change server-side compression from client.
2021-09-16 00:55:06 +03:00
Nikolai Kochetov
e616732743 Small refactoring. 2021-09-15 22:35:48 +03:00
Nikolai Kochetov
b997214620 Rename QueryPipeline to QueryPipelineBuilder. 2021-09-14 20:48:18 +03:00
Vitaly Baranov
113ddceabb gRPC: Allow change server-side compression from client. 2021-09-13 01:07:28 +03:00
Nikolai Kochetov
3a9d88fbc9 Fix more tests. 2021-09-10 17:52:24 +03:00
Nikolai Kochetov
f569a3e3f7 Merge branch 'master' into rewrite-pushing-to-views 2021-09-09 20:30:23 +03:00
Anton Popov
8e5b3b2f6c Merge remote-tracking branch 'upstream/master' into HEAD 2021-09-09 15:12:34 +03:00
Vitaly Baranov
70c6623036
Merge branch 'master' into governance/session_log 2021-09-07 10:12:54 +03:00
Vitaly Baranov
bcc31f1f3e Remove unnecessary changes. 2021-09-07 01:37:28 +03:00
Anton Popov
59128412ea Merge remote-tracking branch 'upstream/master' into HEAD 2021-09-03 22:17:11 +03:00
Nikolai Kochetov
66a76ab70f Rewrite PushingToViewsBlockOutputStream part 6 2021-09-03 20:29:36 +03:00
Nikolai Kochetov
358babc31b Rewrite PushingToViewsBlockOutputStream part 5. 2021-09-02 14:29:20 +03:00
alesapin
a8003e444b Review fixes 2021-09-02 12:20:46 +03:00
Anton Popov
5e421ab272 Merge remote-tracking branch 'upstream/master' into HEAD 2021-09-02 02:42:50 +03:00
Vasily Nemkov
c902afddde Added system.session_log table
Which logs all the info about LogIn, LogOut and LogIn Failure events.
Additional info that is logged:
- User name
- event type (LogIn, LogOut, LoginFailure)
- Event date\time\time with microseconds
- authentication type (same as for IDENTIFIED BY of CREATE USER statement)
- array of active settings profiles upon login
- array of active roles upon login
- array of changed settings with corresponding values
- client address and port
- interface (TCP\HTTP\MySQL\PostgreSQL, etc.)
- client info (name, version info)
- optional LoginFailure reason text message.

Added some tests to verify that events are properly saved with all necessary info via following interfaces:
- TCP
- HTTP
- MySQL

Known limitations
- Not tested against named HTTP sessions, PostgreSQL and gRPC, hence those are not guaranteed to work 100% properly.
2021-08-30 18:28:28 +03:00
alesapin
47b995467e
Merge pull request #28080 from ClickHouse/some_renames_in_keeper
Clickhouse-keeper: renames and comments
2021-08-26 10:16:21 +03:00
Anton Popov
6d3274c22c Merge remote-tracking branch 'upstream/master' into HEAD 2021-08-26 03:31:46 +03:00
Vitaly Baranov
64f69462c6
Merge pull request #27921 from vitlibar/add-tests-for-field-init
Allow implicit cast bool to Field
2021-08-24 17:15:44 +03:00
alesapin
95cf0634dc Clickhouse-keeper: renames and comments 2021-08-24 15:30:31 +03:00
Nikita Mikhaylov
fb6462d70a
Merge pull request #27886 from vitlibar/add-separate-constants-for-interfaces
Add separate constants for interfaces LOCAL and TCP_INTERSERVER.
2021-08-23 16:25:01 +03:00
Vitaly Baranov
ff1fad8521 Use setSetting() with implicit conversion true/false -> Field. 2021-08-23 08:57:00 +03:00
Alexey Milovidov
c3c31e2895 Move function to appropriate place to make code more readable 2021-08-20 12:56:39 +03:00
Vitaly Baranov
3ab1177d7e Add separate constants for interface LOCAL and TCP_INTERSERVER. 2021-08-19 23:04:36 +03:00
Vitaly Baranov
fabd7193bd Code cleanups and improvements. 2021-08-18 14:24:52 +03:00
Vasily Nemkov
51ffc33457 Introduce sessions.
This is required to add system.session_log table.
2021-08-18 14:24:52 +03:00
hermano
14e251f158 Fixes style 2021-08-16 18:54:40 -03:00
hermano
5b520fbe0f Preloads query parameters 2021-08-16 07:58:52 -03:00
hermano
3366fc7c7e Enables query parameters in request body 2021-08-15 15:46:31 -03:00
Raúl Marín
a451bf6eac Remove unused code 2021-08-12 11:30:01 +02:00
Raúl Marín
f6788fc660 Mysql handler: Move format check to the handler 2021-08-12 11:29:50 +02:00
tavplubix
e7290fb134
Merge pull request #27385 from BraulioVM/fix/27171
Do not fail if HTTP port is not set and user tries to send request to TCP port
2021-08-09 15:30:58 +03:00
Vitaly Baranov
5a7fe51532
Merge pull request #27431 from vitlibar/grpc-protocol-bytes-instead-of-strings
Use bytes instead of strings in the GRPC protocol.
2021-08-09 09:51:24 +03:00
alexey-milovidov
d2efe3869f
Merge pull request #26984 from azat/keeper-server-fix
Remove test_keeper_server usage (for {operation/session}_timeout_ms)
2021-08-08 04:04:42 +03:00
Braulio Valdivielso
a833d1cf9e fixup! change http error response 2021-08-07 19:57:19 +01:00
Braulio Valdivielso
6189757fed change http error response
As reported in #27171, the logic that generates the HTTP error
response didn't work in case the configuration hadn't specified a
`http_port`. The new logic checks whether the `http_port` was set in
the first place.
2021-08-06 23:32:37 +01:00
Anton Popov
3a0d4807a5 Merge branch 'async-insert' of git://github.com/abyss7/ClickHouse into merging-20557 2021-08-06 16:20:02 +03:00
Vitaly Baranov
9a40ce87e9 Use bytes instead of strings in the GRPC protocol. 2021-08-06 13:55:49 +03:00
Vitaly Baranov
40a3c8281a Fix synchronization in GRPCServer 2021-08-03 09:44:47 +03:00
Azat Khuzhin
1feee18455 Remove test_keeper_server usage (for {operation/session}_timeout_ms) 2021-07-29 21:24:32 +03:00
Nikolai Kochetov
9b5a816b43 Merge branch 'master' into output-streams-to-processors 2021-07-26 18:03:11 +03:00
Nikolai Kochetov
9c92f43359 Update storages. 2021-07-23 22:33:59 +03:00
Nikolai Kochetov
3c17a62686
Merge pull request #26590 from ClickHouse/remove-some-more-streams
Remove some streams.
2021-07-22 21:28:50 +03:00
Nikolai Kochetov
3ed3f7a9f7 Fix integration tests. 2021-07-22 13:38:22 +03:00
Nikolai Kochetov
5ffd99dfd4
Merge pull request #25674 from amosbird/distributedreturnconnection
Drain connection asynchronously
2021-07-22 11:04:49 +03:00
Nikolai Kochetov
f38de35b14 Rename some constants. 2021-07-21 19:13:17 +03:00
Nikolai Kochetov
179ec05a72 Remove some streams. 2021-07-20 21:18:43 +03:00
anneji-dev
d8f45fbe13
Set client query kind for mysql and postgresql handler (#26498)
* client query kind is not set for mysql and postgresql

* Update MySQLHandler.cpp

* Update PostgreSQLHandler.cpp

Co-authored-by: anneji <anneji@tencent.com>
2021-07-20 09:23:58 +03:00
Amos Bird
dbfb699690
Asynchronously drain connections. 2021-07-19 21:53:29 +08:00
Vitaly Baranov
4f1926550b
Merge pull request #26429 from vitlibar/remove-mysql-wire-context
Remove MySQLWireContext
2021-07-19 12:21:24 +03:00
Alexey Milovidov
261a220227 Remove some code 2021-07-17 21:06:46 +03:00
alexey-milovidov
38dfe1fc0a
Merge pull request #26172 from ClickHouse/exception_id
Add error id to exceptions
2021-07-17 02:07:17 +03:00
Vitaly Baranov
0f8b196682 Remove MySQLWireContext. 2021-07-16 22:21:20 +03:00
Ivan Lezhankin
69e7f082fe Merge remote-tracking branch 'upstream/master' into async-insert 2021-07-13 17:15:32 +03:00
Nikita Mikhaylov
c255f152aa
Merge pull request #26051 from ClickHouse/fix_21184
Fix sequence_id in MySQL protocol
2021-07-13 16:03:25 +03:00
mergify[bot]
b7ae4e4ced
Merge branch 'master' into async-insert 2021-07-12 09:21:37 +00:00
Alexey Milovidov
3887e82dac Merge branch 'exception_id' of github.com:yandex/ClickHouse into exception_id 2021-07-12 03:18:39 +03:00
Alexey Milovidov
c4f34689ec Merge branch 'master' into exception_id 2021-07-11 22:12:06 +03:00
Vladimir
f120bd3d09
Directly pass getExceptionMessage() to LOG_ERROR in TCPHandler.cpp 2021-07-10 13:30:38 +03:00
Alexey Milovidov
588c31d9f5 Better messages 2021-07-10 11:18:06 +03:00
Alexey Milovidov
1f91c65aca Add error id to exceptions 2021-07-10 05:43:53 +03:00
vdimir
c01f4588b4
Validate prometheus metric name with regex 2021-07-09 19:12:26 +03:00
Alexander Tokmakov
1a470fb777 fix sequence_id in MySQL protocol 2021-07-07 20:03:28 +03:00
kssenii
0dda5b67c4 Fix set SQL_SELECT_LIMIT 2021-07-04 16:17:59 +03:00
Ivan Lezhankin
37439a8af6 Fix typos 2021-06-29 01:51:01 +03:00
Ivan Lezhankin
09b3db38f0 Don't create input stream for native data 2021-06-28 23:43:37 +03:00
Ivan Lezhankin
1bb41593d1 Merge remote-tracking branch 'upstream/master' into async-insert 2021-06-28 22:55:56 +03:00
sundy-li
d423d07a87 [mysql] fix mysql select user() return empty 2021-06-25 10:20:22 +08:00
Ivan Lezhankin
37365589ed Merge branch 'master' into async-insert 2021-06-17 16:57:45 +03:00
alexey-milovidov
04be5437d9
Merge pull request #25296 from abyss7/http-issues
Add settings for HTTP header limitations
2021-06-17 01:50:48 +03:00
alexey-milovidov
16931a661c
Update HTTPServerRequest.h 2021-06-17 01:50:06 +03:00
Maksim Kita
67e9b85951 Merge ext into common 2021-06-16 23:28:41 +03:00