Lock on arbitrary string feature
От | Lincoln Yeoh |
---|---|
Тема | Lock on arbitrary string feature |
Дата | |
Msg-id | 3.0.5.32.20010111154339.009fc100@192.228.128.13 обсуждение исходный текст |
Ответ на | Re: [PATCHES] Re: Recursion and SPI (Bruce Momjian <pgman@candle.pha.pa.us>) |
Ответы |
Re: Lock on arbitrary string feature
Re: Lock on arbitrary string feature |
Список | pgsql-hackers |
Hi, Has anyone any input to offer on adding an arbitrary locking feature? Where GETLOCK "string" will lock on "string", the lock being only released at the end of a transaction. While the lock is held, other processes trying to do GETLOCK "string" will block until the lock is released. This feature can allow applications to better serialize things. For example: inserting unique records. Cooperating applications could just do something like: GETLOCK "mytable.key2=1234"; SELECT count(*) from mytable where key2=1234 for update; if count==0, insert the stuff.elsif count==1 update the stuff insteadelse something is wrong! The lock will thus only affect applications interested in mytable where key2=1234 In contrast the current alternatives appear to be either LOCK the entire table (preventing ALL inserts and selects), or to create a UNIQUE constraint (forcing complete rollbacks and restarts in event of a collision :( ). Any comments, suggestions or tips would be welcome. It looks like quite a complex thing to do - I've only just started looking at the postgresql internals and the lock manager. Cheerio, Link.
В списке pgsql-hackers по дате отправления: