         state (assoc peer-state :state :dead)]
     (:node (extensions/create-at sync :peer-state (:id peer-state) state))))
 
+
+;;; Ensure "tasks" always has the same order.
+;;; Ensure that node creation is idempotent.
 (defmethod extensions/plan-job ZooKeeper
   [sync job-id tasks catalog workflow]
   (let [catalog-node (:node (extensions/create-at sync :catalog job-id catalog))

                     :peer-node peer-node}]
        (throw (ex-info "Failed to acknowledge task" err-val))))))

(defmethod extensions/revoke-offer ZooKeeper
  [sync ack-node]
  (let [ack-data (extensions/read-node sync ack-node)

            job-log-record {:job (:task/job-id task) :task (:task/id task)}]
        (:node (extensions/create sync :job-log job-log-record))))))

;;; Allow :active -> :active peer state transition
;;; Exception can stay, it will just be thrown even though the peer acked
;;; on the last available coordinator.
(defmethod extensions/ack ZooKeeper
  [sync ack-node]
  (let [ack-data (extensions/read-node sync ack-node)
