From 2d66a5c393cf7b42309b82050e197ad2f1709934 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 13 Mar 2021 11:29:40 +0300 Subject: [PATCH] Fix hang check for 00966_live_view_watch_events_http If INSERT was failed then WATCH EVENTS will hang: 2021.03.12 23:45:33.666223 [ 1901 ] {} DynamicQueryHandler: Request URI: /?allow_experimental_live_view=1&query=WATCH%20test.lv%20EVENTS ... 2021.03.12 23:45:34.119465 [ 35492 ] {55f2c8ec-df9f-4e97-9acc-385ed5b5fde2} executeQuery: Code: 241, e.displayText() = DB::Exception: Memory limit (for user) exceeded: would use 153.99 MiB (attempt to allocate chunk of 4194729 bytes), maximum: 150.00 MiB (version 21.4.1.6239) (from [::1]:43910) (in query: INSERT INTO test.mt VALUES ), Stack trace (when copying this message, always include the lines below): ... Hung check: elapsed: 597.835824299 is_cancelled: 0 query: WATCH test.lv EVENTS thread_ids: [1901] gdb: Thread 133 (Thread 0x7f26ac95b700 (LWP 1901)): 0 0x00007f2793d447b1 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0 1 0x0000000008cbd5c5 in __tsan::call_pthread_cancel_with_cleanup(int (*)(void*, void*, void*), void*, void*, void*, void (*)(void*), void*) () 2 0x0000000008c4f134 in cond_wait(__tsan::ThreadState*, unsigned long, __tsan::ScopedInterceptor*, int (*)(void*, void*, void*), void*, void*, void*) () 3 0x0000000008c4f339 in pthread_cond_timedwait () 4 0x000000001831c8b6 in std::__1::__libcpp_condvar_timedwait (__cv=0x7b5801053520, __m=0x189, __ts=0x7f26ac9132b8) at ../contrib/libcxx/include/__threading_support:442 5 std::__1::condition_variable::__do_timed_wait (this=0x7b5801053520, lk=..., tp=...) at ../contrib/libcxx/src/condition_variable.cpp:74 6 0x00000000134fe7f2 in std::__1::condition_variable::wait_for > (this=this@entry=0x7b5801053520, __lk=..., __d=...) at ../contrib/libcxx/include/__mutex_base:462 7 0x00000000134fe2c9 in DB::LiveViewEventsBlockInputStream::tryReadImpl (this=this@entry=0x7b5c0070ff98, blocking=false) at ../src/Storages/LiveView/LiveViewEventsBlockInputStream.h:180 8 0x00000000134fd6e4 in DB::LiveViewEventsBlockInputStream::readImpl (this=0x189) at ../src/Storages/LiveView/LiveViewEventsBlockInputStream.h:115 9 0x0000000012285593 in DB::IBlockInputStream::read (this=0x7b5c0070ff98) at ../src/DataStreams/IBlockInputStream.cpp:58 10 0x00000000122afc7e in DB::copyDataImpl const&, std::__1::function const&>(DB::IBlockInputStream&, DB::IBlockOutputStream&, std::__1::function const&, std::__1::function const&) (from=..., to=..., is_cancelled=..., progress=...) at ../src/DataStreams/copyData.cpp:26 11 0x00000000122af8e1 in DB::copyData(DB::IBlockInputStream&, DB::IBlockOutputStream&, std::__1::function const&, std::__1::function const&) (from=..., to=..., is_cancelled=..., progress=...) at ../src/DataStreams/copyData.cpp:73 12 0x0000000012cfc5e2 in DB::executeQuery(DB::ReadBuffer&, DB::WriteBuffer&, bool, DB::Context&, std::__1::function, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&)>) (istr=..., ostr=..., allow_into_outfile=false, context=..., set_result_details=...) at ../src/Interpreters/executeQuery.cpp:1033 13 0x000000001357941d in DB::HTTPHandler::processQuery (this=this@entry=0x7b1c006f41b0, context=..., request=..., params=..., response=..., used_output=..., query_scope=...) at ../src/Server/HTTPHandler.cpp:772 14 0x000000001357c507 in DB::HTTPHandler::handleRequest (this=, request=..., response=...) at ../src/Server/HTTPHandler.cpp:910 15 0x00000000135f3081 in DB::HTTPServerConnection::run (this=) at ../src/Server/HTTP/HTTPServerConnection.cpp:48 16 0x00000000161f9e73 in Poco::Net::TCPServerConnection::start (this=0x7b8c01554000) at ../contrib/poco/Net/src/TCPServerConnection.cpp:43 17 0x00000000161fa59f in Poco::Net::TCPServerDispatcher::run (this=) at ../contrib/poco/Net/src/TCPServerDispatcher.cpp:113 18 0x0000000016361732 in Poco::PooledThread::run (this=) at ../contrib/poco/Foundation/src/ThreadPool.cpp:199 19 0x000000001635fcd0 in Poco::(anonymous namespace)::RunnableHolder::run (this=) at ../contrib/poco/Foundation/src/Thread.cpp:55 20 0x000000001635e4d8 in Poco::ThreadImpl::runnableEntry (pThread=0x7b5400082538) at ../contrib/poco/Foundation/src/Thread_POSIX.cpp:345 21 0x0000000008c4e36d in __tsan_thread_start_func () 22 0x00007f2793d3d609 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 23 0x00007f2793c64293 in clone () from /lib/x86_64-linux-gnu/libc.so.6 Cc: @vzakaznikov --- .../00966_live_view_watch_events_http.py | 19 +++++++++--------- .../0_stateless/00967_live_view_watch_http.py | 20 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/queries/0_stateless/00966_live_view_watch_events_http.py b/tests/queries/0_stateless/00966_live_view_watch_events_http.py index 3d407ec5602..1c00a5d1236 100755 --- a/tests/queries/0_stateless/00966_live_view_watch_events_http.py +++ b/tests/queries/0_stateless/00966_live_view_watch_events_http.py @@ -28,13 +28,14 @@ with client(name='client1>', log=log) as client1: client1.expect(prompt) - with http_client({'method':'GET', 'url': '/?allow_experimental_live_view=1&query=WATCH%20test.lv%20EVENTS'}, name='client2>', log=log) as client2: - client2.expect('.*1\n') - client1.send('INSERT INTO test.mt VALUES (1),(2),(3)') + try: + with http_client({'method':'GET', 'url': '/?allow_experimental_live_view=1&query=WATCH%20test.lv%20EVENTS'}, name='client2>', log=log) as client2: + client2.expect('.*1\n') + client1.send('INSERT INTO test.mt VALUES (1),(2),(3)') + client1.expect(prompt) + client2.expect('.*2\n') + finally: + client1.send('DROP TABLE test.lv') + client1.expect(prompt) + client1.send('DROP TABLE test.mt') client1.expect(prompt) - client2.expect('.*2\n') - - client1.send('DROP TABLE test.lv') - client1.expect(prompt) - client1.send('DROP TABLE test.mt') - client1.expect(prompt) diff --git a/tests/queries/0_stateless/00967_live_view_watch_http.py b/tests/queries/0_stateless/00967_live_view_watch_http.py index d26bb5402e7..c41b9f0c861 100755 --- a/tests/queries/0_stateless/00967_live_view_watch_http.py +++ b/tests/queries/0_stateless/00967_live_view_watch_http.py @@ -27,14 +27,14 @@ with client(name='client1>', log=log) as client1: client1.send('CREATE LIVE VIEW test.lv AS SELECT sum(a) FROM test.mt') client1.expect(prompt) - - with http_client({'method':'GET', 'url':'/?allow_experimental_live_view=1&query=WATCH%20test.lv'}, name='client2>', log=log) as client2: - client2.expect('.*0\t1\n') - client1.send('INSERT INTO test.mt VALUES (1),(2),(3)') + try: + with http_client({'method':'GET', 'url':'/?allow_experimental_live_view=1&query=WATCH%20test.lv'}, name='client2>', log=log) as client2: + client2.expect('.*0\t1\n') + client1.send('INSERT INTO test.mt VALUES (1),(2),(3)') + client1.expect(prompt) + client2.expect('.*6\t2\n') + finally: + client1.send('DROP TABLE test.lv') + client1.expect(prompt) + client1.send('DROP TABLE test.mt') client1.expect(prompt) - client2.expect('.*6\t2\n') - - client1.send('DROP TABLE test.lv') - client1.expect(prompt) - client1.send('DROP TABLE test.mt') - client1.expect(prompt)