Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
(ns jepsen.pg
(:use [clojure.set :only [union difference]]
jepsen.set-app)
(:require [clojure.java.jdbc :as j]
[clojure.java.jdbc.sql :as s]
[clojure.string :as string]))
(defn connect [host]
{:subprotocol "postgresql"
:subname (str "//" host "/jepsen")
:user "jepsen"
:password "jepsen"})
(def db-lock (Object.))
(defn pg-app
[opts]
(let [table (get opts :coll "set_app")
db (connect "n1")]
(reify SetApp
(setup [app]
(locking db-lock
(teardown app)
(j/with-connection db
(j/create-table
table
[:id "serial primary key"]
[:element :int "not null"]))
(assert (zero? (-> db
(j/query (s/select "count(*)" table))
first
:count)))))
(add [app element]
(j/db-transaction [db db]
(j/insert! db table {:element element})))
(results [app]
(j/query db (s/select * table)
:row-fn :element))
(teardown [app]
(try
(j/with-connection db
(j/drop-table table))
(catch Exception _
nil))))))
3 :ok
0 :ok
1 :ok
4 :ok
2 :ok
8 :ok
5 :ok
6 :ok
9 :ok
7 :ok
13 :ok
10 :ok
12 :ok
14 :ok
11 :ok
18 :ok
19 :ok
17 :ok
15 :ok
16 :ok
24 :ok
23 :ok
20 :ok
29 :ok
22 :ok
28 :ok
21 :ok
25 :ok
26 :ok
34 :ok
27 :ok
31 :ok
33 :ok
30 :ok
39 :ok
32 :ok
38 :ok
36 :ok
35 :ok
44 :ok
43 :ok
41 :ok
40 :ok
37 :ok
48 :ok
49 :ok
42 :ok
45 :ok
46 :ok
53 :ok
54 :ok
47 :ok
50 :ok
51 :ok
58 :ok
52 :ok
55 :ok
59 :ok
56 :ok
63 :ok
57 :ok
64 :ok
61 :ok
62 :ok
60 :ok
68 :ok
69 :ok
66 :ok
73 :ok
71 :ok
67 :ok
65 :ok
74 :ok
78 :ok
72 :ok
70 :ok
79 :ok
76 :ok
84 :ok
75 :ok
81 :ok
83 :ok
77 :ok
89 :ok
82 :ok
80 :ok
94 :ok
86 :ok
88 :ok
87 :ok
85 :ok
99 :ok
93 :ok
91 :ok
90 :ok
92 :ok
104 FATAL: remaining connection slots are reserved for non-replication superuser connections
95 FATAL: remaining connection slots are reserved for non-replication superuser connections
98 FATAL: remaining connection slots are reserved for non-replication superuser connections
97 FATAL: remaining connection slots are reserved for non-replication superuser connections
96 FATAL: remaining connection slots are reserved for non-replication superuser connections
109 FATAL: remaining connection slots are reserved for non-replication superuser connections
102 FATAL: remaining connection slots are reserved for non-replication superuser connections
100 FATAL: remaining connection slots are reserved for non-replication superuser connections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.