Skip to content

Commit

Permalink
add to async get session as well (#3046)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuo-danswer authored Nov 4, 2024
1 parent 1d8e662 commit b6ecbbc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/danswer/db/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,12 @@ async def get_async_session_with_tenant(
try:
# Set the search_path to the tenant's schema
await session.execute(text(f'SET search_path = "{tenant_id}"'))
except Exception as e:
logger.error(f"Error setting search_path: {str(e)}")
if POSTGRES_IDLE_SESSIONS_TIMEOUT:
await session.execute(
f"SET SESSION idle_in_transaction_session_timeout = {POSTGRES_IDLE_SESSIONS_TIMEOUT}"
)
except Exception:
logger.exception("Error setting search_path.")
# You can choose to re-raise the exception or handle it
# Here, we'll re-raise to prevent proceeding with an incorrect session
raise
Expand Down

0 comments on commit b6ecbbc

Please sign in to comment.