From 5369ce16c8a9b3a30edc79adef636642c297083c Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Thu, 1 Aug 2019 16:51:24 -0400 Subject: [PATCH] cockroachdb: use CONFIGURE ZONE in set-replication-zone! Fixes https://github.com/cockroachdb/cockroach/issues/39185. Fixes https://github.com/cockroachdb/cockroach/issues/39208. Fixes https://github.com/cockroachdb/cockroach/issues/39209. Fixes https://github.com/cockroachdb/cockroach/issues/39210. Fixes https://github.com/cockroachdb/cockroach/issues/39212. Fixes https://github.com/cockroachdb/cockroach/issues/39214. Fixes https://github.com/cockroachdb/cockroach/issues/39215. Fixes https://github.com/cockroachdb/cockroach/issues/39217. Fixes https://github.com/cockroachdb/cockroach/issues/39216. Fixes https://github.com/cockroachdb/cockroach/issues/39218. Fixes https://github.com/cockroachdb/cockroach/issues/39219. Fixes https://github.com/cockroachdb/cockroach/issues/39220. Fixes https://github.com/cockroachdb/cockroach/issues/39221. Fixes https://github.com/cockroachdb/cockroach/issues/39222. Fixes https://github.com/cockroachdb/cockroach/issues/39223. Fixes https://github.com/cockroachdb/cockroach/issues/39224. Fixes https://github.com/cockroachdb/cockroach/issues/39226. Fixes https://github.com/cockroachdb/cockroach/issues/39225. Fixes https://github.com/cockroachdb/cockroach/issues/39227. Fixes https://github.com/cockroachdb/cockroach/issues/39228. Fixes https://github.com/cockroachdb/cockroach/issues/39229. Fixes https://github.com/cockroachdb/cockroach/issues/39230. Fixes https://github.com/cockroachdb/cockroach/issues/39231. Fixes https://github.com/cockroachdb/cockroach/issues/39234. Fixes https://github.com/cockroachdb/cockroach/issues/39233. Fixes https://github.com/cockroachdb/cockroach/issues/39235. Fixes https://github.com/cockroachdb/cockroach/issues/39236. Fixes https://github.com/cockroachdb/cockroach/issues/39238. Fixes https://github.com/cockroachdb/cockroach/issues/39237. The `cockroach zone` command was deprecated in https://github.com/cockroachdb/cockroach/pull/39177a. --- cockroachdb/project.clj | 1 - cockroachdb/src/jepsen/cockroach.clj | 2 +- cockroachdb/src/jepsen/cockroach/auto.clj | 29 +++++------------------ 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/cockroachdb/project.clj b/cockroachdb/project.clj index 410254f7f..2ef95c1cf 100644 --- a/cockroachdb/project.clj +++ b/cockroachdb/project.clj @@ -6,7 +6,6 @@ :dependencies [[org.clojure/clojure "1.8.0"] [jepsen "0.1.9-SNAPSHOT"] [org.clojure/java.jdbc "0.6.1"] - [circleci/clj-yaml "0.5.5"] [org.postgresql/postgresql "9.4.1211"]] :jvm-opts ["-Xmx12g" "-XX:+UseConcMarkSweepGC" diff --git a/cockroachdb/src/jepsen/cockroach.clj b/cockroachdb/src/jepsen/cockroach.clj index 1859ff7c9..d8437df5d 100644 --- a/cockroachdb/src/jepsen/cockroach.clj +++ b/cockroachdb/src/jepsen/cockroach.clj @@ -72,7 +72,7 @@ (jepsen/synchronize test) (when (= node (jepsen/primary test)) - (auto/set-replication-zone! ".default" + (auto/set-replication-zone! "default" {:range_min_bytes 1024 :range_max_bytes 1048576}) (info node "Creating database...") diff --git a/cockroachdb/src/jepsen/cockroach/auto.clj b/cockroachdb/src/jepsen/cockroach/auto.clj index 93195a21a..36d4fed0b 100644 --- a/cockroachdb/src/jepsen/cockroach/auto.clj +++ b/cockroachdb/src/jepsen/cockroach/auto.clj @@ -3,7 +3,6 @@ (:require [clojure.tools.logging :refer :all] [clojure.java.io :as io] [clojure.string :as str] - [clj-yaml.core :as yaml] [jepsen.util :as util] [jepsen [core :as jepsen] [control :as c :refer [|]]] @@ -100,29 +99,13 @@ [:-e ~@body] [:>> errlog (c/lit "2>&1")])))) -(defn replication-zone - "Gets the replication zone on a given node. With no args, fetches the default - zone." - ([] - (replication-zone ".default")) - ([name] - (yaml/parse-string - (c/cd working-path - (c/exec cockroach :zone :get name (when insecure :--insecure)))))) - (defn set-replication-zone! - "Sets the replication zone on the given node. Returns the new replication - zone." - [name zone] - (c/sudo cockroach-user - (-> (c/cd working-path - (c/exec :echo (yaml/generate-string zone) | - cockroach :zone :set - (when insecure :--insecure) - :--file=- - name)) - (str/replace #"UPDATE .+\n" "") - (yaml/parse-string)))) + "Sets the replication zone on the given node." + [zone config] + (csql! (str + "alter range " zone " configure zone using " + (str/join ", " + (map (fn [[k v]] (str (name k) " = " v)) config))))) (defn install-bumptime! "Install time adjusting binary"