Does redundant extension exist During faster COPY in PG16 - Mailing list pgsql-hackers

From 何柯文(渊云)
Subject Does redundant extension exist During faster COPY in PG16
Date
Msg-id 3dbb9c7f-7b81-43f0-98d9-b76f33b4aca1.hekewen.hkw@alibaba-inc.com
Whole thread Raw
Responses Re: Does redundant extension exist During faster COPY in PG16
List 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

pgsql-hackers by date:

Previous
From: shveta malik
Date:
Subject: Re: Synchronizing slots from primary to standby
Next
From: Masahiko Sawada
Date:
Subject: Re: Synchronizing slots from primary to standby