Skip site navigation (1) Skip section navigation (2)

Re: Proposal: String key space for advisory locks

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: String key space for advisory locks
Date: 2009-10-27 23:50:11
Message-ID: 319C476D-A365-4BF0-94CA-1CDC078529B9@thebuild.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Oct 27, 2009, at 4:37 PM, Merlin Moncure wrote:
> 'as is', advisory locks is a fantastic feature that can be used for
> signaling, mutexing, etc that are relatively difficult things to do in
> the transactional world of sql.  My main gripe is that the 'shared id'
> method for doing record pessimistic locks is basically a nuclear
> missile pointed at your shared buffers if you don't have lot of
> discipline in the queries that lock IDs.  Maybe this argues for more
> of a 'sql exposed' pessimistic lock feature that operates on similar
> level as 'for update'...I'm not sure...curious what thoughts you have
> about improving them.

Advisory locks have, as you say, a raft of very useful characteristics:

1. Enforced as much or as little as you wish, depending on your  
application design.
2. Race-condition-free.
3. Cleaned up automatically on session end.

Of course, 2^64 potential entries are enough for anyone.  The  
usability issue comes when you have multiple domains that you want to  
apply advisory locks to in a single database.  For example, if you  
have multiple tables (one of which, just for example, has a character  
pk), and perhaps some inter-client mutex signaling for things that are  
outside of a transactional model ("this client is importing a file  
from an outside source, so don't you do it"), it's unappealing to have  
to come up with ways of representing those in a 64-bit namespace.

Hashing isn't a terrible solution, assuming collisions don't become an  
issue; a well-designed hashtext64() would help a lot.
--
-- Christophe Pettus
    xof(at)thebuild(dot)com


In response to

pgsql-hackers by date

Next:From: Robert HaasDate: 2009-10-28 00:35:37
Subject: Re: Parsing config files in a directory
Previous:From: Merlin MoncureDate: 2009-10-27 23:37:00
Subject: Re: Proposal: String key space for advisory locks

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group