public
Last active

  • Download Gist
gistfile1.clj
Clojure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
(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))))))
gistfile2.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.