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

Commit6599c9a

Browse files
committed
Add an Assert() to max_parallel_workers enforcement.
To prevent future bugs along the lines of the one corrected by commit8ff5186, or find any that remainin the current code, add an Assert() that the difference betweenparallel_register_count and parallel_terminate_count is in a sanerange.Kuntal Ghosh, with considerable tidying-up by me, per a suggestionfrom Neha Khatri. Reviewed by Tomas Vondra.Discussion:http://postgr.es/m/CAFO0U+-E8yzchwVnvn5BeRDPgX2z9vZUxQ8dxx9c0XFGBC7N1Q@mail.gmail.com
1 parent8ff5186 commit6599c9a

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

‎src/backend/postmaster/bgworker.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,9 @@ RegisterDynamicBackgroundWorker(BackgroundWorker *worker,
971971
BackgroundWorkerData->parallel_terminate_count) >=
972972
max_parallel_workers)
973973
{
974+
Assert(BackgroundWorkerData->parallel_register_count-
975+
BackgroundWorkerData->parallel_terminate_count <=
976+
MAX_PARALLEL_WORKER_LIMIT);
974977
LWLockRelease(BackgroundWorkerLock);
975978
return false;
976979
}

‎src/backend/utils/misc/guc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#include"parser/scansup.h"
5858
#include"pgstat.h"
5959
#include"postmaster/autovacuum.h"
60-
#include"postmaster/bgworker.h"
60+
#include"postmaster/bgworker_internals.h"
6161
#include"postmaster/bgwriter.h"
6262
#include"postmaster/postmaster.h"
6363
#include"postmaster/syslogger.h"
@@ -2713,7 +2713,7 @@ static struct config_int ConfigureNamesInt[] =
27132713
NULL
27142714
},
27152715
&max_parallel_workers_per_gather,
2716-
2,0,1024,
2716+
2,0,MAX_PARALLEL_WORKER_LIMIT,
27172717
NULL,NULL,NULL
27182718
},
27192719

@@ -2723,7 +2723,7 @@ static struct config_int ConfigureNamesInt[] =
27232723
NULL
27242724
},
27252725
&max_parallel_workers,
2726-
8,0,1024,
2726+
8,0,MAX_PARALLEL_WORKER_LIMIT,
27272727
NULL,NULL,NULL
27282728
},
27292729

‎src/include/postmaster/bgworker_internals.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
#include"lib/ilist.h"
1717
#include"postmaster/bgworker.h"
1818

19+
/* GUC options */
20+
21+
/*
22+
* Maximum possible value of parallel workers.
23+
*/
24+
#defineMAX_PARALLEL_WORKER_LIMIT 1024
25+
1926
/*
2027
* List of background workers, private to postmaster.
2128
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp