Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1b9050da66aba821fec18376bee30d17e91e7027^..421892a192b8f95ab96c5edb61d424f80a4221d0 #71

Merged
merged 17 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions config/perl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ AC_MSG_RESULT([$perl_embed_ccflags])
# PGAC_CHECK_PERL_EMBED_LDFLAGS
# -----------------------------
# We are after Embed's ldopts, but without the subset mentioned in
# Config's ccdlflags; and also without any -arch flags, which recent
# Apple releases put in unhelpfully. (If you want a multiarch build
# you'd better be specifying it in more places than plperl's final link.)
# Config's ccdlflags and ldflags. (Those are the choices of those who
# built the Perl installation, which are not necessarily appropriate
# for building PostgreSQL.)
AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
[AC_REQUIRE([PGAC_PATH_PERL])
AC_MSG_CHECKING(for flags to link embedded Perl)
Expand All @@ -99,8 +99,8 @@ if test "$PORTNAME" = "win32" ; then
fi
else
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
pgac_tmp2=`$PERL -MConfig -e 'print "$Config{ccdlflags} $Config{ldflags}"'`
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%"`
fi
AC_SUBST(perl_embed_ldflags)dnl
if test -z "$perl_embed_ldflags" ; then
Expand Down
4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -10477,8 +10477,8 @@ if test "$PORTNAME" = "win32" ; then
fi
else
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e "s/ -arch [-a-zA-Z0-9_]*//g"`
pgac_tmp2=`$PERL -MConfig -e 'print "$Config{ccdlflags} $Config{ldflags}"'`
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%"`
fi
if test -z "$perl_embed_ldflags" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
Expand Down
27 changes: 22 additions & 5 deletions doc/src/sgml/runtime.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -1258,11 +1258,12 @@ default:\
<itemizedlist>
<listitem>
<para>
On <productname>Linux</productname>
<filename>/proc/sys/fs/file-max</filename> determines the
maximum number of open files that the kernel will support. It can
be changed by writing a different number into the file or by
adding an assignment in <filename>/etc/sysctl.conf</filename>.
On <productname>Linux</productname> the kernel parameter
<varname>fs.file-max</varname> determines the maximum number of open
files that the kernel will support. It can be changed with
<literal>sysctl -w fs.file-max=<replaceable>N</replaceable></literal>.
To make the setting persist across reboots, add an assignment
in <filename>/etc/sysctl.conf</filename>.
The maximum limit of files per process is fixed at the time the
kernel is compiled; see
<filename>/usr/src/linux/Documentation/proc.txt</filename> for
Expand Down Expand Up @@ -1298,6 +1299,22 @@ default:\
linkend="guc-max-files-per-process"/> configuration parameter to
limit the consumption of open files.
</para>

<para>
Another kernel limit that may be of concern when supporting large
numbers of client connections is the maximum socket connection queue
length. If more than that many connection requests arrive within a very
short period, some may get rejected before the postmaster can service
the requests, with those clients receiving unhelpful connection failure
errors such as <quote>Resource temporarily unavailable</quote> or
<quote>Connection refused</quote>. The default queue length limit is 128
on many platforms. To raise it, adjust the appropriate kernel parameter
via <application>sysctl</application>, then restart the postmaster.
The parameter is variously named <varname>net.core.somaxconn</varname>
on Linux, <varname>kern.ipc.soacceptqueue</varname> on newer FreeBSD,
and <varname>kern.ipc.somaxconn</varname> on macOS and other BSD
variants.
</para>
</sect2>

<sect2 id="linux-memory-overcommit">
Expand Down
3 changes: 1 addition & 2 deletions src/backend/access/brin/brin.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
**nullkeys;
int *nkeys,
*nnullkeys;
int keyno;
char *ptr;
Size len;
char *tmp PG_USED_FOR_ASSERTS_ONLY;
Expand Down Expand Up @@ -454,7 +453,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
memset(nnullkeys, 0, sizeof(int) * bdesc->bd_tupdesc->natts);

/* Preprocess the scan keys - split them into per-attribute arrays. */
for (keyno = 0; keyno < scan->numberOfKeys; keyno++)
for (int keyno = 0; keyno < scan->numberOfKeys; keyno++)
{
ScanKey key = &scan->keyData[keyno];
AttrNumber keyattno = key->sk_attno;
Expand Down
3 changes: 1 addition & 2 deletions src/backend/access/brin/brin_minmax_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,6 @@ brin_range_serialize(Ranges *range)
int typlen;
bool typbyval;

int i;
char *ptr;

/* simple sanity checks */
Expand Down Expand Up @@ -662,7 +661,7 @@ brin_range_serialize(Ranges *range)
*/
ptr = serialized->data; /* start of the serialized data */

for (i = 0; i < nvalues; i++)
for (int i = 0; i < nvalues; i++)
{
if (typbyval) /* simple by-value data types */
{
Expand Down
3 changes: 1 addition & 2 deletions src/backend/access/gist/gist.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
Page page = BufferGetPage(buffer);
bool is_leaf = (GistPageIsLeaf(page)) ? true : false;
XLogRecPtr recptr;
int i;
bool is_split;

/*
Expand Down Expand Up @@ -420,7 +419,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
{
char *data = (char *) (ptr->list);

for (i = 0; i < ptr->block.num; i++)
for (int i = 0; i < ptr->block.num; i++)
{
IndexTuple thistup = (IndexTuple) data;

Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/transam/xlogprefetcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn)
if (!block->in_use)
continue;

Assert(!BufferIsValid(block->prefetch_buffer));;
Assert(!BufferIsValid(block->prefetch_buffer));

/*
* Record the LSN of this record. When it's replayed,
Expand Down
3 changes: 1 addition & 2 deletions src/backend/commands/copyfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,6 @@ BeginCopyFrom(ParseState *pstate,
num_defaults;
FmgrInfo *in_functions;
Oid *typioparams;
int attnum;
Oid in_func_oid;
int *defmap;
ExprState **defexprs;
Expand Down Expand Up @@ -1401,7 +1400,7 @@ BeginCopyFrom(ParseState *pstate,
defmap = (int *) palloc(num_phys_attrs * sizeof(int));
defexprs = (ExprState **) palloc(num_phys_attrs * sizeof(ExprState *));

for (attnum = 1; attnum <= num_phys_attrs; attnum++)
for (int attnum = 1; attnum <= num_phys_attrs; attnum++)
{
Form_pg_attribute att = TupleDescAttr(tupDesc, attnum - 1);

Expand Down
7 changes: 3 additions & 4 deletions src/backend/commands/indexcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ DefineIndex(Oid relationId,
Oid root_save_userid;
int root_save_sec_context;
int root_save_nestlevel;
int i;

root_save_nestlevel = NewGUCNestLevel();

Expand Down Expand Up @@ -1047,7 +1046,7 @@ DefineIndex(Oid relationId,
* We disallow indexes on system columns. They would not necessarily get
* updated correctly, and they don't seem useful anyway.
*/
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
for (int i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
{
AttrNumber attno = indexInfo->ii_IndexAttrNumbers[i];

Expand All @@ -1067,7 +1066,7 @@ DefineIndex(Oid relationId,
pull_varattnos((Node *) indexInfo->ii_Expressions, 1, &indexattrs);
pull_varattnos((Node *) indexInfo->ii_Predicate, 1, &indexattrs);

for (i = FirstLowInvalidHeapAttributeNumber + 1; i < 0; i++)
for (int i = FirstLowInvalidHeapAttributeNumber + 1; i < 0; i++)
{
if (bms_is_member(i - FirstLowInvalidHeapAttributeNumber,
indexattrs))
Expand Down Expand Up @@ -1243,7 +1242,7 @@ DefineIndex(Oid relationId,
* If none matches, build a new index by calling ourselves
* recursively with the same options (except for the index name).
*/
for (i = 0; i < nparts; i++)
for (int i = 0; i < nparts; i++)
{
Oid childRelid = part_oids[i];
Relation childrel;
Expand Down
3 changes: 1 addition & 2 deletions src/backend/executor/nodeAgg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1296,13 +1296,12 @@ finalize_aggregates(AggState *aggstate,
Datum *aggvalues = econtext->ecxt_aggvalues;
bool *aggnulls = econtext->ecxt_aggnulls;
int aggno;
int transno;

/*
* If there were any DISTINCT and/or ORDER BY aggregates, sort their
* inputs and run the transition functions.
*/
for (transno = 0; transno < aggstate->numtrans; transno++)
for (int transno = 0; transno < aggstate->numtrans; transno++)
{
AggStatePerTrans pertrans = &aggstate->pertrans[transno];
AggStatePerGroup pergroupstate;
Expand Down
10 changes: 4 additions & 6 deletions src/backend/libpq/pqcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,11 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
}

/*
* Select appropriate accept-queue length limit. PG_SOMAXCONN is only
* intended to provide a clamp on the request on platforms where an
* overly large request provokes a kernel error (are there any?).
* Select appropriate accept-queue length limit. It seems reasonable
* to use a value similar to the maximum number of child processes
* that the postmaster will permit.
*/
maxconn = MaxBackends * 2;
if (maxconn > PG_SOMAXCONN)
maxconn = PG_SOMAXCONN;
maxconn = MaxConnections * 2;

err = listen(fd, maxconn);
if (err < 0)
Expand Down
8 changes: 4 additions & 4 deletions src/backend/optimizer/path/costsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2447,7 +2447,6 @@ append_nonpartial_cost(List *subpaths, int numpaths, int parallel_workers)
int arrlen;
ListCell *l;
ListCell *cell;
int i;
int path_index;
int min_index;
int max_index;
Expand Down Expand Up @@ -2486,7 +2485,6 @@ append_nonpartial_cost(List *subpaths, int numpaths, int parallel_workers)
for_each_cell(l, subpaths, cell)
{
Path *subpath = (Path *) lfirst(l);
int i;

/* Consider only the non-partial paths */
if (path_index++ == numpaths)
Expand All @@ -2495,15 +2493,17 @@ append_nonpartial_cost(List *subpaths, int numpaths, int parallel_workers)
costarr[min_index] += subpath->total_cost;

/* Update the new min cost array index */
for (min_index = i = 0; i < arrlen; i++)
min_index = 0;
for (int i = 0; i < arrlen; i++)
{
if (costarr[i] < costarr[min_index])
min_index = i;
}
}

/* Return the highest cost from the array */
for (max_index = i = 0; i < arrlen; i++)
max_index = 0;
for (int i = 0; i < arrlen; i++)
{
if (costarr[i] > costarr[max_index])
max_index = i;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/postmaster/postmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -5065,7 +5065,7 @@ SubPostmasterMain(int argc, char *argv[])
* If testing EXEC_BACKEND on Linux, you should run this as root before
* starting the postmaster:
*
* echo 0 >/proc/sys/kernel/randomize_va_space
* sysctl -w kernel.randomize_va_space=0
*
* This prevents using randomized stack and code addresses that cause the
* child process's memory map to be different from the parent's, making it
Expand Down
11 changes: 0 additions & 11 deletions src/backend/postmaster/walwriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,7 @@ HandleWalWriterInterrupts(void)
}

if (ShutdownRequestPending)
{
/*
* Force reporting remaining WAL statistics at process exit.
*
* Since pgstat_report_wal is invoked with 'force' is false in main
* loop to avoid overloading the cumulative stats system, there may
* exist unreported stats counters for the WAL writer.
*/
pgstat_report_wal(true);

proc_exit(0);
}

/* Perform logging of memory contexts of this process */
if (LogMemoryContextPending)
Expand Down
16 changes: 8 additions & 8 deletions src/backend/replication/logical/origin.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ replorigin_drop_guts(Relation rel, RepOriginId roident, bool nowait)
if (nowait)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_IN_USE),
errmsg("could not drop replication origin with ID %u, in use by PID %d",
errmsg("could not drop replication origin with ID %d, in use by PID %d",
state->roident,
state->acquired_by)));

Expand Down Expand Up @@ -408,7 +408,7 @@ replorigin_drop_guts(Relation rel, RepOriginId roident, bool nowait)
*/
tuple = SearchSysCache1(REPLORIGIDENT, ObjectIdGetDatum(roident));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for replication origin with ID %u",
elog(ERROR, "cache lookup failed for replication origin with ID %d",
roident);

CatalogTupleDelete(rel, &tuple->t_self);
Expand Down Expand Up @@ -485,7 +485,7 @@ replorigin_by_oid(RepOriginId roident, bool missing_ok, char **roname)
if (!missing_ok)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("replication origin with ID %u does not exist",
errmsg("replication origin with ID %d does not exist",
roident)));

return false;
Expand Down Expand Up @@ -799,7 +799,7 @@ StartupReplicationOrigin(void)
last_state++;

ereport(LOG,
(errmsg("recovered replication state of node %u to %X/%X",
(errmsg("recovered replication state of node %d to %X/%X",
disk_state.roident,
LSN_FORMAT_ARGS(disk_state.remote_lsn))));
}
Expand Down Expand Up @@ -937,7 +937,7 @@ replorigin_advance(RepOriginId node,
{
ereport(ERROR,
(errcode(ERRCODE_OBJECT_IN_USE),
errmsg("replication origin with ID %u is already active for PID %d",
errmsg("replication origin with ID %d is already active for PID %d",
replication_state->roident,
replication_state->acquired_by)));
}
Expand All @@ -948,7 +948,7 @@ replorigin_advance(RepOriginId node,
if (replication_state == NULL && free_state == NULL)
ereport(ERROR,
(errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
errmsg("could not find free replication state slot for replication origin with ID %u",
errmsg("could not find free replication state slot for replication origin with ID %d",
node),
errhint("Increase max_replication_slots and try again.")));

Expand Down Expand Up @@ -1126,7 +1126,7 @@ replorigin_session_setup(RepOriginId node)
{
ereport(ERROR,
(errcode(ERRCODE_OBJECT_IN_USE),
errmsg("replication origin with ID %u is already active for PID %d",
errmsg("replication origin with ID %d is already active for PID %d",
curstate->roident, curstate->acquired_by)));
}

Expand All @@ -1138,7 +1138,7 @@ replorigin_session_setup(RepOriginId node)
if (session_replication_state == NULL && free_slot == -1)
ereport(ERROR,
(errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
errmsg("could not find free replication state slot for replication origin with ID %u",
errmsg("could not find free replication state slot for replication origin with ID %d",
node),
errhint("Increase max_replication_slots and try again.")));
else if (session_replication_state == NULL)
Expand Down
2 changes: 2 additions & 0 deletions src/backend/replication/logical/reorderbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,8 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn,
Relation relation = NULL;
Oid reloid;

CHECK_FOR_INTERRUPTS();

/*
* We can't call start stream callback before processing first
* change.
Expand Down
Loading
Loading