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

Commit0df88a6

Browse files
committed
Don't spuriously report FD_SETSIZE exhaustion on Windows.
Starting on 2023-08-03, this intermittently terminated a "pgbench -C"test in CI. It could affect a high-client-count "pgbench" without "-C".While parallel reindexdb and vacuumdb reach the same problematic check,sufficient client count and/or connection turnover is less plausible forthem. Given the lack of examples from the buildfarm or from manualbuilds, reproducing this must entail rare operating systemconfigurations. Also correct the associated error message, which waswrong for non-Windows. Back-patch to v12, where the pgbench check firstappeared. While v11 vacuumdb has the problematic check, reaching itwith typical vacuumdb usage is implausible.Reviewed by Thomas Munro.Discussion:https://postgr.es/m/CA+hUKG+JwvTNdcyJTriy9BbtzF1veSRQ=9M_ZKFn9_LqE7Kp7Q@mail.gmail.com
1 parentd26f33c commit0df88a6

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7136,15 +7136,22 @@ clear_socket_set(socket_set *sa)
71367136
staticvoid
71377137
add_socket_to_set(socket_set*sa,intfd,intidx)
71387138
{
7139+
/* See connect_slot() for background on this code. */
7140+
#ifdefWIN32
7141+
if (sa->fds.fd_count+1 >=FD_SETSIZE)
7142+
{
7143+
pg_log_fatal("too many concurrent database clients for this platform: %d",
7144+
sa->fds.fd_count+1);
7145+
exit(1);
7146+
}
7147+
#else
71397148
if (fd<0||fd >=FD_SETSIZE)
71407149
{
7141-
/*
7142-
* Doing a hard exit here is a bit grotty, but it doesn't seem worth
7143-
* complicating the API to make it less grotty.
7144-
*/
7145-
pg_log_fatal("too many client connections for select()");
7150+
pg_log_fatal("socket file descriptor out of range for select(): %d",
7151+
fd);
71467152
exit(1);
71477153
}
7154+
#endif
71487155
FD_SET(fd,&sa->fds);
71497156
if (fd>sa->maxfd)
71507157
sa->maxfd=fd;

‎src/fe_utils/parallel_slot.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,40 @@ connect_slot(ParallelSlotArray *sa, int slotno, const char *dbname)
297297
slot->connection=connectDatabase(sa->cparams,sa->progname,sa->echo, false, true);
298298
sa->cparams->override_dbname=old_override;
299299

300-
if (PQsocket(slot->connection) >=FD_SETSIZE)
300+
/*
301+
* POSIX defines FD_SETSIZE as the highest file descriptor acceptable to
302+
* FD_SET() and allied macros. Windows defines it as a ceiling on the
303+
* count of file descriptors in the set, not a ceiling on the value of
304+
* each file descriptor; see
305+
* https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select
306+
* and
307+
* https://learn.microsoft.com/en-us/windows/win32/api/winsock/ns-winsock-fd_set.
308+
* We can't ignore that, because Windows starts file descriptors at a
309+
* higher value, delays reuse, and skips values. With less than ten
310+
* concurrent file descriptors, opened and closed rapidly, one can reach
311+
* file descriptor 1024.
312+
*
313+
* Doing a hard exit here is a bit grotty, but it doesn't seem worth
314+
* complicating the API to make it less grotty.
315+
*/
316+
#ifdefWIN32
317+
if (slotno >=FD_SETSIZE)
301318
{
302-
pg_log_fatal("too many jobs for this platform");
319+
pg_log_fatal("too many jobs for this platform: %d",slotno);
303320
exit(1);
304321
}
322+
#else
323+
{
324+
intfd=PQsocket(slot->connection);
325+
326+
if (fd >=FD_SETSIZE)
327+
{
328+
pg_log_fatal("socket file descriptor out of range for select(): %d",
329+
fd);
330+
exit(1);
331+
}
332+
}
333+
#endif
305334

306335
/* Setup the connection using the supplied command, if any. */
307336
if (sa->initcmd)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp