Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/memos/graph_dbs/polardb.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,13 @@ def _get_connection(self):
if not self._semaphore.acquire(timeout=timeout):
logger.warning(f"Timeout waiting for connection slot ({timeout}s)")
raise RuntimeError(
f"Connection pool busy: could not acquire a slot within {timeout}s (all connections in use)."
f"Connection pool busy: acquire a slot within {timeout}s (all connections in use)."
)
logger.info(
"Connection pool usage: %s/%s",
self.connection_pool.maxconn - self._semaphore._value,
self.connection_pool.maxconn,
)
conn = None
broken = False

Expand All @@ -264,7 +269,7 @@ def _get_connection(self):
logger.debug(f"Acquired connection {id(conn)} from pool")
conn.autocommit = True
with conn.cursor() as cur:
cur.execute("SELECT 1")
cur.execute(f'SET search_path = {self.db_name}_graph, ag_catalog, "$user", public;')
yield conn
except Exception as e:
broken = True
Expand Down Expand Up @@ -1777,6 +1782,7 @@ def search_by_fulltext(
)
where_clause_cte = f"WHERE {' AND '.join(where_with_q)}" if where_with_q else ""
query = f"""
/*+ Set(max_parallel_workers_per_gather 0) */
WITH q AS (SELECT to_tsquery('{tsquery_config}', %s) AS fq)
SELECT {select_cols}
FROM "{self.db_name}_graph"."Memory" m
Expand Down