Project

General

Profile

Actions

Bug #21547

open

return certain database errors as 500 so they can be retried

Added by Peter Amstutz 2 months ago. Updated 9 days ago.

Status:
New
Priority:
Normal
Assigned To:
Category:
API
Target version:
Story points:
-

Description

Certain database errors represent transient errors. We should tell the client to retry the request by returning a 500 internal server error instead of 422 (which is the default behavior).

#<ActiveRecord::Deadlocked: PG::TRDeadlockDetected: ERROR: deadlock detected>

Rationale: The observed deadlocks in Arvados are conflicts between two statements (a lock ordering issue), so unwinding and retrying is a reasonable solution

#<ActiveRecord::StatementInvalid: PG::UnableToSend>

Rationale: It seems this gets thrown when the API server can't connect to the database.

Here's the list of postgres errors known to the PG gem:

https://github.com/ged/ruby-pg/blob/daec80f91b9519509ca1694a231f11a75cb43f7f/ext/errorcodes.def#L598

https://github.com/ged/ruby-pg/blob/daec80f91b9519509ca1694a231f11a75cb43f7f/ext/pg_errors.c#L88

Some other possible Exceptions to retry:

ConnectionBad
ConnectionException
ConnectionDoesNotExist
ConnectionFailure
TooManyConnections
CannotConnectNow
IdleSessionTimeout
ObjectInUse
LockNotAvailable
AdminShutdown
CrashShutdown

(There's a lot of connection related errors and I don't know the difference between them, but I included them all because it seems like those are very likely to be errors that occur through no fault of the client).


Subtasks 1 (1 open0 closed)

Task #21554: ReviewNewTom CleggActions

Related issues

Related to Arvados - Bug #21540: occasional container_requests deadlockNewActions
Actions

Also available in: Atom PDF