Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create a new connection for each request #96

Open
Totktonada opened this issue Nov 1, 2021 · 0 comments
Open

Don't create a new connection for each request #96

Totktonada opened this issue Nov 1, 2021 · 0 comments

Comments

@Totktonada
Copy link
Member

Since our tests are time bounded, creating a connection eats a time that can be used to give more dense workload to tarantool.

I didn't investigated the code much against this question, but I see the problem in the bank-lua test:

:transfer
(let [{:keys [from to amount]} (:value op)
con (cl/open (first (db/primaries test)) test)
table (clojure.string/upper-case table-name)
r (-> con
(sql/query [(str "SELECT _WITHDRAW('" table "'," from "," to "," amount ")")])
first
:COLUMN_1)]
(if (false? r)
(assoc op :type :fail, :value {:from from :to to :amount amount})
(assoc op :type :ok))))))

(Consider cl/open.)

Moreover, the (db/primaries test) call also creates its own connection and performs a request:

(defn primary
[node]
(let [conn (open node test)
leader (:COLUMN_1 (first (sql/query conn ["SELECT _LEADER()"])))]
;(assert leader)
leader))

How it should work, I think:

  • We should keep the connection until it dies. In case of several instances (of a replicaset), don't know: either current one or all. The latter seems better.
  • We should request leadership information using the existing connection / connection pool.
  • We should NOT renew a leader each time: instead, do it when the leader is gone.
    • If the instance becomes unavailable.
    • For write requests we can catch an error about the read-only state.
    • For read requests, which should be executed on a leader (if there are such cases), we should implement some server side check, whether the node that executes a request is a leader.
  • Re-create died connections or configure tarantool-java to overcome long unavailability, but still reconnect quite fast.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant