From: | Jingtang Zhang <mrdrivingduck(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Lock tag of relation extend lock |
Date: | 2025-10-06 11:39:18 |
Message-ID: | 9625BBE7-BFDE-4389-9F5B-8D8041F6F921@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
In a recent debug I found two process conflict on relation extension lock,
one is holding it for MAIN fork extension, while the other one is trying to
do FSM extension. It seems that the extension lock is using the logical relid
of a table as lock tag, but smgrextend is independant among each fork.
LockRelationForExtension is used to lock out concurrent extension to get an
accurate smgrnblocks (of MAIN fork, mostly) for where to extend the fork from.
Except for that in bufmgr.c, where the forknum is passed in as parameter,
so main/fsm/vm extension shares the code.
Would it be more reasonable to use physical identifier as the lock tag, like
rlocator + fork? In that case, smgr*extend will not block on separate forks.
And also it is easier to share code between recovery and normal operations,
(see what definition of struct BufferManagerRelation says), because currently
relation extension lock needs a relcache to be passed in, and we have to
build a fake relcache during xlog recovery. The lockinfo of the fake relcache
may be wrong actually, although it's not a problem. If we use the physical
information as lock tag, the lockinfo of fake relcache won't be that hack.
Good thing is that different forks of the same relfile can be extended
concurrently by different processes. Not sure about any side effect.
Any thoughts?
--
Regards, Jingtang
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2025-10-06 11:55:47 | Re: split func.sgml to separated individual sgml files |
Previous Message | Ranier Vilela | 2025-10-06 11:33:10 | Re: Fix misuse use of window_gettupleslot function (src/backend/executor/nodeWindowAgg.c) |