question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use multi transactions?

See original GitHub issue

I am trying to use Exposed with SpringBoot and MySQL. When I use two transaction s, First transaction is executed. But second transaction is ignored without errors. Can I use multi transactions?

example

This is based on a tutorial of Spting Boot. https://spring.io/guides/tutorials/spring-boot-kotlin/

@RestController
@RequestMapping("/api/article")
class ArticleController() {

    @GetMapping("/test")
    fun test(): List<String> {
        transaction {
            User.insert {
                it[login] = "no1_" + java.lang.Math.random()
                it[firstname] = "one"
                it[lastname] = "one"
                it[description] = Date().toString()
            }
        }
        transaction {
            User.insert {
                it[login] = "no2_" + java.lang.Math.random()
                it[firstname] = "two"
                it[lastname] = "two"
                it[description] = Date().toString()
            }
        }
        return listOf<String>("test")
    }
mysql> select * from User;
+----+------------------------+-----------+----------+------------------------------+
| id | login                  | firstname | lastname | description                  |
+----+------------------------+-----------+----------+------------------------------+
| 17 | no1_0.9963653238062685 | one       | one      | Mon Mar 09 13:01:29 JST 2020 |
+----+------------------------+-----------+----------+------------------------------+

When I tried again, I got error java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30001ms. . That looks waiting for transaction to be committed.

environments

    implementation("org.jetbrains.exposed:exposed-spring-boot-starter:0.21.1")
    implementation("org.jetbrains.exposed:exposed-java-time:0.21.1")
    implementation("mysql:mysql-connector-java:8.0.19")

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Tapaccommented, Mar 14, 2020

Thank you for a sample it was very helpful. Now I found and fixed the issue and it will be available in the next release

1reaction
kaibadashcommented, Mar 13, 2020

Thank you so much! I got no error. I shared a sample project 👍 https://github.com/kaibadash/exposed_ignored_transaction

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: You cannot use more than one AR or AP account in ...
If you have multiple A/R or A/P accounts and you recorded a transaction to the incorrect account, you need to correct the original...
Read more >
Can't process transactions in multi-user environment - Office
When one or more users process many transactions in a multi-user environment, the transactions may fail with the following error message:.
Read more >
c# - Multiple TransactionScope problem - Stack Overflow
I think you'll find the specific answer is that you cannot complete a transaction that hasn't begun anything, it's in an invalid state....
Read more >
Multi-statement transactions | BigQuery - Google Cloud
You can run multi-statement transactions over multiple queries in a session. To start a transaction, use the BEGIN TRANSACTION statement.
Read more >
13.3.1 START TRANSACTION, COMMIT, and ROLLBACK ...
You cannot use ROLLBACK to undo the effect; however, if an error occurs during statement ... To specify multiple modifiers, separate them by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found