Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd814d7f

Browse files
Revert recent change to RequestNamedLWLockTranche().
Commit38b602b modified this function to allocate enough spacefor MAX_NAMED_TRANCHES (256) requests, which is likely far morethan most clusters need. This commit reverts that change so thatit first allocates enough space for only 16 requests and resizesthe array when necessary. While at it, remove the check for toomany tranches from this function. We can now rely onInitializeLWLocks() to do that check via its calls toLWLockNewTrancheId() for the named tranches.Reviewed-by: Sami Imseih <samimseih@gmail.com>Discussion:https://postgr.es/m/aLmzwC2dRbqk14y6%40nathan
1 parentf047814 commitd814d7f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

‎src/backend/storage/lmgr/lwlock.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ void
610610
RequestNamedLWLockTranche(constchar*tranche_name,intnum_lwlocks)
611611
{
612612
NamedLWLockTrancheRequest*request;
613+
staticintNamedLWLockTrancheRequestsAllocated;
613614

614615
if (!process_shmem_requests_in_progress)
615616
elog(FATAL,"cannot request additional LWLocks outside shmem_request_hook");
@@ -628,17 +629,22 @@ RequestNamedLWLockTranche(const char *tranche_name, int num_lwlocks)
628629

629630
if (NamedLWLockTrancheRequestArray==NULL)
630631
{
632+
NamedLWLockTrancheRequestsAllocated=16;
631633
NamedLWLockTrancheRequestArray= (NamedLWLockTrancheRequest*)
632634
MemoryContextAlloc(TopMemoryContext,
633-
MAX_NAMED_TRANCHES
635+
NamedLWLockTrancheRequestsAllocated
634636
*sizeof(NamedLWLockTrancheRequest));
635637
}
636638

637-
if (NamedLWLockTrancheRequests >=MAX_NAMED_TRANCHES)
638-
ereport(ERROR,
639-
(errmsg("maximum number of tranches already registered"),
640-
errdetail("No more than %d tranches may be registered.",
641-
MAX_NAMED_TRANCHES)));
639+
if (NamedLWLockTrancheRequests >=NamedLWLockTrancheRequestsAllocated)
640+
{
641+
inti=pg_nextpower2_32(NamedLWLockTrancheRequests+1);
642+
643+
NamedLWLockTrancheRequestArray= (NamedLWLockTrancheRequest*)
644+
repalloc(NamedLWLockTrancheRequestArray,
645+
i*sizeof(NamedLWLockTrancheRequest));
646+
NamedLWLockTrancheRequestsAllocated=i;
647+
}
642648

643649
request=&NamedLWLockTrancheRequestArray[NamedLWLockTrancheRequests];
644650
strlcpy(request->tranche_name,tranche_name,NAMEDATALEN);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp