Food for thought: After our pending release, it might be an idea to
make a combined effort to identify and address as many concurrency
issues as possible, we need to modernize our implementation code so we
stay relevant.
An important task will be updating all our service implementations so
they DON'T start threads during construction.
Every time I fix one concurrency problem, performance usually improves
and another heisenbug appears.
/* Expiration checks are only meaningful for active transactions. */
/* NOTE:
* 1) Cancellation sets expiration to 0 without changing state
* from Active right away. Clients are supposed to treat
* UnknownTransactionException just like Aborted, so it's OK to send
* in this case.
* 2) Might be a small window where client is committing the transaction
* close to the expiration time. If the committed transition takes
* place between getState() and ensureCurrent then the client could get
* a false result.
*/
//TODO - need better locking here. getState and expiration need to be
checked atomically