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

Commit3895e91

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 parent890a73b commit3895e91

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6710,15 +6710,22 @@ clear_socket_set(socket_set *sa)
67106710
staticvoid
67116711
add_socket_to_set(socket_set*sa,intfd,intidx)
67126712
{
6713+
/* See connect_slot() for background on this code. */
6714+
#ifdefWIN32
6715+
if (sa->fds.fd_count+1 >=FD_SETSIZE)
6716+
{
6717+
pg_log_fatal("too many concurrent database clients for this platform: %d",
6718+
sa->fds.fd_count+1);
6719+
exit(1);
6720+
}
6721+
#else
67136722
if (fd<0||fd >=FD_SETSIZE)
67146723
{
6715-
/*
6716-
* Doing a hard exit here is a bit grotty, but it doesn't seem worth
6717-
* complicating the API to make it less grotty.
6718-
*/
6719-
pg_log_fatal("too many client connections for select()");
6724+
pg_log_fatal("socket file descriptor out of range for select(): %d",
6725+
fd);
67206726
exit(1);
67216727
}
6728+
#endif
67226729
FD_SET(fd,&sa->fds);
67236730
if (fd>sa->maxfd)
67246731
sa->maxfd=fd;

‎src/bin/scripts/scripts_parallel.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,39 @@ ParallelSlotsSetup(const ConnParams *cparams,
223223
conn=connectDatabase(cparams,progname,echo, false, true);
224224

225225
/*
226-
* Fail and exit immediately if trying to use a socket in an
227-
* unsupported range. POSIX requires open(2) to use the lowest
228-
* unused file descriptor and the hint given relies on that.
226+
* POSIX defines FD_SETSIZE as the highest file descriptor
227+
* acceptable to FD_SET() and allied macros. Windows defines it
228+
* as a ceiling on the count of file descriptors in the set, not a
229+
* ceiling on the value of each file descriptor; see
230+
* https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select
231+
* and
232+
* https://learn.microsoft.com/en-us/windows/win32/api/winsock/ns-winsock-fd_set.
233+
* We can't ignore that, because Windows starts file descriptors
234+
* at a higher value, delays reuse, and skips values. With less
235+
* than ten concurrent file descriptors, opened and closed
236+
* rapidly, one can reach file descriptor 1024.
237+
*
238+
* Doing a hard exit here is a bit grotty, but it doesn't seem
239+
* worth complicating the API to make it less grotty.
229240
*/
230-
if (PQsocket(conn) >=FD_SETSIZE)
241+
#ifdefWIN32
242+
if (i >=FD_SETSIZE)
231243
{
232-
pg_log_fatal("too many jobs for this platform -- try %d",i);
244+
pg_log_fatal("too many jobs for this platform: %d",i);
233245
exit(1);
234246
}
247+
#else
248+
{
249+
intfd=PQsocket(conn);
250+
251+
if (fd >=FD_SETSIZE)
252+
{
253+
pg_log_fatal("socket file descriptor out of range for select(): %d",
254+
fd);
255+
exit(1);
256+
}
257+
}
258+
#endif
235259

236260
init_slot(slots+i,conn);
237261
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp