Expected behaviour of using a configuration out of its transaction scope?

24 views
Skip to first unread message

Victor Noël

unread,
Oct 18, 2019, 5:54:44 AM10/18/19
to jOOQ User Group
Hi,

I was playing with transaction support in jOOQ and faced the following situation that surprised me (this is pseudo-code and very simplifying to illustrate the heart of the question):

var leaked = DSL
 
.using(datasource, SQLDialect.POSTGRES)
 
.transactionResult(conf -> {
   
var tx = DSL.using(conf);
    tx.select(...).fetch();
   
return tx;
 
});

leaked
.select(...).fetch();

I would have expected the first select to succeed and the second one to fail, because I leaked the context out of the transaction and used it after it was closed.

But maybe I'm making incorrect assumptions?

What happens in this case, the leaked select will just be executed outside of any transaction?

Thanks

Lukas Eder

unread,
Oct 21, 2019, 3:52:08 AM10/21/19
to jOOQ User Group
Hi Victor,

Thank you very much for your message. I've created a bug report for this issue, which I believe is a bug:

At first sight, the outer query should throw an exception, as the transactional semantics is undefined. We could, of course, define it retroactively. I *think* that what happens is you inherit the datasource's default auto commit flag, which might be "true", so you will run each query in its own transaction.

Fixing this will not be easy as a lot of applications may already depend on the current behaviour. We'll think about it. Thanks again for bringing this to our attention.

Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/d169e71a-3a31-4d89-9400-0bc9911952fc%40googlegroups.com.

Victor Noël

unread,
Oct 21, 2019, 10:15:29 AM10/21/19
to jOOQ User Group
Thanks for making this a proper issue and clarifying the current behaviour :)
To unsubscribe from this group and stop receiving emails from it, send an email to jooq...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages