Jacob:
Yes, those sessions could definitely be locking themselves out of rows they are deleting or updating by interrupting themselves on a timeout and then reissuing the operation. The solution is for the timeout handler to call sqlbreak() ESQL/C API function to stop the outstanding operation. They should also be using hte sqlbreakcallback() API function to set and capture the timeout instead of language specific or OS timers and interrupts. These are database safe ways to handle this kind of operation. (Though I agree with you that they probably should not be doing what they are doing altogether.) So, you set a timeout using sqlbreakcallback() which registers a callback function at the same time then perform the DELETE. If the timeout expires before the delete returns then the callback function is executed with a status argument value of 2 indicating a timeout. The callback function should call sqldone() to determine if the SQL operation si still active and if so then call sqlbreak() to interrupt the DELETE in the engine instead of letting it keep running. Only then can they safely issue the DELETE again. If the callback function is called with a status argument of 0 then the DELETE (or whatever) has completed without a timeout.
They absolutely should not be calling a longjump() while an SQL operation is still active (ie unless they sqlbreak() it).
Art
Art S. Kagel, President and Principal Consultant
ASK Database Management
Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves.
------Original Message------
Hi Family.
My current client seems to be doing something strange in their web-based application servers. First the intuitive way I would do it at first instinct:
If DEADLCK_TIMOUT (spelling?) is set to 60 seconds, it seems perfectly legit for my own database access to be set with
set lock mode to wait 5. that way, if a SELECT or DELETE is taking more than 5 seconds I would get the "unable to position" error.
A long discussion with one of the programmers indicates the app servers seem to be doing something else. Disclaimer on his behalf: It is a commercial product and AFAIK he has no access to the source code. The suspicion is that the app server is setting an internal timer (likely with setjump() and longjump() calls) as a timeout mechanism. Thus, if a DELETE takes more than that 5 seconds (or whatever they set it to) and it is not complete by then, it repeats the DELETE.
My reaction to this theory is horror: "But the lock(s) set in the process of the stalled DELETE are still in place!"
The symptom that led to said long discussion was that there are deadlock errors happening a lot. Unless some internal engine behavior has changed over the past few years, any lock lasting longer than DEADLCK_TIMOUT gets flagged as a deadlock, even when it's just a long-lasting lock.
Is it possible for a session to be locked out of a row when that the session had itself set that very lock?
My next question regards a way to avoid that possibility: If I come out of the timer and the operation is still pending, is there a way to abort that operation? I vaguely recall seeing such an option but I'm not sure if that was in an Informix manual or another. And how to address which operation to abort in an asynchronous environment that may have many pending operations? That seems to be another conundrum.
Ideas, anyone?
------------------------------
Jacob Salomon (Concise is my middle name - NOT :-)
---
Nobody goes there anymore, it's too crowded. --Attr: Yogi Berra
------------------------------
#Informix