 
 ;; FIXME: was to-timestamp redundant here and in store-report? others don't have it...
 
-(defn exec-deactivate-node [{:keys [id received payload]} start-time db]
+(defn exec-deactivate-node [{:keys [id received payload]} start-time db conn-status]
   (let [{:keys [certname producer_timestamp]} payload]
-    (jdbc/with-transacted-connection db
-      (when-not (scf-storage/certname-exists? certname)
-        (scf-storage/add-certname! certname))
-      (scf-storage/deactivate-node! certname producer_timestamp))
+    (jdbc/retry-with-monitored-connection
+     db conn-status :read-committed
+     (fn []
+       (when-not (scf-storage/certname-exists? certname)
+         (scf-storage/add-certname! certname))
+       (scf-storage/deactivate-node! certname producer_timestamp)))
     (log-command-processed-messsage id received start-time :deactivate-node certname)))
 
 ;; Report submission

    "configure expiration" (prep-configure-expiration cmd)
    "replace catalog inputs" (prep-replace-catalog-inputs cmd)))

(def supported-command?
  (comp (kitchensink/valset command-names) :command))

(defn supported-version? [command version]
  (contains? (get supported-command-versions command #{}) version))

(defn supported-command-version? [command-name [received-command-name received-version]]
  (boolean
   (and (= command-name received-command-name)
        (supported-version? command-name received-version))))

(defn exec-command
  "Takes a command object and processes it to completion. Dispatch is
   based on the command's name and version information"
  [{command-name :command version :version delete? :delete? :as command}
   db conn-status start]
  (condp supported-command-version? [command-name version]
    "replace catalog" (exec-replace-catalog command start db)
    "replace facts" (exec-replace-facts command start db)
    "store report" (exec-store-report command start db conn-status)
    "deactivate node" (exec-deactivate-node command start db)
    "configure expiration" (exec-configure-expiration command start db)
    "replace catalog inputs" (exec-replace-catalog-inputs command start db)))

(defn process-command!
  ;; only used by testing...

        not-exception? #(not (instance? Throwable %))
        attempt-exec (fn [db status]
                       (try
                         (attempt-exec-command cmd db status response-chan stats)
                         nil
                         (catch Throwable ex
                           ex)))]
