pg_locks view and user locks
pg_locks view and user locks
От:
"Merlin Moncure" <merlin.moncure@rcsonline.com>
Дата:
I've been knocking around a bit with user level locks and I have a few suggestions/questions: First, the pg_locks view lists user level locks but doesn't really say much about them. For example, for traditional locks we get the xid but for user locks we don't really get anything useful. I looked in lockfuncs.c and didn't see that there would be any real penalty to displaying the offset/block of the user lock, and returning it in request from pg_locks. Is this view frequently queried by system processes? Why would we want to do this? Well it makes resolving a user lock to a specific pid easier...admittedly of dubious value but helpful to me...although if this doesn't fly I can always create an alternate view which serves my purpose (and perhaps add a high level function to the /contrib userlock module). Second, Is there a reason why user level locks are completely undocumented? AFAICT, There is no mention of them in anywhere in the docs, particularly 12.4, which describes methods for application managed concurrency. The availability of cooperative long term locks is (IMO) a really nice feature, particularly for people porting legacy applications which depend on explicit locking (there is some good info in the user lock module which is unfortunately under the GPL). Not complaining or looking for help, just curious why they seemed to have slipped through the cracks. Merlin
Re: [HACKERS] pg_locks view and user locks
От:
Alvaro Herrera <alvherre@dcc.uchile.cl>
Дата:
On Mon, Sep 13, 2004 at 01:34:05PM -0400, Merlin Moncure wrote: > First, the pg_locks view lists user level locks but doesn't really say > much about them. For example, for traditional locks we get the xid but > for user locks we don't really get anything useful. I looked in > lockfuncs.c and didn't see that there would be any real penalty to > displaying the offset/block of the user lock, and returning it in > request from pg_locks. ISTM it would be better to have pg_locks show only system locks, and another view, say pg_userlocks, to show user locks. This would allow to show different data; for example, the PID of the process involved. What's more, user locks and system locks never conflict, so it seems wrong to show them together. Another option would be to add another column to pg_locks to say what lockmethod (1 for system, 2 for user) is used in each lock. Maybe we want to separate locks even more, and use one table to show xact locks, another to show table locks, and yet another to show user locks. But maybe this is a bad idea right from the start. > Is this view frequently queried by system processes? I don't think there is a lot of server-side stuff (aside from possible UDFs) that use pg_locks directly. It's there only for user convenience. -- Alvaro Herrera () "Someone said that it is at least an order of magnitude more work to do production software than a prototype. I think he is wrong by at least an order of magnitude." (Brian Kernighan)
Re: [HACKERS] pg_locks view and user locks
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Alvaro Herrera writes: > ISTM it would be better to have pg_locks show only system locks, and > another view, say pg_userlocks, to show user locks. This would allow to > show different data; for example, the PID of the process involved. I think this is a bad idea, at least for the base-level view, because it would imply that it's impossible to get a truly simultaneous view of the state of all the locks. It would certainly be a bad idea to so separate xact and table locks. I'd prefer to extend the present approach and add columns that are NULL when the type of lock isn't relevant to them. > Another option would be to add another column to pg_locks to say what > lockmethod (1 for system, 2 for user) is used in each lock. How about a text column with values "TABLE", "XACT", "USER"? regards, tom lane