mirror of
https://github.com/dimitri/pgloader.git
synced 2026-02-10 00:41:34 +01:00
Review abnormal termination code path.
In case of an exceptional condition leading to termination of the pgloader program we tried to use log-message after the monitor should have been closed. Also the 0.3s delay to let latests messages out looks like a poor design. This patch attempts to remedy both the situation: refrain from using a closed down monitoring thread, and properly wait until it's done before returning to the shell. See #583.
This commit is contained in:
parent
352f4adc8d
commit
2341ef195d
@ -345,13 +345,17 @@
|
||||
|
||||
(source-definition-error (c)
|
||||
(declare (ignore c)) ; handler-bind printed it out
|
||||
(sleep 0.3) ; wait until monitor stops...
|
||||
;; wait until monitor stops...
|
||||
(let ((lp:*kernel* *monitoring-kernel*))
|
||||
(lp:end-kernel :wait t))
|
||||
(uiop:quit +os-code-error-bad-source+))
|
||||
|
||||
(condition (c)
|
||||
(declare (ignore c)) ; handler-bind printed it out
|
||||
(log-message :log "What I am doing here?")
|
||||
(sleep 0.3) ; wait until monitor stops...
|
||||
(format *error-output* "~%What I am doing here?~%~%")
|
||||
;; wait until monitor stops...
|
||||
(let ((lp:*kernel* *monitoring-kernel*))
|
||||
(lp:end-kernel :wait t))
|
||||
(uiop:quit +os-code-error+)))))
|
||||
|
||||
;; done.
|
||||
|
||||
@ -220,6 +220,7 @@
|
||||
(defpackage #:pgloader.monitor
|
||||
(:use #:cl #:pgloader.params #:pgloader.state)
|
||||
(:export #:with-monitor
|
||||
#:*monitoring-kernel*
|
||||
#:*monitoring-queue*
|
||||
#:log-message
|
||||
#:new-label
|
||||
|
||||
@ -12,6 +12,9 @@
|
||||
;;;
|
||||
(in-package :pgloader.monitor)
|
||||
|
||||
(defvar *monitoring-kernel* nil
|
||||
"Internal lparallel kernel to manage the separate monitor thread.")
|
||||
|
||||
(defvar *monitoring-queue* nil
|
||||
"Internal lparallel queue where to send and receive messages from.")
|
||||
|
||||
@ -130,8 +133,12 @@
|
||||
(*standard-output* . ,*standard-output*)
|
||||
(*summary-pathname* . ,*summary-pathname*)
|
||||
(*sections* . ',*sections*)))
|
||||
(lparallel:*kernel* (lp:make-kernel 1 :bindings bindings))
|
||||
(*monitoring-channel* (lp:make-channel)))
|
||||
(kernel (lp:make-kernel 1 :bindings bindings))
|
||||
(lparallel:*kernel* kernel))
|
||||
|
||||
;; make our kernel and channel visible from the outside
|
||||
(setf *monitoring-kernel* kernel
|
||||
*monitoring-channel* (lp:make-channel))
|
||||
|
||||
(lp:submit-task *monitoring-channel* #'monitor *monitoring-queue*)
|
||||
(send-event (make-start :start-logger start-logger))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user