mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-08 07:16:58 +02:00
Refactor PostgreSQL conditions.
Use a single deftype postgresql-unavailable rather than copy/pasting the same list of conditions in several places.
This commit is contained in:
parent
60c1146e18
commit
1e436555a8
@ -362,6 +362,7 @@
|
||||
#:pgsql-execute
|
||||
#:pgsql-execute-with-timing
|
||||
#:pgsql-connect-and-execute-with-timing
|
||||
#:postgresql-unavailable
|
||||
|
||||
;; postgresql schema facilities
|
||||
#:truncate-tables
|
||||
|
@ -48,6 +48,22 @@
|
||||
(defvar *pgsql-client-key* "~/.postgresql/postgresql.key"
|
||||
"File where to read the PostgreSQL Client Side SSL Private Key.")
|
||||
|
||||
;;;
|
||||
;;;
|
||||
;;;
|
||||
(deftype postgresql-unavailable ()
|
||||
"It might happen that PostgreSQL becomes unavailable in the middle of
|
||||
our processing: it being restarted is an example."
|
||||
`(or
|
||||
cl-postgres-error::server-shutdown
|
||||
cl-postgres-error::admin-shutdown
|
||||
cl-postgres-error::crash-shutdown
|
||||
cl-postgres-error::operator-intervention
|
||||
cl-postgres-error::cannot-connect-now
|
||||
cl-postgres-error::database-connection-error
|
||||
cl-postgres-error::database-connection-lost
|
||||
cl-postgres-error::database-socket-error))
|
||||
|
||||
;;;
|
||||
;;; We need to distinguish some special cases of PostgreSQL errors within
|
||||
;;; Class 53 — Insufficient Resources: in case of "too many connections" we
|
||||
@ -141,15 +157,7 @@
|
||||
appropriate log level."
|
||||
`(handler-bind
|
||||
(((and cl-postgres:database-error
|
||||
(not (or
|
||||
cl-postgres-error::server-shutdown
|
||||
cl-postgres-error::admin-shutdown
|
||||
cl-postgres-error::crash-shutdown
|
||||
cl-postgres-error::operator-intervention
|
||||
cl-postgres-error::cannot-connect-now
|
||||
cl-postgres-error::database-connection-error
|
||||
cl-postgres-error::database-connection-lost
|
||||
cl-postgres-error::database-socket-error)))
|
||||
(not postgresql-unavailable))
|
||||
#'(lambda (e)
|
||||
(log-message :error "~a" e)))
|
||||
(cl-postgres:postgresql-warning
|
||||
@ -249,16 +257,7 @@
|
||||
(pomo:with-transaction ()
|
||||
(pgsql-execute-with-timing section label sql :count count)))
|
||||
|
||||
((or
|
||||
cl-postgres-error::server-shutdown
|
||||
cl-postgres-error::admin-shutdown
|
||||
cl-postgres-error::crash-shutdown
|
||||
cl-postgres-error::operator-intervention
|
||||
cl-postgres-error::cannot-connect-now
|
||||
cl-postgres-error::database-connection-error
|
||||
cl-postgres-error::database-connection-lost
|
||||
cl-postgres-error::database-socket-error)
|
||||
(condition)
|
||||
(postgresql-unavailable (condition)
|
||||
|
||||
(log-message :error "~a" condition)
|
||||
(log-message :error "Reconnecting to PostgreSQL")
|
||||
|
@ -87,16 +87,7 @@
|
||||
(log-message :error "~a" condition)
|
||||
(retry-batch table columns batch batch-rows condition))))
|
||||
|
||||
((or
|
||||
cl-postgres-error::server-shutdown
|
||||
cl-postgres-error::admin-shutdown
|
||||
cl-postgres-error::crash-shutdown
|
||||
cl-postgres-error::operator-intervention
|
||||
cl-postgres-error::cannot-connect-now
|
||||
cl-postgres-error::database-connection-error
|
||||
cl-postgres-error::database-connection-lost
|
||||
cl-postgres-error::database-socket-error)
|
||||
(condition)
|
||||
(postgresql-unavailable (condition)
|
||||
|
||||
(log-message :error "~a" condition)
|
||||
(log-message :error "Copy Batch reconnecting to PostgreSQL")
|
||||
|
@ -173,16 +173,7 @@
|
||||
:section :post
|
||||
:label "Install Comments"))
|
||||
|
||||
((or
|
||||
cl-postgres-error::server-shutdown
|
||||
cl-postgres-error::admin-shutdown
|
||||
cl-postgres-error::crash-shutdown
|
||||
cl-postgres-error::operator-intervention
|
||||
cl-postgres-error::cannot-connect-now
|
||||
cl-postgres-error::database-connection-error
|
||||
cl-postgres-error::database-connection-lost
|
||||
cl-postgres-error::database-socket-error)
|
||||
(condition)
|
||||
(postgresql-unavailable (condition)
|
||||
|
||||
(log-message :error "~a" condition)
|
||||
(log-message :error
|
||||
|
Loading…
Reference in New Issue
Block a user