Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add null transaction metadata option #106

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cassandra/src/cassandra/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@
(with {:compaction
{:class compaction-strategy}}))))

(defn insert-record
[session {:keys [keyspace table columns]}]
(alia/execute session (use-keyspace (keyword keyspace)))
(alia/execute session (insert (keyword table)
(values columns)
(if-exists false))))

(defn close-cassandra
[cluster session]
(some-> session alia/shutdown (.get 10 TimeUnit/SECONDS))
Expand Down
11 changes: 11 additions & 0 deletions scalardb/src/scalardb/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
(def ^:private ^:const NUM_FAILURES_FOR_RECONNECTION 1000)
(def ^:const INITIAL_TABLE_ID 1)
(def ^:const DEFAULT_TABLE_COUNT 3)
(def ^:const DEFAULT_KEY_COUNT 10)

(def ^:private ^:const COORDINATOR "coordinator")
(def ^:private ^:const STATE_TABLE "state")
Expand Down Expand Up @@ -264,3 +265,13 @@
{:stats (independent-stats-checker)
:exceptions (checker/unhandled-exceptions)
:workload (independent-workload-checker workload-checker)})))

(defn setup-records-without-tx-metadata
[test keyspace table]
(let [cluster (alia/cluster {:contact-points (:nodes test)})
session (alia/connect cluster)]
(doseq [i (range DEFAULT_KEY_COUNT)]
(retry-when-exception
(fn [n] (c/insert-record session {:keyspace keyspace
:table table
:columns [[:id n] [:val 999]]}))[i]))))
5 changes: 3 additions & 2 deletions scalardb/src/scalardb/elle_append.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[jepsen.independent :as independent]
[jepsen.tests.cycle.append :as append]
[scalardb.core :as scalar :refer [INITIAL_TABLE_ID
DEFAULT_TABLE_COUNT]])
DEFAULT_TABLE_COUNT
DEFAULT_KEY_COUNT]])
(:import (com.scalar.db.api Get
Put)
(com.scalar.db.io IntValue
Expand Down Expand Up @@ -130,7 +131,7 @@

(defn- append-test
[opts]
(append/test {:key-count 10
(append/test {:key-count DEFAULT_KEY_COUNT
:min-txn-length 1
:max-txn-length 10
:max-writes-per-key 10
Expand Down
5 changes: 3 additions & 2 deletions scalardb/src/scalardb/elle_append_2pc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[jepsen.independent :as independent]
[jepsen.tests.cycle.append :as append]
[scalardb.core :as scalar :refer [INITIAL_TABLE_ID
DEFAULT_TABLE_COUNT]])
DEFAULT_TABLE_COUNT
DEFAULT_KEY_COUNT]])
(:import (com.scalar.db.api Get
Put)
(com.scalar.db.io IntValue
Expand Down Expand Up @@ -138,7 +139,7 @@

(defn- append-test
[opts]
(append/test {:key-count 10
(append/test {:key-count DEFAULT_KEY_COUNT
:min-txn-length 1
:max-txn-length 10
:max-writes-per-key 10
Expand Down
26 changes: 15 additions & 11 deletions scalardb/src/scalardb/elle_write_read.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[jepsen.independent :as independent]
[jepsen.tests.cycle.wr :as wr]
[scalardb.core :as scalar :refer [INITIAL_TABLE_ID
DEFAULT_TABLE_COUNT]])
DEFAULT_TABLE_COUNT
DEFAULT_KEY_COUNT]])
(:import (com.scalar.db.api Get
Put)
(com.scalar.db.io IntValue
Expand Down Expand Up @@ -79,12 +80,12 @@
(when (compare-and-set! (:table-id test) current-id next-id)
(info (str "Creating new tables for " next-id))
(doseq [i (range DEFAULT_TABLE_COUNT)]
(scalar/setup-transaction-tables test [{:keyspace KEYSPACE
:table (str TABLE
next-id
\_
i)
:schema SCHEMA}])))))))
(let [table (str TABLE next-id \_ i)]
(scalar/setup-transaction-tables test [{:keyspace KEYSPACE
:table table
:schema SCHEMA}])
(if (:use-null-tx-metadata test)
(scalar/setup-records-without-tx-metadata test KEYSPACE table)))))))))

(defrecord WriteReadClient [initialized?]
client/Client
Expand All @@ -96,9 +97,12 @@
(when (compare-and-set! initialized? false true)
(doseq [id (range (inc INITIAL_TABLE_ID))
i (range DEFAULT_TABLE_COUNT)]
(scalar/setup-transaction-tables test [{:keyspace KEYSPACE
:table (str TABLE id \_ i)
:schema SCHEMA}]))
(let [table (str TABLE id \_ i)]
(scalar/setup-transaction-tables test [{:keyspace KEYSPACE
:table table
:schema SCHEMA}])
(if (:use-null-tx-metadata test)
(scalar/setup-records-without-tx-metadata test KEYSPACE table))))
(scalar/prepare-transaction-service! test))))

(invoke! [_ test op]
Expand All @@ -125,7 +129,7 @@

(defn- write-read-gen
[]
(wr/gen {:key-count 10
(wr/gen {:key-count DEFAULT_KEY_COUNT
:min-txn-length 1
:max-txn-length 10
:max-writes-per-key 10}))
Expand Down
26 changes: 15 additions & 11 deletions scalardb/src/scalardb/elle_write_read_2pc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[jepsen.independent :as independent]
[jepsen.tests.cycle.wr :as wr]
[scalardb.core :as scalar :refer [INITIAL_TABLE_ID
DEFAULT_TABLE_COUNT]])
DEFAULT_TABLE_COUNT
DEFAULT_KEY_COUNT]])
(:import (com.scalar.db.api Get
Put)
(com.scalar.db.io IntValue
Expand Down Expand Up @@ -74,12 +75,12 @@
(when (compare-and-set! (:table-id test) current-id next-id)
(info (str "Creating new tables for " next-id))
(doseq [i (range DEFAULT_TABLE_COUNT)]
(scalar/setup-transaction-tables test [{:keyspace KEYSPACE
:table (str TABLE
next-id
\_
i)
:schema SCHEMA}])))))))
(let [table (str TABLE next-id \_ i)]
(scalar/setup-transaction-tables test [{:keyspace KEYSPACE
:table table
:schema SCHEMA}])
(if (:use-null-tx-metadata test)
(scalar/setup-records-without-tx-metadata test KEYSPACE table)))))))))

(defrecord WriteReadClient [initialized?]
client/Client
Expand All @@ -91,9 +92,12 @@
(when (compare-and-set! initialized? false true)
(doseq [id (range (inc INITIAL_TABLE_ID))
i (range DEFAULT_TABLE_COUNT)]
(scalar/setup-transaction-tables test [{:keyspace KEYSPACE
:table (str TABLE id \_ i)
:schema SCHEMA}]))
(let [table (str TABLE id \_ i)]
(scalar/setup-transaction-tables test [{:keyspace KEYSPACE
:table table
:schema SCHEMA}])
(if (:use-null-tx-metadata test)
(scalar/setup-records-without-tx-metadata test KEYSPACE table))))
(scalar/prepare-2pc-service! test))))

(invoke! [_ test op]
Expand Down Expand Up @@ -128,7 +132,7 @@

(defn- write-read-gen
[]
(wr/gen {:key-count 10
(wr/gen {:key-count DEFAULT_KEY_COUNT
:min-txn-length 1
:max-txn-length 10
:max-writes-per-key 10}))
Expand Down
5 changes: 4 additions & 1 deletion scalardb/src/scalardb/runner.clj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@

(cli/repeated-opt nil "--consistency-model CONSISTENCY_MODEL"
"consistency model to be checked"
["snapshot-isolation"])])
["snapshot-isolation"])

[nil "--use-null-tx-metadata" "Use null transaction metadata to test with existing tables."
:default false]])

(defn test-cmd
[]
Expand Down