0

Currently, quarkus only supports multiple datasources for JDBC and the Agroal extension as is stated in the document.

However, the Agroal extension (with narayana-agroal) does not notify any rollback-on-commit Exception to the application code, although some JDBC Driver throws SQLException which indicates the DB was rolled back on commit phase including Google Cloud Spanner JDBC driver. This makes impossible to handle the rollback properly (e.g. return error code to the client).

Is there any solution to detour this problem? Thanks!

Yuki Hashimoto
  • 1,013
  • 7
  • 19
  • 1
    What I have done in the past - in CDI, not Quarkus but the principle may apply - was to introduce an interceptor of my own that executes before *and after* the transaction interceptor. As per the JTA spec, the `@Transactional` interceptor runs at priority `Interceptor.Priority.PLATFORM_BEFORE+200`. Your own interceptor, running at priority +199, can actually catch exceptions thrown by the transactional interceptor and report them to the application. – Nikos Paraskevopoulos Sep 02 '20 at 07:20
  • @NikosParaskevopoulos Thanks for your kind reply! The problem is that the `Exception` I want to catch is deleted inside `transactionManager.commit()`, so even a custom `TransactionalInterceptor` cannot detect the `Exception`. – Yuki Hashimoto Sep 03 '20 at 03:11
  • 1
    FWIW, multiple persistence units support in the Hibernate ORM extension is coming with 1.8. You can already test it in 1.8.0.CR1. See https://groups.google.com/g/quarkus-dev/c/RGjLAyJx_40 for more info. – Guillaume Smet Sep 03 '20 at 15:24
  • @GuillaumeSmet Thanks for your reply! I agree that it's a great new feature, but I don't think it resolves my problem, because it still uses `agroal-narayana` (`io.agroal.narayana.LocalXAResource`), in which failure-on-commit is ignored at all. – Yuki Hashimoto Sep 07 '20 at 02:50
  • @YukiHashimoto would you have some more details from log - e.g. are there some warnings or errors emitted from Agroal or Narayana to log? I think the issue could be there is wrong integration of Agroal and Narayana. But it would be good to have some clue what's exactly happening - e.g. if you may run with TRACE logging. Or some reproducer could be helpful :-) My assumption is that the Agroal uses incorrect XAException error codes (https://github.com/agroal/agroal/blob/master/agroal-narayana/src/main/java/io/agroal/narayana/LocalXAResource.java#L66) which mean different and are ignored by TM. – chalda Sep 07 '20 at 12:35
  • @chalda Thanks for your help, and I apologize my rate response. I got some error messages and I can paste it to anywhere. Where should I give the log, thanks! – Yuki Hashimoto Sep 11 '20 at 02:15
  • @YukiHashimoto no problem, my responses are delayed as well. Maybe can you put it somewhere to pastebin and link it here? Or if you e.g. share some google doc. Whatever way is feasible for you and where I will have a permission to access it. I will check it then and let you know what I'm able to do with it. – chalda Sep 14 '20 at 10:42

0 Answers0