tarantool / jepsen.tarantool

Jepsen tests for Tarantool
https://www.tarantool.io/en/
Other
7 stars 0 forks source link

Close connections to DBMS #35

Open ligurio opened 4 years ago

ligurio commented 4 years ago

Right now connections in a client stay opened and we should close them. Unfortunatley there is no arbitrary method in next.jdbc to close a connection.

See discussion: https://clojureverse.org/t/how-to-manage-database-connection-in-clojure/5067/8

Possible solution in https://www.github.com/jepsen-io/redis/tree/master/src%2Fjepsen%2Fredis%2Fclient.clj

(defn close!
  "Closes a connection to a node."
  [^java.io.Closeable conn]
  (.close (:pool conn)))

Another approach is to use with-open, that will cleanup connection automatically - https://cljdoc.org/d/seancorfield/next.jdbc/1.1.610/doc/getting-started/prepared-statements

It is possible to log connect/disconnect operations in Tarantool with triggers - https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_session/#box-session-on-connect:

function log_connect ()
  local log = require('log')
  local m = 'Connection. user=' .. box.session.user() .. ' id=' .. box.session.id()
  log.info(m)
end

function log_disconnect ()
  local log = require('log')
  local m = 'Disconnection. user=' .. box.session.user() .. ' id=' .. box.session.id()
  log.info(m)
end

box.session.on_connect(log_connect)
box.session.on_disconnect(log_disconnect)

Logging shows that Jepsen performs about 500 connects in test Counter, i.e. one connection per operation.