Forum OpenACS Development: Re: db_transaction hanging a thread how to detect, how to kill...

Jerry, in the code above you're using two different database handles both within a db_transaction block, right? Are the semantics of that even defined in the db_* API? What is it really doing? I bet only the first handle is getting a "begin transaction", the second is not doing anything special and is still in autocommit mode.

But either way it doesn't matter, if the intention is that the whole db_transaction block be one atomic transaction, that's impossible, as you're using two handles. Hm, probably db_transaction should notice this and throw an error... This seems like a good example of when the db_transaction syntactic sugar is noticeably more confusing than the simple "begin transaction ... end transaction" commands that are going on underneath.

I don't think db_transaction needs any form of timeout or deadlock detection. What it needs is to throw an error when people try to use two handles (to the same schema) within a db_transaction block, as two handles, by definition, cannot ever be part of one transaction. Even if using two handles within a db_transaction block happens to accidentally do what you want in any particuar case I'd still call it a programming error, and likely to make future maintenance of any such code rather confusing.

I'm still wondering whether we ought to simply turn off all use of more than one handle at once by default. I haven't yet seen any case where using two database handles at once (to the same schema) was actually a good idea. Seems normally we only do it by accident...

John McCarthy: By Grabthar's hammer, by the suns of Warvan, you shall be avenged!
Jerry, what's up, did something happen to John McCarthy? He's still alive an well at Stanford AFAIK.

I say that this is an excellent opportunity to imbed your extensive knowledge of the inner workings of the system by implementing your own suggestion to throw an error when this condition is detected. This type of inadvertant programming error may well be beyond the capability of the typical oacs programmer to detect and resolve. I would consider it great service if you were to implement your fix.

I would consider this to be a bug fix, but you may want to elevate it to TIP status.


Heh, is someone trying to feed my ego in order to get work out of me? ;)

Randy, ok, if no one objects, I'll do it sometime. Don't know exactly when yet though.