-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
with-transaction MySQL #47
Comments
@irigarae That's pretty weird. Can you confirm that this doesn't happen with a JVM setup where you use next.jdbc directly in Clojure? |
Are you running the query in a loop, multiple times, or is the above exactly what you are running? So can I reproduce this by just invoking the above script multiple times? |
The above should reproduce the errors most of the times you run it, except you may need to comment out the following line the first time:
|
Thanks! |
Note to self, I can reproduce with the following docker invocation: (require '[babashka.pods :as pods])
(pods/load-pod 'org.babashka/mysql "0.0.8")
(require '[pod.babashka.mysql :as mysql])
;; running mysql in docker with:
;; docker run --name=mysql-pod-repro -p3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE=test -e MYSQL_ROOT_HOST=% -d mysql/mysql-server:8.0.20
(def db {:dbtype "mysql"
:host "localhost"
:port 3306
:dbname "test"
:user "root"
:password "my-secret-pw"})
(def con (mysql/get-connection db))
(mysql/execute! con ["drop table if exists foo"])
(mysql/execute! con ["create table foo (a int)"])
(mysql/execute! con ["insert into foo values (1), (2), (3)"])
(mysql/execute! con ["select * from foo"])
(mysql/with-transaction [tx con]
;; (Thread/sleep 200)
(mysql/execute! tx ["select * from foo"])) |
I added a branch called |
@john-shaffer As you contributed the MySQL support, if you have any ideas, please chime in. |
Trying to debug babashka/babashka-sql-pods#47. This also serves as a good test that basic functionality works.
I added a |
I see the same behavior, with MariaDB in podman working but MySQL in podman working inconsistently. However, the code compiled as a Clojure native-image project using next.jdbc works fine with both databases. |
It could be a multithreading issue. The pod uses a thread for running the transaction. Perhaps MySQL connections aren’t thread safe or so. |
I believe I have found a fix. It was indeed a multi-threading issue but the issue was within the pod. I'll add the fix. @john-shaffer Is there a way to add "real" MySQL to the tests similar to how it's done for MariaDB? |
Fix pushed! |
@irigarae @euccastro If you could test with this updated pod:
then I'll make a new release after you have confirmed the bug is fixed. You can load the pod using |
@borkdude Testing from my side indeed the erratic behaviour is gone. |
Good, I will release a new version later this week. |
Great work! I think the best option for testing against MySQL is to use a container. |
Released the new pod as version 0.1.0, also available via the registry. |
version
Babashka 0.6.5
org.babashka/mysql 0.0.8
platform
Mac and Linux (tested on both)
problem
Running some query within
with-transaction
gives unexpected behaviour. These are some results seen after running the same query multiple times:repro
Having an accessible MySQL DB (tested on v5.7 and v8.0)
Running the transaction multiple times gives different results. Running
(mysql/execute! con ["select * from foo"])
gives always the same result. Uncommenting(Thread/sleep 200)
reduces the amount of erratic behaviour considerably.expected behavior
I would expect
to return always the same thing as
The text was updated successfully, but these errors were encountered: