From 05be63467cf027c31565cdeaf5fcc1a772497ba5 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Thu, 7 Dec 2023 19:40:09 +0100 Subject: [PATCH] MT#58395 increase session timeouts * set session wait_timeout to 600 seconds * in batch mode also the following session vars are set: - net_read_timeout = 600 - net_write_timeout = 600 Change-Id: Ie774f7b5776d07e5c424d0391a5a5ddf4af2d98d --- ngcp-update-db-schema | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ngcp-update-db-schema b/ngcp-update-db-schema index 4a96b874..05d62b1f 100755 --- a/ngcp-update-db-schema +++ b/ngcp-update-db-schema @@ -137,8 +137,7 @@ class Config: _prompt_is_shown: bool = False _interrupted: bool = False _not_replicated_was_applied: bool = False - _temp_sql_file: BufferedRandom = \ - tempfile.NamedTemporaryFile() # type: ignore + _temp_sql_file: BufferedRandom = None # type: ignore _run_cmd_mysql_options: List[str] = [] _scripts_dir_order: List[str] = ['init', 'base', 'diff'] @@ -404,6 +403,8 @@ def connect_db() -> Connection: # type: ignore error('unknown database connection scenario') shutdown(1) + db_conn.query('SET SESSION wait_timeout = 600;') + return db_conn @@ -828,6 +829,16 @@ def apply_revisions(revisions: Revisions) -> None: if mode == 'down': dir_specs.reverse() + if config.batch_mode: + config._temp_sql_file = tempfile.NamedTemporaryFile() # type: ignore + config._temp_sql_file.write( + str( + 'SET SESSION wait_timeout = 600;\n' + + 'SET SESSION net_read_timeout = 600;\n' + + 'SET SESSION net_write_timeout = 600;\n' + ).encode() + ) + for spec in dir_specs: sorted_revisions = sorted(revisions[spec].keys()) if mode == 'down':