Skip to content

Commit b6ecbbc

Browse files
authored
add to async get session as well (onyx-dot-app#3046)
1 parent 1d8e662 commit b6ecbbc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backend/danswer/db/engine.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,12 @@ async def get_async_session_with_tenant(
310310
try:
311311
# Set the search_path to the tenant's schema
312312
await session.execute(text(f'SET search_path = "{tenant_id}"'))
313-
except Exception as e:
314-
logger.error(f"Error setting search_path: {str(e)}")
313+
if POSTGRES_IDLE_SESSIONS_TIMEOUT:
314+
await session.execute(
315+
f"SET SESSION idle_in_transaction_session_timeout = {POSTGRES_IDLE_SESSIONS_TIMEOUT}"
316+
)
317+
except Exception:
318+
logger.exception("Error setting search_path.")
315319
# You can choose to re-raise the exception or handle it
316320
# Here, we'll re-raise to prevent proceeding with an incorrect session
317321
raise

0 commit comments

Comments
 (0)