Re: multi-threaded pgbench

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Josh Williams <joshwilliams(at)ij(dot)net>
Cc: Greg Smith <gsmith(at)gregsmith(dot)com>, Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: multi-threaded pgbench
Date: 2009-07-30 09:28:03
Message-ID: 9837222c0907300228v53a98596g199902cacd3eae5e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 29, 2009 at 23:31, Josh Williams<joshwilliams(at)ij(dot)net> wrote:
> On Tue, 2009-07-28 at 23:38 -0400, Josh Williams wrote:
>> Huh, running the patched version on a single thread with 128 clients
>> just got it to crash.  Actually consistently, three times now.  Will try
>> the same thing on the development box tomorrow morning to get some
>> better debugging information.
>
> So yeah, buffer overrun.
>
> In pgbench.c FD_SETSIZE is redefined to get around the Windows default
> of 64.  But this is done after bringing in winsock2.h (a couple levels
> in as a result of first including postgres_fe.h).  So any fd_set is
> built with an array of 64 descriptors, while pgbench thinks it has 1024
> available to work with.
>
> This was introduced a while back; the multi-threaded patch just makes it
> visible by giving it an important pointer to write over.  Previously it
> would just run over into the loop counter (and probably a couple other
> things) and thus it'd continue on happily with the [sub]set it has.

Yikes.
Yeah, this is fallout from the hacking we did with moving the winsock
includes around a while back. At the time the #defines were added,
winsock came in through the win32.h file :S

> In either case this seems to be a simple fix, to move that #define
> earlier (see pgbench_win32.patch.)

Yes, and it seems to be entirely unrelated to the multithreaded patch.
Thus, applied as a separate patch.

--
Magnus Hagander
Self: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Santosh Ahuja 2009-07-30 10:17:17 Compiling Postgres 8.3.7 MSVC 2005
Previous Message Magnus Hagander 2009-07-30 09:03:20 Re: 8.4 win32 shared memory patch