Thread: Failed pgbench: setrandom invalid maximum number 0

Failed pgbench: setrandom invalid maximum number 0

From
Greg Sabino Mullane
Date:
Seeing the following on an old box I use for testing various=20
things. Thought it was something to do with my box at first,=20
but the problem seems to only occur in >=3D 8.4. But it's also=20
not pgbench alone, as it was working fine one day, and not the=20
next. Here's what I now get on 8.4, 9.0, and 9.1:

$ pgbench btest1 -n

setrandom: invalid maximum number 0
Client 0 aborted in state 3. Execution meta-command failed.
transaction type: TPC-B (sort of)
scaling factor: 0
query mode: simple
number of clients: 1
number of threads: 1
number of transactions per client: 10
number of transactions actually processed: 0/10
tps =3D 0.000000 (including connections establishing)
tps =3D 0.000000 (excluding connections establishing)

What I get on 8.3 and older is this:

$ pgbench btest1 -n

transaction type: TPC-B (sort of)
scaling factor: 1
number of clients: 1
number of transactions per client: 10
number of transactions actually processed: 10/10
tps =3D 332.005312 (including connections establishing)
tps =3D 372.703216 (excluding connections establishing)

Here's a snippet of strace for the failing run:

<<closing .pgpass>>
munmap(0xb773b000, 4096)                =3D 0
socket(PF_FILE, SOCK_STREAM, 0)         =3D 3
fcntl64(3, F_SETFL, O_RDONLY|O_NONBLOCK) =3D 0
fcntl64(3, F_SETFD, FD_CLOEXEC)         =3D 0
connect(3, {sa_family=3DAF_FILE, path=3D"/tmp/.s.PGSQL.5900"}, 110) =3D 0
getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) =3D 0
getsockname(3, {sa_family=3DAF_FILE, NULL}, [2]) =3D 0
time(NULL)                              =3D 1306638084
time(NULL)                              =3D 1306638084
poll([{fd=3D3, events=3DPOLLOUT|POLLERR}], 1, 10000) =3D 1 ([{fd=3D3, reven=
ts=3DPOLLOUT}])
send(3, "\0\0\0#\0\3\0\0user\0greg\0database\0btest"..., 35, MSG_NOSIGNAL) =
=3D 35
time(NULL)                              =3D 1306638084
poll([{fd=3D3, events=3DPOLLIN|POLLERR}], 1, 10000) =3D 1 ([{fd=3D3, revent=
s=3DPOLLIN}])
recv(3, "R\0\0\0\10\0\0\0\0S\0\0\0\26application_name\0\0"..., 16384, 0) =
=3D 332
gettimeofday({1306638084, 217401}, NULL) =3D 0
write(2, "setrandom: invalid maximum numbe"..., 36setrandom: invalid maximu=
m number 0
) =3D 36
write(2, "Client 0 aborted in state 3. Exe"..., 60Client 0 aborted in state=
 3. Execution meta-command failed.
) =3D 60
<<writing all the other lines seen above>>

--=20
Greg Sabino Mullane greg@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8

Re: Failed pgbench: setrandom invalid maximum number 0

From
Tom Lane
Date:
Greg Sabino Mullane <greg@endpoint.com> writes:
> Seeing the following on an old box I use for testing various
> things. Thought it was something to do with my box at first,
> but the problem seems to only occur in >= 8.4. But it's also
> not pgbench alone, as it was working fine one day, and not the
> next. Here's what I now get on 8.4, 9.0, and 9.1:

> $ pgbench btest1 -n

> setrandom: invalid maximum number 0

That's not valid syntax.  Some versions of getopt() take it upon
themselves to rearrange the switch order, some do not ...

            regards, tom lane

Re: Failed pgbench: setrandom invalid maximum number 0

From
Greg Sabino Mullane
Date:
> That's not valid syntax.  Some versions of getopt() take it upon
> themselves to rearrange the switch order, some do not ...

Sorry: I should have made clear this happens without the -n as well,=20
I just wanted to make the sample output a little smaller.

--=20
Greg Sabino Mullane greg@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8

Re: Failed pgbench: setrandom invalid maximum number 0

From
Greg Sabino Mullane
Date:
> > but the problem seems to only occur in >=3D 8.4. But it's also=20

Good news and bad news. The good news is that it started occuring on=20
all versions of pgbench, which makes it more likely to be a problem=20
with my system rather than pgbench (although that error message=20
sure is inscrutable). The bad news is I had to reboot the box for=20
other reasons and I cannot duplicate the issue. Yet. :)

--=20
Greg Sabino Mullane greg@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8

Re: Failed pgbench: setrandom invalid maximum number 0

From
Greg Sabino Mullane
Date:
> setrandom: invalid maximum number 0

Okay, nevermind, user error: some other process was deleting a=20
row from pgbench_branches, and the pgbench.c happily set scale=20
to 0 from the 'select count(*) from pgbench_branches' query=20
inside of it, until it gives the totally not-helpful error=20
seen above later on as it sets :scale to 0, multiplies the tpc_b=20
default number of branches by zero, and then complains when the=20
minimum number of branches (1) is less than the max allowed (0).=20

Oddly enough, the code checks for the count(*) < 0 but not <=3D 0.

--=20
Greg Sabino Mullane greg@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8