pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Kamigishi Rei <iijima.yun@koumakan.jp>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Cc: Thomas Munro <thomas.munro@gmail.com>
Subject: Re: BUG #17245: Index corruption involving deduplicated entries
Date: Fri, 29 Oct 2021 15:22:42 -0700
Message-ID: <20211029222242.3aik2dv5palwfx4a@alap3.anarazel.de> (raw)
In-Reply-To: <CAH2-Wzk-iReii6BHWgvqBHDNkM0AqEWpxJZHJEVH8WrnTO1isg@mail.gmail.com>
References: <202110250104.jve5vzdedck7@alvherre.pgsql>
	<87h7d57b3q.fsf@news-spur.riddles.org.uk>
	<20211028214209.kbv4ulehz36up6kq@alap3.anarazel.de>
	<125603c4-4403-dcbb-221e-fd1d4ef6ed83@koumakan.jp>
	<20211028220124.n4vulzxp6i6fsq4t@alap3.anarazel.de>
	<551936fa-9ba8-aed1-7ae1-c77d5920101c@koumakan.jp>
	<9c7433f6-65b3-9f57-e8a3-4414d0cf0c53@koumakan.jp>
	<399affa1-c9c5-9b3e-c14f-b24ecb86b303@koumakan.jp>
	<20211029204945.6hzta5dmxwtikurx@alap3.anarazel.de>
	<CAH2-Wzk-iReii6BHWgvqBHDNkM0AqEWpxJZHJEVH8WrnTO1isg@mail.gmail.com>

Hi,

On 2021-10-29 15:06:52 -0700, Peter Geoghegan wrote:
> On Fri, Oct 29, 2021 at 1:49 PM Andres Freund <andres@anarazel.de> wrote:
> > > rmgr: Heap        len (rec/tot):     59/  8115, tx:    2085600, lsn:
> > > 2/A0165A70, prev 2/A0165A38, desc: LOCK off 22: xid 2085600: flags 0x00
> > > LOCK_ONLY EXCL_LOCK KEYS_UPDATED , blkref #0: rel 1663/19243/19560 blk 540
> > > FPW
> > > rmgr: Heap        len (rec/tot):     54/    54, tx:    2085600, lsn:
> > > 2/A018E858, prev 2/A018D7D8, desc: LOCK off 22: xid 2085600: flags 0x00
> > > LOCK_ONLY EXCL_LOCK KEYS_UPDATED , blkref #0: rel 1663/19243/19560 blk 540
> > > rmgr: Heap        len (rec/tot):     73/  8237, tx:    2085600, lsn:
> > > 2/A018E890, prev 2/A018E858, desc: UPDATE off 22 xmax 2085600 flags 0x03
> > > KEYS_UPDATED ; new off 21 xmax 2085600, blkref #0: rel 1663/19243/19560 blk
> > > 328 FPW, blkref #1: rel 1663/19243/19560 blk 540
> >
> > This is also odd. Why are we locking the same row twice, in the same
> > transaction?
> 
> My guess is that mediawiki is supposed to be usable with at least
> MySQL, Postgres, and SQLite, and so uses SELECT FOR UPDATE in ways
> that seem excessive to us.

I was wondering from a different angle:

The two locks are from the same transaction. As far as I remember that code we
actually shouldn't end up emitting a separate lock if the lock level is the
same.

Just briefly looking over the code, the second heap_lock_tuple() should get a
TM_BeingModified from HTSU, which should then end up in the
TransactionIdIsCurrentTransactionId(xwait)) branch, resulting in a goto
out_unlocked.

Greetings,

Andres Freund





view thread (103+ messages)  latest in thread

Message-ID: <20211029222242.3aik2dv5palwfx4a@alap3.anarazel.de>
Permalink:  ../20211029222242.3aik2dv5palwfx4a@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20211029222242.3aik2dv5palwfx4a@alap3.anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andres@anarazel.de, pg@bowt.ie, iijima.yun@koumakan.jp, andrew@tao11.riddles.org.uk, alvherre@alvh.no-ip.org, thomas.munro@gmail.com
  Subject: Re: BUG #17245: Index corruption involving deduplicated entries
  In-Reply-To: <20211029222242.3aik2dv5palwfx4a@alap3.anarazel.de>
  References: <202110250104.jve5vzdedck7@alvherre.pgsql> <87h7d57b3q.fsf@news-spur.riddles.org.uk> <20211028214209.kbv4ulehz36up6kq@alap3.anarazel.de> <125603c4-4403-dcbb-221e-fd1d4ef6ed83@koumakan.jp> <20211028220124.n4vulzxp6i6fsq4t@alap3.anarazel.de> <551936fa-9ba8-aed1-7ae1-c77d5920101c@koumakan.jp> <9c7433f6-65b3-9f57-e8a3-4414d0cf0c53@koumakan.jp> <399affa1-c9c5-9b3e-c14f-b24ecb86b303@koumakan.jp> <20211029204945.6hzta5dmxwtikurx@alap3.anarazel.de> <CAH2-Wzk-iReii6BHWgvqBHDNkM0AqEWpxJZHJEVH8WrnTO1isg@mail.gmail.com> <20211029222242.3aik2dv5palwfx4a@alap3.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox