[Answered ]-Django db transaction set_autocommit and CONN_MAX_AGE

2👍

I would recommend using transaction.atomic(), since its purpose is to do exactly the thing you want.

You can see the implementation here. The most obvious difference is that Django’s version has support for “nested” transactions using savepoints. You can trust that this code is well-tested and widely used.

Regarding your scenario, your updates in step 2 should survive in either case, since autocommit applies at the database connection level, and the two concurrent requests will be using different database connections.

Leave a comment