Re: [HACKERS] please?

From: Pablo Funes <pablo(at)cs(dot)brandeis(dot)edu>
To: vadim(at)krs(dot)ru (Vadim Mikheev)
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, pablo(at)cs(dot)brandeis(dot)edu, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] please?
Date: 1999-06-01 16:09:36
Message-ID: 199906011609.MAA07086@mancha.cs.brandeis.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > There is no way to do that in 6.4. I am not sure whether the MVCC
> > additions in 6.5 provide a way to do it or not (Vadim?).
>
> I want to have it in later versions.
>
> At the moment try to use contrib/userlock/
>

AHA! It looks like this solves my problem, at least for now,
until an official way to do nonblocking locs shows up on a
future release.
Here's what contrib/userlock/user_locks.doc says:

select some_fields, user_write_lock_oid(oid) from table where id='key';

Now if the returned user_write_lock_oid field is 1 you have acquired an
user lock on the oid of the selected tuple and can now do some long operation
on it, like let the data being edited by the user.

If it is 0 it means that the lock has been already acquired by some other
process and you should not use that item until the other has finished.

[...]

update table set some_fields where id='key';
select user_write_unlock_oid(oid) from table where id='key';

[...]

This could also be done by setting a flag in the record itself but in
this case you have the overhead of the updates to the records and there
could be some locks not released if the backend or the application crashes
before resetting the lock flag.

It could also be done with a begin/end block but in this case the entire
table would be locked by postgres and it is not acceptable to do this for
a long period because other transactions would block completely.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 1999-06-01 16:22:54 Re: [HACKERS] which list?
Previous Message Bruce Momjian 1999-06-01 15:53:22 Re: [HACKERS] LIMITS