Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]

From: "H(dot)Merijn Brand" <h(dot)m(dot)brand(at)xs4all(dot)nl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Simon Riggs <simon(at)2ndQuadrant(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: [Fwd: DBD::Pg on HP-UX 11.31 64bit]
Date: 2010-12-16 16:48:03
Message-ID: 20101216174803.20b2b6db@pc09.procura.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, 14 Dec 2010 15:16:36 -0500, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

Thanks for the answer. I think all of this makes sense in reading
further into the HP-UX 11.31 socket docs. Please read on as I found a
workaround, but that is probably NOT *the* solution.

> Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:
> > FW
> > From: H.Merijn Brand <h(dot)m(dot)brand(at)xs4all(dot)nl>
> > I have postgres running on most my HP-UX varieties, ranging from HP-UX
> > 10.20/32bit through 11.31/64bit. It works fine everywhere, except on
> > HP-UX 11.31-ipf in 64bit mode. Note that this is Itanium architecture.
>
> > postgres' own test suite passes, but all connects fail with DBD::Pg.
>
> That's pretty odd. What seems to be failing here:
>
> > This is perl, v5.10.1 (*) built for IA64.ARCHREV_0-LP64
> > getsockopt (3, SOL_SOCKET, SO_ERROR, 0x9fffffffffffdb84, 0x9fffffffffffdb98) ERR#22 EINVAL
>
> is this bit of code in libpq:
>
> int optval;
> ACCEPT_TYPE_ARG3 optlen = sizeof(optval);
> ...
> if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,
> (char *) &optval, &optlen) == -1)
> {
> appendPQExpBuffer(&conn->errorMessage,
> libpq_gettext("could not get socket error status: %s\n"),
> SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
> goto error_return;
> }

This is what the docs on HP-UX say:

int getsockopt (
int s,
int level,
int optname,
void *optval,
int *optlen
);

UNIX 03 Only (X/Open Sockets)

int getsockopt (
int s,
int level,
int optname,
void *__restrict optval,
socklen_t *__restrict optlen
);

the includes tell me

src/include/pg_config.h:#define ACCEPT_TYPE_ARG3 size_t

That is already some sort of inconsistency

AF_CCITT only
#include <x25/x25addrstr.h>

int accept (int s, void *addr, int *addrlen);

UNIX 03 only (X/Open Sockets)
int accept (
int s,
struct sockaddr *__restrict addr,
socklen_t *__restrict addrlen
);

To use X/Open sockets, which seems to me the better option for
postgresql, I changed scr/Makefile.global =>

CC = cc
CFLAGS = -O2 -g -Ae -z +Z +DD64 -D_XOPEN_SOURCE=600
LIBS = -lssl -lcrypto -lxnet -lz -lm
LDFLAGS = -Wl,+vnocompatwarnings +DD64 -L/usr/local/ia64/lib \
-L/usr/lib/hpux64 -L/usr/contrib/X11R6/lib/hpux64 -s \
-L/usr/local/lib -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib

To ensure optimal alignment, I also added

#pragma pack 16

to all header files

However that made no difference in the end-result:

connect (3, 0x6000000000849280, 16) ERR#245 EINPROGRESS
poll (0x9fffffffffffdba0, 1, -1) = 1
getsockopt (3, SOL_SOCKET, SO_ERROR, 0x9fffffffffffdb94, 0x9fffffffffffdba8) ERR#22 EINVAL

HOWEVER

With

tcsh> setenv LD_PRELOAD /usr/lib/hpux64/libxnet.so.1
bash> export LD_PRELOAD=/usr/lib/hpux64/libxnet.so.1

DBD-Pg-2.17.1 559 > make test
PGINITDB="/pro/pgsql-8.4.5/bin/initdb" PERL_DL_NONLAZY=1 /pro/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-signature.t .... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ......... ok
t/01connect.t ....... 4/13 #
# DBI Version 1.615
# DBD::Pg Version 2.17.1
# Perl Version 5.10.1
# OS hpux
# PostgreSQL (compiled) 80405
# PostgreSQL (target) 80404
# PostgreSQL (reported) PostgreSQL 8.4.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839], 64-bit
# Default port 5432
# DBI_DSN dbi:Pg:
# DBI_USER postgres
# Test schema dbd_pg_testschema
# PGDATABASE testdb
# PGHOST 12.13.14.15
# array_nulls on
# backslash_quote safe_encoding
# client_encoding UTF8
# server_encoding UTF8
# standard_conforming_strings off
t/01connect.t ....... ok
t/01constants.t ..... ok
t/02attribs.t ....... 48/249
# Failed test 'Failed ping returns a SQLSTATE code of 08000'
# at t/02attribs.t line 1597.
# got: '22000'
# expected: '08000'
t/02attribs.t ....... 247/249 # Looks like you failed 1 test of 249.
t/02attribs.t ....... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/249 subtests
(less 1 skipped subtest: 247 okay)
t/03dbmethod.t ...... ok
t/03smethod.t ....... ok
t/04misc.t .......... ok
t/06bytea.t ......... ok
t/07copy.t .......... ok
t/08async.t ......... ok
t/09arrays.t ........ ok
t/12placeholders.t .. ok
t/20savepoints.t .... ok
t/99cleanup.t ....... 1/1 Removing test database directory
t/99cleanup.t ....... ok

Test Summary Report
-------------------
t/02attribs.t (Wstat: 256 Tests: 249 Failed: 1)
Failed test: 244
Non-zero exit status: 1
Files=15, Tests=1707, 21 wallclock secs ( 0.39 usr 0.09 sys + 2.62 cusr 0.90 csys = 4.00 CPU)
Result: FAIL
Failed 1/15 test programs. 1/1707 subtests failed.

As, at this point, there is no control over the library that perl itself is linked with:

Lib Real path Size Date Refs
------------------------------------ ------------------------------------ --------- ------------------- ----
/pro/bin/perl /pro/bin/perl 4419056 2009-10-05 09:30:15 13
/usr/lib/hpux64/libcl.so.1 /usr/lib/hpux64/libcl.so.1 69336 2007-02-15 22:47:27 3
/usr/lib/hpux64/libIO77.so.1 /usr/lib/hpux64/libIO77.so.1 3099480 2007-01-12 21:03:25 0
/usr/lib/hpux64/libunwind.so.1 /usr/lib/hpux64/libunwind.so.1 558120 2007-02-15 22:47:31 1
/usr/lib/hpux64/libuca.so.1 /usr/lib/hpux64/libuca.so.1 85680 2007-02-15 22:36:36 0
/usr/lib/hpux64/libpthread.so.1 /usr/lib/hpux64/libpthread.so.1 1528360 2008-07-09 23:24:48 0
/usr/lib/hpux64/libnsl.so.1 /usr/lib/hpux64/libnsl.so.1 1510840 2008-07-03 19:16:00 3
/usr/lib/hpux64/libc.so.1 /usr/lib/hpux64/libc.so.1 4898520 2009-06-06 01:23:40 1
/usr/lib/hpux64/libdl.so.1 /usr/lib/hpux64/libdl.so.1 78168 2010-06-24 20:02:37 0
/usr/lib/hpux64/libxti.so.1 /usr/lib/hpux64/libxti.so.1 298840 2008-06-28 11:59:19 0
/usr/lib/hpux64/libnm.so /usr/lib/hpux64/libnm.so.1 244296 2007-02-15 22:32:55 0
/usr/lib/hpux64/libm.so.1 /usr/lib/hpux64/libm.so.1 2026976 2007-02-15 22:47:28 0
/usr/lib/hpux64/libsec.so.1 /usr/lib/hpux64/libsec.so.1 580112 2008-04-25 17:29:35 1

As getsockopt () is defined in libc.so.1, that one is used before it uses
the libxnet one as required/used by libpq.

> It's not clear at all how that would fail in the Perl environment if it
> works standalone. I could believe getting EINVAL if we had determined
> the wrong datatype for ACCEPT_TYPE_ARG3, but that ought to fail
> standalone too, I should think. Anyway it would be worth checking what
> configure identified as ACCEPT_TYPE_ARG3 and comparing that to the docs
> for getsockopt.

--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.3 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2010-12-16 16:57:06 Re: Urgent inquiry
Previous Message Tom Lane 2010-12-16 15:34:26 Re: index corruption on composite primary key indexes