From: | "Henryk Szal" <szal(at)doctorq(dot)com(dot)pl> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | timeout on lock |
Date: | 2001-04-09 10:02:39 |
Message-ID: | 9as0va$8d3$1@news.tht.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
i implement additional server functionality. Currently (v7.0.3), executing
SQL update statement on the same
row from inside two different processess results in blocking second process
to the end of transaction in the first one.
In real OLTP application second process can't wait too long. After few
seconds server should return with
message 'lock timeout exceeded'. I modify postgres lock manager source code
to obtain that functionality.
I take advantage of deadlock detection mechanism. Currently deadlock
detection routine initialy check for
simple deadlock detection between two processess, next insert lock into lock
queue and after
DEADLOCK_CHECK_TIMER seconds run HandleDeadLock to comprehensive deadlock
detection.
To obtain 'timeout on lock' feature I do as follow:
1. Add new configure parameter. I add #define statement in file
include/config.in
#define NO_WAIT_FOR_LOCK 1
In the future somebody can add new option to SQL SET command
2. Modify HandleDeadLock routine. In file backend/storage/lmgr/proc.c change
lines 866-870
if (!DeadLockCheck(MyProc, MyProc->waitLock))
{
UnlockLockTable();
return;
}
to
if (!NO_WAIT_FOR_LOCK)
{
if (!DeadLockCheck(MyProc, MyProc->waitLock))
{
UnlockLockTable();
return;
}
}
With this modyfication every conflicting lock wait DEADLOCK_CHECK_TIMER
seconds in queue and returns with error
'deadlock detect'.
Who can add 'timeout on lock' feature to the next postgres server release?
From | Date | Subject | |
---|---|---|---|
Next Message | Henryk Szal | 2001-04-09 10:30:18 | timeout on lock feature |
Previous Message | Zeugswetter Andreas SB | 2001-04-09 09:37:58 | AW: RPM upgrade caveats going from a beta version to RC |