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

Commit1102f4e

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 parent1e81d3e commit1102f4e

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7815,14 +7815,23 @@ clear_socket_set(socket_set *sa)
78157815
staticvoid
78167816
add_socket_to_set(socket_set*sa,intfd,intidx)
78177817
{
7818+
/* See connect_slot() for background on this code. */
7819+
#ifdefWIN32
7820+
if (sa->fds.fd_count+1 >=FD_SETSIZE)
7821+
{
7822+
pg_log_error("too many concurrent database clients for this platform: %d",
7823+
sa->fds.fd_count+1);
7824+
exit(1);
7825+
}
7826+
#else
78187827
if (fd<0||fd >=FD_SETSIZE)
78197828
{
7820-
/*
7821-
* Doing a hard exit here is a bit grotty, but it doesn't seem worth
7822-
* complicating the API to make it less grotty.
7823-
*/
7824-
pg_fatal("too many client connections for select()");
7829+
pg_log_error("socket file descriptor out of range for select(): %d",
7830+
fd);
7831+
pg_log_error_hint("Try fewer concurrent database clients.");
7832+
exit(1);
78257833
}
7834+
#endif
78267835
FD_SET(fd,&sa->fds);
78277836
if (fd>sa->maxfd)
78287837
sa->maxfd=fd;

‎src/fe_utils/parallel_slot.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,41 @@ 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)
301-
pg_fatal("too many jobs for this platform");
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)
318+
{
319+
pg_log_error("too many jobs for this platform: %d",slotno);
320+
exit(1);
321+
}
322+
#else
323+
{
324+
intfd=PQsocket(slot->connection);
325+
326+
if (fd >=FD_SETSIZE)
327+
{
328+
pg_log_error("socket file descriptor out of range for select(): %d",
329+
fd);
330+
pg_log_error_hint("Try fewer jobs.");
331+
exit(1);
332+
}
333+
}
334+
#endif
302335

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp