              (catch Exception e
                ;; do nothing. sleep interrupted by notify
                ))
-            (recur conf (.get (:continue conf))))
+            (recur conf
+                   (.get (:continue conf))
+                   (inc times)))
           (do
             (log/infof "db-watcher[%s] terminating" dbname)))))))
 

(defn process-row-changes [conf conn]
  ;; obtain mutex, nowait
  ;; TODO: handle failure to get lock (probably an exception)
  (let [dbname        (-> conf :dbconf :subname)]
    (jdbc/transaction
     (if (obtain-mutex conf conn)
       (do

        watcher-config {:conf     conf
                        :error    (atom nil)
                        :continue control-atom
                        :dbconf   conf
                        :sleep-time (:sleep-time conf)}
        watcher-thread (Thread. (fn [] (db-watcher watcher-config)))]
    (swap! db-watchers assoc wname (assoc watcher-config :thread watcher-thread))
    (.start watcher-thread)))
