mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fix memory accounting via HTTP interface
function perf_test() { time yes '127.1:8123/?wait_end_of_query=1' | head -n10000 | xargs -P10000 curl -s -d 'select 1' | grep -x -c 1 } function server() { local limit=$1 && shift clickhouse-server "$@" -- --max_server_memory_usage=$limit } perf_test: - before this patch with 1G limit: succeed only ~800 queries - after this patch with 1G limit: succeed ~8000 queries - before this patch with 10G limit: succeed only ~3000 queries - after this patch with 10G limit: succeed ~10000 queries Fixes: #11153
This commit is contained in:
parent
3f96bdaa24
commit
844960195d
@ -232,15 +232,12 @@ HTTPHandler::HTTPHandler(IServer & server_, const std::string & name)
|
||||
|
||||
|
||||
void HTTPHandler::processQuery(
|
||||
Context & context,
|
||||
Poco::Net::HTTPServerRequest & request,
|
||||
HTMLForm & params,
|
||||
Poco::Net::HTTPServerResponse & response,
|
||||
Output & used_output)
|
||||
{
|
||||
Context context = server.context();
|
||||
|
||||
CurrentThread::QueryScope query_scope(context);
|
||||
|
||||
LOG_TRACE(log, "Request URI: {}", request.getURI());
|
||||
|
||||
std::istream & istr = request.stream();
|
||||
@ -683,6 +680,11 @@ void HTTPHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Ne
|
||||
setThreadName("HTTPHandler");
|
||||
ThreadStatus thread_status;
|
||||
|
||||
/// Should be initialized before anything,
|
||||
/// For correct memory accounting.
|
||||
Context context = server.context();
|
||||
CurrentThread::QueryScope query_scope(context);
|
||||
|
||||
Output used_output;
|
||||
|
||||
/// In case of exception, send stack trace to client.
|
||||
@ -706,7 +708,7 @@ void HTTPHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Ne
|
||||
throw Exception("The Transfer-Encoding is not chunked and there is no Content-Length header for POST request", ErrorCodes::HTTP_LENGTH_REQUIRED);
|
||||
}
|
||||
|
||||
processQuery(request, params, response, used_output);
|
||||
processQuery(context, request, params, response, used_output);
|
||||
LOG_INFO(log, "Done processing query");
|
||||
}
|
||||
catch (...)
|
||||
|
@ -72,6 +72,7 @@ private:
|
||||
|
||||
/// Also initializes 'used_output'.
|
||||
void processQuery(
|
||||
Context & context,
|
||||
Poco::Net::HTTPServerRequest & request,
|
||||
HTMLForm & params,
|
||||
Poco::Net::HTTPServerResponse & response,
|
||||
|
Loading…
Reference in New Issue
Block a user