Updated list of retryable errors and updated both tests to use same azure_query function

This commit is contained in:
Smita Kulkarni 2023-08-01 12:39:36 +02:00
parent ed40a15e82
commit ce4f273be1
2 changed files with 5 additions and 20 deletions

View File

@ -7,6 +7,7 @@ import pytest
from helpers.cluster import ClickHouseCluster
from helpers.utility import generate_values, replace_config, SafeThread
from azure.storage.blob import BlobServiceClient
from test_storage_azure_blob_storage.test import azure_query
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
@ -38,28 +39,10 @@ def cluster():
cluster.shutdown()
# Note: use this for selects and inserts and create table queries.
# Note: use azure_query for selects and inserts and create table queries.
# For inserts there is no guarantee that retries will not result in duplicates.
# But it is better to retry anyway because 'Connection was closed by the server' error
# But it is better to retry anyway because connection related errors
# happens in fact only for inserts because reads already have build-in retries in code.
def azure_query(node, query, try_num=3, settings={}):
for i in range(try_num):
try:
return node.query(query, settings=settings)
except Exception as ex:
retriable_errors = [
"DB::Exception: Azure::Core::Http::TransportException: Connection was closed by the server while trying to read a response"
]
retry = False
for error in retriable_errors:
if error in str(ex):
retry = True
logging.info(f"Try num: {i}. Having retriable error: {ex}")
break
if not retry or i == try_num - 1:
raise Exception(ex)
continue
def create_table(node, table_name, **additional_settings):
settings = {

View File

@ -43,6 +43,8 @@ def azure_query(node, query, try_num=10, settings={}):
retriable_errors = [
"DB::Exception: Azure::Core::Http::TransportException: Connection was closed by the server while trying to read a response",
"DB::Exception: Azure::Core::Http::TransportException: Connection closed before getting full response or response is less than expected",
"DB::Exception: Azure::Core::Http::TransportException: Connection was closed by the server while trying to read a response",
"DB::Exception: Azure::Core::Http::TransportException: Error while polling for socket ready read",
]
retry = False
for error in retriable_errors: