sql

All things SQL and JDBC...
dominicm 2020-11-04T19:59:45.213500Z

We have some code which attempts to do a read-modify-write cycle, but the write is an insert if the read failed, as we want to use "lock for update" in postgres. We've discovered that if there's an outer transaction to this code, then we're unable to catch the exception and retry with an update, as the exception is thrown when the transaction is committed, not when the insert happens. Does anyone have any advice?

2020-11-04T20:44:28.214800Z

The insert doesn't happen until the transaction commits

👍 1
2020-11-04T20:45:27.215800Z

That is what committing means

2020-11-04T20:49:16.219600Z

If you switch to a database that doesn't implement acid transactions as well a postgres (mysql?) that might work