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

Added random timeout for pessimistic locking append tests #107

Merged
merged 4 commits into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions yugabyte/src/yugabyte/ysql/append.clj
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@

(defn append-primary!
"Writes a key based on primary key."
[geo-partitioning conn table row col v]
(let [r (c/execute! conn [(str "update " table
[locking geo-partitioning conn table row col v]
(let [_ (if (= :pessimistic locking)
(do
; Randomly evaluate SELECT FOR UPDATE with timeout in case of pessimistic locking
(c/query conn [(select-with-optional-lock locking col table) row])
(Thread/sleep (rand-int 2000)))
nil)
r (c/execute! conn [(str "update " table
" set " col " = CONCAT(" col ", ',', ?)" (geo-row-update geo-partitioning v) " "
"where k = ?") v row])]
(when (= [0] r)
Expand Down Expand Up @@ -132,7 +138,7 @@
(read-primary locking conn table row col)

:append
(append-primary! geo-partitioning conn table row col v))]))
(append-primary! locking geo-partitioning conn table row col v))]))

(defn create-geo-tablespace
[conn tablespace-name replica-placement]
Expand Down
Loading