From ece55ff29d3385ad7aec6556c12a2181cc9ec513 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 26 Nov 2023 10:02:47 -0500 Subject: [PATCH] add MARS connection for aioodbc on jenkins main we are getting a lot of connection busy with other results, which we assume is due to the thread-pool based approach of aioodbc not being very solid. MARS is described at: https://stackoverflow.com/questions/9017264/why-only-some-users-get-the-error-connection-is-busy-with-results-for-another https://learn.microsoft.com/en-us/sql/relational-databases/native-client/features/using-multiple-active-result-sets-mars?view=sql-server-ver16 not clear why the name of the parameter is different in those two articles. using a totally made up parameter doesn't raise any error, so it's not clear if this works at all. Change-Id: I8e437e9f46c1c070c5102a24d7d82a912e8b5145 --- lib/sqlalchemy/dialects/mssql/provision.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sqlalchemy/dialects/mssql/provision.py b/lib/sqlalchemy/dialects/mssql/provision.py index 096ae03fa5..2db3ee44f0 100644 --- a/lib/sqlalchemy/dialects/mssql/provision.py +++ b/lib/sqlalchemy/dialects/mssql/provision.py @@ -29,6 +29,9 @@ def generate_driver_url(url, driver, query_str): if driver not in ("pyodbc", "aioodbc"): new_url = new_url.set(query="") + if driver == "aioodbc": + new_url = new_url.update_query_dict({"MARS_Connection": "Yes"}) + if query_str: new_url = new_url.update_query_string(query_str) @@ -37,6 +40,7 @@ def generate_driver_url(url, driver, query_str): except exc.NoSuchModuleError: return None else: + print(f"NEW URL!!!!! {new_url}") return new_url -- 2.47.2