Does redundant extension exist During faster COPY in PG16

From: 何柯文(渊云) <hekewen(dot)hkw(at)alibaba-inc(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: "andres(at)anarazel(dot)de" <andres(at)anarazel(dot)de>
Subject: Does redundant extension exist During faster COPY in PG16
Date: 2024-01-22 11:54:00
Message-ID: 3dbb9c7f-7b81-43f0-98d9-b76f33b4aca1.hekewen.hkw@alibaba-inc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
I'm learning faster COPY of PG16. I have some questions about extension lock improvement.
From ./src/backend/storage/buffer/bufmgr.c:1901 (ExtendBufferedRelShared)
```
/*
* Lock relation against concurrent extensions, unless requested not to.
*
* We use the same extension lock for all forks. That's unnecessarily
* restrictive, but currently extensions for forks don't happen often
* enough to make it worth locking more granularly.
*
* Note that another backend might have extended the relation by the time
* we get the lock.
*/
if (!(flags & EB_SKIP_EXTENSION_LOCK))
{
LockRelationForExtension(bmr.rel, ExclusiveLock);
if (bmr.rel)
bmr.smgr = RelationGetSmgr(bmr.rel);
}
...
smgrzeroextend(bmr.smgr, fork, first_block, extend_by, false);
```
During concurrent extension, when we obtain the extension lock, we use smgrzeroextend() to extend relation files instead of searching fsm through GetPageWithFreeSpace(). Is this approach reasonable?
During concurrent extensions, one backend bulk extend successfully, meaning that other backends waiting on extension lock have free pages to use.
If all concurrent extend backends extend the relation file after getting the extension lock, the extension lock will be held (extention backends * smgrzeroextend() executing time).

Any feedback is welcome.

--
Best Regards
Kewen He

from 阿里邮箱 macOS

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2024-01-22 11:58:05 Re: Synchronizing slots from primary to standby
Previous Message shveta malik 2024-01-22 11:37:05 Re: Synchronizing slots from primary to standby