Thread: Re: pgstat: remove delayed destroy / pipe:

Re: pgstat: remove delayed destroy / pipe:

From
"Magnus Hagander"
Date:
> It turns out the problem is that port/pipe.c is compiled with
> -DFRONTEND and include/port/win32.h wraps the recv to
> pgwin32_recv macro in a #ifndef FRONTEND.  We've actually
> been using the WinSock recv function directly (verified with gcc -E).

That's definitly wrong.
Looks like this file needs a _srv version in the Makefile.  Bruce?

Just a thought - might this affect more things that rely on FRONTEND
defines in the headers? How bad would it be to just make libpgport build
two complete sets of object files, one for server and one for frontend,
instead of special-casing which files are rebuilt?


> If somebody else could take over actually fixing this, that
> would be great.  As I mentioned before, we're heading away
> from Windows for the time being.

I can try - though I only have development servers on win32 these days,
and have never been bitten by this actual problem. So we'd still much
appreciate yuor help in testing a solution once it's there..

//Magnus

Re: pgstat: remove delayed destroy / pipe:

From
"Peter Brant"
Date:
As long as we have a Win32 test server around, I'm happy to help.

If you have a multi-processor development server, it's easy to recreate
though.  Just load up the server (pgbench is fine) and wait a few
minutes.  Single processor machines don't seem to be affected.

Pete

>>> "Magnus Hagander" <mha@sollentuna.net> 05/02/06 10:13 am >>>
I can try - though I only have development servers on win32 these
days,
and have never been bitten by this actual problem. So we'd still much
appreciate yuor help in testing a solution once it's there..


Re: pgstat: remove delayed destroy / pipe:

From
"Peter Brant"
Date:
I take that back.  My local Postgres just didn't have stats_block_level
and stats_row_level turned on.  It happens on single processor machines
too.

Pete

>>> "Peter Brant" <Peter.Brant@wicourts.gov> 05/02/06 6:29 pm >>>
minutes.  Single processor machines don't seem to be affected.


Re: pgstat: remove delayed destroy / pipe:

From
Bruce Momjian
Date:
Magnus Hagander wrote:
> > It turns out the problem is that port/pipe.c is compiled with
> > -DFRONTEND and include/port/win32.h wraps the recv to
> > pgwin32_recv macro in a #ifndef FRONTEND.  We've actually
> > been using the WinSock recv function directly (verified with gcc -E).
>
> That's definitly wrong.
> Looks like this file needs a _srv version in the Makefile.  Bruce?

Wow!  That is disturbing.  I tried to minimize the affect of FRONTEND,
but obviously I never though about the affect on include files that use
FRONTEND.  Seems it is only Win32 that used FRONTEND in includes (except
for pg_wchar.h, which is used by libpq and already built independently).

> Just a thought - might this affect more things that rely on FRONTEND
> defines in the headers? How bad would it be to just make libpgport build
> two complete sets of object files, one for server and one for frontend,
> instead of special-casing which files are rebuilt?

The attached patch does exactly what you suggest.  I think it has to be
patched to 8.0.X, 8.1.X, and HEAD.  I will apply in 24-48 hours.

--
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/port/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/port/Makefile,v
retrieving revision 1.30
diff -c -c -r1.30 Makefile
*** src/port/Makefile    9 Dec 2005 21:19:36 -0000    1.30
--- src/port/Makefile    7 May 2006 01:05:32 -0000
***************
*** 26,37 ****
  override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
  LIBS += $(PTHREAD_LIBS)

! # Replace object files that use FRONTEND define
! LIBOBJS_SRV := $(LIBOBJS)
! LIBOBJS_SRV := $(patsubst dirmod.o,dirmod_srv.o, $(LIBOBJS_SRV))
! LIBOBJS_SRV := $(patsubst exec.o,exec_srv.o, $(LIBOBJS_SRV))
! LIBOBJS_SRV := $(patsubst getaddrinfo.o,getaddrinfo_srv.o, $(LIBOBJS_SRV))
! LIBOBJS_SRV := $(patsubst thread.o,thread_srv.o, $(LIBOBJS_SRV))

  all: libpgport.a libpgport_srv.a

--- 26,33 ----
  override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
  LIBS += $(PTHREAD_LIBS)

! # Replace all object files so they use FRONTEND define
! LIBOBJS_SRV := $(LIBOBJS:%.o=%_srv.o)

  all: libpgport.a libpgport_srv.a

***************
*** 60,72 ****
  libpgport_srv.a: $(LIBOBJS_SRV)
      $(AR) $(AROPT) $@ $^

! dirmod_srv.o: dirmod.c
!     $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
!
! exec_srv.o: exec.c
!     $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
!
! getaddrinfo_srv.o: getaddrinfo.c
      $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@

  # No thread flags for server version
--- 56,62 ----
  libpgport_srv.a: $(LIBOBJS_SRV)
      $(AR) $(AROPT) $@ $^

! %_srv.o: %.c
      $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@

  # No thread flags for server version

Re: pgstat: remove delayed destroy / pipe:

From
Bruce Momjian
Date:
Patch applied to HEAD, 8.1.X and 8.0.X.

---------------------------------------------------------------------------

Bruce Momjian wrote:
> Magnus Hagander wrote:
> > > It turns out the problem is that port/pipe.c is compiled with
> > > -DFRONTEND and include/port/win32.h wraps the recv to
> > > pgwin32_recv macro in a #ifndef FRONTEND.  We've actually
> > > been using the WinSock recv function directly (verified with gcc -E).
> >
> > That's definitly wrong.
> > Looks like this file needs a _srv version in the Makefile.  Bruce?
>
> Wow!  That is disturbing.  I tried to minimize the affect of FRONTEND,
> but obviously I never though about the affect on include files that use
> FRONTEND.  Seems it is only Win32 that used FRONTEND in includes (except
> for pg_wchar.h, which is used by libpq and already built independently).
>
> > Just a thought - might this affect more things that rely on FRONTEND
> > defines in the headers? How bad would it be to just make libpgport build
> > two complete sets of object files, one for server and one for frontend,
> > instead of special-casing which files are rebuilt?
>
> The attached patch does exactly what you suggest.  I think it has to be
> patched to 8.0.X, 8.1.X, and HEAD.  I will apply in 24-48 hours.
>
> --
>   Bruce Momjian   http://candle.pha.pa.us
>   EnterpriseDB    http://www.enterprisedb.com
>
>   + If your life is a hard drive, Christ can be your backup. +

> Index: src/port/Makefile
> ===================================================================
> RCS file: /cvsroot/pgsql/src/port/Makefile,v
> retrieving revision 1.30
> diff -c -c -r1.30 Makefile
> *** src/port/Makefile    9 Dec 2005 21:19:36 -0000    1.30
> --- src/port/Makefile    7 May 2006 01:05:32 -0000
> ***************
> *** 26,37 ****
>   override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
>   LIBS += $(PTHREAD_LIBS)
>
> ! # Replace object files that use FRONTEND define
> ! LIBOBJS_SRV := $(LIBOBJS)
> ! LIBOBJS_SRV := $(patsubst dirmod.o,dirmod_srv.o, $(LIBOBJS_SRV))
> ! LIBOBJS_SRV := $(patsubst exec.o,exec_srv.o, $(LIBOBJS_SRV))
> ! LIBOBJS_SRV := $(patsubst getaddrinfo.o,getaddrinfo_srv.o, $(LIBOBJS_SRV))
> ! LIBOBJS_SRV := $(patsubst thread.o,thread_srv.o, $(LIBOBJS_SRV))
>
>   all: libpgport.a libpgport_srv.a
>
> --- 26,33 ----
>   override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
>   LIBS += $(PTHREAD_LIBS)
>
> ! # Replace all object files so they use FRONTEND define
> ! LIBOBJS_SRV := $(LIBOBJS:%.o=%_srv.o)
>
>   all: libpgport.a libpgport_srv.a
>
> ***************
> *** 60,72 ****
>   libpgport_srv.a: $(LIBOBJS_SRV)
>       $(AR) $(AROPT) $@ $^
>
> ! dirmod_srv.o: dirmod.c
> !     $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
> !
> ! exec_srv.o: exec.c
> !     $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
> !
> ! getaddrinfo_srv.o: getaddrinfo.c
>       $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
>
>   # No thread flags for server version
> --- 56,62 ----
>   libpgport_srv.a: $(LIBOBJS_SRV)
>       $(AR) $(AROPT) $@ $^
>
> ! %_srv.o: %.c
>       $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
>
>   # No thread flags for server version

>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

--
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +