jstuyts wrote:
Like I said before I have to take my chances with having multiple connections open for a long time. Unless someone can provide me a simple, transparent alternative.
I am thinking about this. It is possible to implement in theory, but I am not sure it will perform in practice. It can take a lot of time to tune and to experiment with this idea :
1. Asume we have single client for simplicity.
2. Set autocommit = on, we will use custom transactions.
3. generate transaction id in application, store this ID in http session.
4. add XID colum for all tables (Interceptor can manage this property for objects)
5. Store commit list, it can be bit set in local file or table with single column in DB, put XID to list on "logical commit".
6. transform all queries to use app XID.
7. implement concurency control, it can be very trivial for some use cases:
select rows where XID is in commit list or XID == current XID (READ_COMMITED), trow exception on conflict for update or delete( Aggressive CC ).
8. Implement recovery:
Delete all rows from DB where XID not in commit list (we delete rows with current XID on "logical abort" ).
9. Implement garbage collection, Use DB transactions to mark all rows as commited (set XID to some constant value) and truncate commit list.
System tables can be used to implement framework for "custom transactions". This is very aggressive way, but you can use any connection for operation without wasting resources, but custom concurency control algorythm can add more overhead itself.