Skip to content

Commit

Permalink
Fixed port issue 2
Browse files Browse the repository at this point in the history
  • Loading branch information
qvad committed Dec 19, 2024
1 parent 3d385e7 commit 7adc83d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion yugabyte/src/yugabyte/auto.clj
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
(ycql.client/await-setup node)

:ysql
(ysql.client/check-setup-successful node))
(ysql.client/check-setup-successful node test))

:started)

Expand Down
24 changes: 14 additions & 10 deletions yugabyte/src/yugabyte/ysql/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
(def conn-isolation-level "Default isolation level for connections"
Connection/TRANSACTION_SERIALIZABLE)

(def ysql-port 5431)
(defn ysql-port
[test]
(if (:connection-manager test)
5431
5433))

(def max-retry-attempts "Maximum number of attempts to be performed by with-retry" 30)
(def max-delay-between-retries-ms "Maximum delay between retries for with-retry" 200)
Expand All @@ -28,12 +32,12 @@

(defn db-spec
"Assemble a JDBC connection specification for a given Jepsen node."
[dbname user password node]
[dbname user password node port]
{:dbtype "yugabytedb"
:dbname dbname
:classname "com.yugabyte.Driver"
:host (name node)
:port ysql-port
:port port
:user user
:password password
:loginTimeout (/ default-timeout 1000)
Expand Down Expand Up @@ -111,13 +115,13 @@

(defn open-conn
"Opens a connection to the given node."
[dbname user password node]
[dbname user password node port]
(util/timeout default-timeout
(throw+ {:type :connection-timed-out
:node node})
(info "Connection" dbname)
(util/retry 0.1
(let [spec (db-spec dbname user password node)
(let [spec (db-spec dbname user password node port)
conn (j/get-connection spec)
spec' (j/add-connection spec conn)]
(.setTransactionIsolation conn conn-isolation-level)
Expand All @@ -137,20 +141,20 @@
"Connects to the YSQL interface and immediately disconnects. YB just...
doesn't accept connections sometimes, so we use this to give up on the setup
process if the cluster looks broken. Hack hack hack."
[node]
[node test]
(try+
(let [conn (open-conn "postgres" "postgres" "" node)]
(let [conn (open-conn "postgres" "postgres" "" node (ysql-port test))]
(close-conn conn))
(catch [:type :connection-timed-out] e
(throw+ {:type :jepsen.db/setup-failed}))))

(defn conn-wrapper
"Constructs a network client for a node, and opens it"
[node]
[node test]
(rc/open!
(rc/wrapper
{:name node
:open (partial open-conn "jepsen" "jepsen" "jepsen" node)
:open (partial open-conn "jepsen" "jepsen" "jepsen" node (ysql-port test))
:close close-conn
; Do not log intermediate reconnection errors (if the reconnect fails, we'll still get it)
:log? false})))
Expand Down Expand Up @@ -432,7 +436,7 @@
client/Client

(open! [~'this ~'test ~'node]
(assoc ~'this :conn-wrapper (conn-wrapper ~'node)))
(assoc ~'this :conn-wrapper (conn-wrapper ~'node ~'test)))

(setup! [~'this ~'test]
(once-per-cluster
Expand Down

0 comments on commit 7adc83d

Please sign in to comment.