Improve Foreign Key error handling.

We don't know how to parse the PostgreSQL condition sent when there is a
fkey error... and the message would not contain the row number where that
error happened anyway.

At the moment it means that the retry-batch facility errors out for failing
to realize that NIL isn't a number on which we can do arithmetic, which in
itself in a little sad.

In this patch we install a condition handler that knows how to deal with
retry-batch failing, so that pgloader may try and continue rather than
appear locked to the user, when I suspect that the debugger is waiting for
input.

See #836, where that's the first half of the fix. The real fix is to handle
foreign key errors correctly of course.
This commit is contained in:
Dimitri Fontaine 2019-02-14 23:10:12 +01:00
parent 2cbf716112
commit 8eea90bb51

View File

@ -67,9 +67,13 @@
(log-message :error "PostgreSQL [~s] ~a" table-name condition)
;; clean the current transaction before retrying new ones
(let ((errors
(retry-batch table columns batch condition)))
(handler-case
(retry-batch table columns batch condition)
(condition (e)
(log-message :error "BUG: failed to retry-batch: ~a" e)
(batch-count batch)))))
(log-message :debug "retry-batch found ~d errors" errors)
(update-stats :data table :rows (- errors))))
(update-stats :data table :errs errors :rows (- errors))))
(postgresql-unavailable (condition)