joshchoo / micronaut-coroutines-transactional-issue

Sample project to demonstrate Transactional not working with Coroutines in Micronaut

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Coroutines and @Transactional issue

@Transactional doesn't seem to work when using Coroutines.

Set up

Start Postgres

$ docker compose up

Start Micronaut

$ ./gradlew run

Steps to reproduce

Run the failing test:

./gradlew test -i

Alternatively, reproduce the error manually with the following steps

Send a post request to /suspend:

$ curl -X POST -d '{"id":"C3076DE3-4678-4B6A-A977-15F35607B7C7"}' http://localhost:8080/suspend -s -S -v -H "Content-Type: ap
plication/json"

Expected: Duplicate key value exception occurs, and no rows should be created in the database.

Actual: One row is still created in the database.

About

Sample project to demonstrate Transactional not working with Coroutines in Micronaut


Languages

Language:Kotlin 100.0%