Re: Deadlock possibility in _bt_check_unique?

From: Gokulakannan Somasundaram <gokul007(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, pgsql-hackers list <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Deadlock possibility in _bt_check_unique?
Date: 2010-03-23 18:06:41
Message-ID: 9362e74e1003231106n673c54e0vacec7f418acc6dc4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> No, you don't understand how it works. All would-be inserters will hit
> the same target page to begin with, ie, the first one that the new key
> could legally be inserted on. The lock that protects against this
> problem is the lock on that page, regardless of which page the key
> actually ends up on.
>
>
Consider Time instances T1, T2, T3, T4

T1 : session 1 holds the write lock on page p1 and completes the unique
check on p1, p2 and p3.

T2 : session 1 releases the lock on p1 (its waiting to acquire a ex lock on
p2)

T3 : session 2 acquires write lock on p1 and completes the unique check on
p1, p2 and p3. Here, i believe the Session 2
has a chance of getting the read lock before session 1 gets the write lock.
Is it not possible?

T4 : session 1 gets the write lock on p2 and inserts and session 2 gets the
write lock on p1 and inserts.

OK. I have stated my assumptions. Is my assumption at time instant T3 wrong/
never happen?

Thanks,
Gokul.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gurjeet Singh 2010-03-23 18:09:34 Re: Repeating Append operation
Previous Message Tom Lane 2010-03-23 17:49:55 Re: Deadlock possibility in _bt_check_unique?