This commit is contained in:
Nikita Taranov 2024-08-07 12:37:39 +01:00
parent 1f5c4101b2
commit 49871bacc1
3 changed files with 12 additions and 5 deletions

View File

@ -66,7 +66,6 @@ namespace Net
bool _firstRequest;
Poco::Timespan _keepAliveTimeout;
int _maxKeepAliveRequests;
HTTPServerParams::Ptr _params;
};

View File

@ -24,7 +24,6 @@ HTTPServerSession::HTTPServerSession(const StreamSocket & socket, HTTPServerPara
, _firstRequest(true)
, _keepAliveTimeout(pParams->getKeepAliveTimeout())
, _maxKeepAliveRequests(pParams->getMaxKeepAliveRequests())
, _params(pParams)
{
setTimeout(pParams->getTimeout());
}

View File

@ -1,5 +1,6 @@
import logging
import pytest
import random
import requests
from helpers.cluster import ClickHouseCluster
@ -24,19 +25,27 @@ def test_max_keep_alive_requests_on_user_side(start_cluster):
# In this test we have `keep_alive_timeout` set to one hour to never trigger connection reset by timeout, `max_keep_alive_requests` is set to 5.
# We expect server to close connection after each 5 requests. We detect connection reset by change in src port.
# So the first 5 requests should come from the same port, the following 5 requests should come from another port.
log_comments = []
for _ in range(10):
rand_id = random.randint(0, 1000000)
log_comment = f"test_requests_with_keep_alive_{rand_id}"
log_comments.append(log_comment)
log_comments = sorted(log_comments)
session = requests.Session()
for i in range(10):
session.get(
f"http://{node.ip_address}:8123/?query=select%201&log_comment=test_requests_with_keep_alive_{i}"
f"http://{node.ip_address}:8123/?query=select%201&log_comment={log_comments[i]}"
)
ports = node.query(
"""
f"""
SYSTEM FLUSH LOGS;
SELECT port
FROM system.query_log
WHERE log_comment like 'test_requests_with_keep_alive_%' AND type = 'QueryFinish'
WHERE log_comment IN ({", ".join(f"'{comment}'" for comment in log_comments)}) AND type = 'QueryFinish'
ORDER BY log_comment
"""
).split("\n")[:-1]