mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-05 08:07:05 +00:00
Fix database query error handling.
Previously, query errors returned \None\. That behavior was changed to raise all errors except the query plan cache issue. Raising those errors forces the request down a more expensive fallback path, which can trigger CPU spikes.
This commit is contained in:
parent
f2cb31a45e
commit
0fda0f9aa2
1 changed files with 9 additions and 5 deletions
|
|
@ -2284,10 +2284,9 @@ class PrismaClient:
|
|||
sql_query: SQL query string to execute
|
||||
|
||||
Returns:
|
||||
Query result or None
|
||||
|
||||
Raises:
|
||||
Original exception if not a cached plan error
|
||||
Query result or None. Returns None on any DB error other than
|
||||
the cached-plan error (which is retried once) to preserve
|
||||
previous behavior where token lookup failures did not raise.
|
||||
"""
|
||||
try:
|
||||
return await self.db.query_first(query=sql_query)
|
||||
|
|
@ -2307,7 +2306,12 @@ class PrismaClient:
|
|||
)
|
||||
return await self.db.query_first(query=sql_query_retry)
|
||||
else:
|
||||
raise
|
||||
# Preserve previous behavior: do not raise on other DB errors;
|
||||
# return None so caller treats as "no token found" (e.g. 401).
|
||||
verbose_proxy_logger.debug(
|
||||
"Token lookup query failed: %s", error_str
|
||||
)
|
||||
return None
|
||||
|
||||
@backoff.on_exception(
|
||||
backoff.expo,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue