Re: this is in plain text (row level locks)

From: Sailesh Krishnamurthy <sailesh(at)cs(dot)berkeley(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Jenny - <nat_lazy(at)hotmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: this is in plain text (row level locks)
Date: 2003-07-24 06:45:39
Message-ID: bxy8yqo1kz0.fsf@datafix.cs.berkeley.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

Tom> That doesn't work, unless you insist that the first backend
Tom> can't exit its transaction until all the other ones are done.
Tom> Which introduces its own possibilities for deadlock --- but
Tom> even worse, how does the first backend *know* that the other
Tom> ones are done? You're right back where you started: it has
Tom> to be possible to tell which backends have share-locked a
Tom> particular row.

Is a count a solution ?

The first backend gets the S lock on the row - I'm assuming you plan
to do it by recording it on the tuple and not in a shared memory lock
table, which means that you might have to unnecessarily write an
unmodified page if its buffer pool frame is stolen.

The problem is that on commit time, you must carefully decrement the
count value of shared locks on any tuple that you own. This can be
accomplished by having each backend keep track of the list of files
and TIDs for any rows for which it acquired S locks. Is this the same
way that pgsql releases the X locks ?

Bruce, I don't disagree that MVCC has the very nice property that
writers don't block readers. However, I don't buy that 2-phase
locking, with lock escalation is either unworkable because of too many
locks, or causes any extra pain for the user application (apart from
the fact that writers not blocking readers gives you more concurrency
at some very minor overhead of not being strictly serializable).

--
Pip-pip
Sailesh
http://www.cs.berkeley.edu/~sailesh

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shridhar Daithankar 2003-07-24 06:45:52 Re:
Previous Message Tom Lane 2003-07-24 05:28:09 Re: this is in plain text (row level locks)