            (java.time Duration)
            (java.util UUID)
            (java.util.concurrent Executors ExecutorService TimeUnit)
-           (org.postgresql PGConnection)))
+           (org.postgresql PGConnection)
+           (org.postgresql.util PSQLException)))
 
 (defn- process-changes! [conn state had-changes?]
   (if-some [change (gis-db/next-unprocessed-change conn)]

      (notify)
      (loop []
        ;; getNotifications is not interruptible, so it will take up to `timeout` for this loop to exit
        (let [notifications (.getNotifications pg-conn (.toMillis timeout))]
          (when-not (.isInterrupted (Thread/currentThread))
            (doseq [_ notifications]
              (notify))

           (.submit ^Callable (until-interrupted
                               (executors/safe-task
                                #(listen-for-gis-changes refresh-async!)))))
  ;; XXX: not awaiting termination, because PGConnection.getNotifications() is not interruptible
  :stop (.shutdownNow ^ExecutorService notified-refresh))
