There have been various posts of logging the activity (start, commit & rollback) of Spring's transaction manager. However, I recently came across a deadlock issue for which logging just the activity isn't enough.
The fundamental issue in our code is a messy usage of transaction propagations REQUIRED and REQUIRES_NEW. There are so many method calls back- and forth that we end up with a lot of transactions stacked onto each other. Alas, the code base is huge and the solution urgent... (We all know what this is.)
The issue was a deadlock because code was added to query entities in a transaction that were sub-sequentially modified in another transaction. Spring spits out an exception telling the update of entity X times out because it's locked. Now, Knowing this is nice, but how does one find the faulty code: The query which does the early locking.
My question (at last) : Is there a way to log the entities being added to a transaction ? This way I can specifically look for transactions locking the entity Spring is complaining about.
Thanks ! :-)