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.
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
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-statementsIt 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:
Logging shows that Jepsen performs about 500 connects in test Counter, i.e. one connection per operation.