Обсуждение: Issue with v11.0 within jsonb_plperl tests in 32bit on AIX

Поиск
Список
Период
Сортировка

Issue with v11.0 within jsonb_plperl tests in 32bit on AIX

От
"REIX, Tony"
Дата:

Hi,


I'm building PostgreSQL v11.0 on AIX (6.1, 7.1, & 7.2).


The 2 new tests jsonb_plperl fail in 32bit, not in 64bit.

All other tests are OK.


 - Same issue for all 3 versions of AIX

 - Version of Perl :     5.24.0

 - Version of Python: 2.7.12



I have traced details, but it is still unclear to me what is the root cause.

I'd like to have some help.

Does someone has already built and tested PostgreSQL v11.0 in 32bit on Linux/x86_64 ?


Looking at details, it seems that some control of the conversion of infinity to json is not done in 32bit.


Do you think that this issue comes from inside PostgreSQL code of from the AIX tools used by PostgreSQL ?


Thanks


Tony



1) Traces of the execution of the tests:


for extra in contrib/jsonb_plperl; do gmake -C '../..'/$extra DESTDIR='/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit'/tmp_install install >>'/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit'/tmp_install/log/install.log || exit; done
PATH="/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/tmp_install/opt/freeware/bin:$PATH" LIBPATH="/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/tmp_install/opt/freeware/lib:$LIBPATH" ../../src/test/regress/pg_regress --temp-instance=./tmp_check --inputdir=. --bindir=     --dbname=contrib_regression jsonb_plperl jsonb_plperlu
============== creating temporary instance            ==============
============== initializing database system           ==============
============== starting postmaster                    ==============
running on port 60848 with PID 22610390
============== creating database "contrib_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== running regression test queries        ==============
test jsonb_plperl                 ... FAILED
test jsonb_plperlu                ... FAILED
============== shutting down postmaster               ==============

======================
 2 of 2 tests failed.
======================


2) Details of the trace

64bit : OK
32bit : 2 failures :
============== running regression test queries        ==============
test jsonb_plperl                 ... FAILED
test jsonb_plperlu                ... FAILED
# diff ./contrib/jsonb_plperl/expected/jsonb_plperl.out ./contrib/jsonb_plperl/results/jsonb_plperl.out
68,70c68,70
<  roundtrip 
< -----------
<  1
---
>                                                                                                                                                                    roundtrip                                                                                                                                                                   
>  ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>   0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000266336279953129
74,75c74,78
< ERROR:  cannot convert infinity to jsonb
< CONTEXT:  PL/Perl function "roundtrip"
---
>                                                                                                                                                                     roundtrip                                                                                                                                                                  
>   ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>  0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000266336287858179
> (1 row)
>
etc........


cd contrib/jsonb_plperl/

sql/jsonb_plperl.sql :

...
CREATE FUNCTION roundtrip(val jsonb, ref text = ) RETURNS jsonb
LANGUAGE plperl
TRANSFORM FOR TYPE jsonb
AS $$
# can't use Data::Dumper, but let's at least check for unexpected ref type
die 'unexpected '.(ref($_[0]) || 'not a').' reference'   if ref($_[0]) ne $_[1];
return $_[0];
$$;


SELECT roundtrip('null') is null;
SELECT roundtrip('1');
SELECT roundtrip('1E+131071');
SELECT roundtrip('-1');
SELECT roundtrip('1.2');
SELECT roundtrip('-1.2');
SELECT roundtrip('"string"');
SELECT roundtrip('"NaN"');
...
How to reproduce :

su pgstbf -c "(set -x; ulimit -a; cd /opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/contrib/jsonb_plperl || exit 1; \      ulimit -f unlimited; \      PATH="/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/tmp_install/opt/freeware/bin:$PATH"        \      LIBPATH="/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/tmp_install/opt/freeware/lib:$LIBPATH"  \      ../../src/test/regress/pg_regress --debug       \      --temp-instance=./tmp_check     \      --inputdir=.    \      --bindir=       \      --dbname=contrib_regression     \      jsonb_plperl    \      jsonb_plperlu )"
../../src/test/regress/pg_regress : executable
If one uses the 64bit version of pg_regress : Same issue. Thus, not an issue due to pg_regress.
--debug option generates traces in files : log/initdb.log log/postmaster.log


a) Comparaison of files: initdb.log 64bit vs 32 bit :
  # export D=`date +"%Y-%m-%d"` # cat log/initdb.log | awk -v D=$D '{if($1==D){print $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15}else{print $0}}' > /tmp/initdb.log.32 Idem en 64bit
 # diff /tmp/initdb.log.64 /tmp/initdb.log.32  ...  23c23  < creating directory /home2/freeware/src/packages/BUILD/postgresql-11.0/64bit/contrib/jsonb_plperl/./tmp_check/data ... ok  ---  > creating directory /home2/freeware/src/packages/BUILD/postgresql-11.0/32bit/contrib/jsonb_plperl/./tmp_check/data ... ok  29c29  < running bootstrap script ... 2018-11-06 16:01:19.632 CST [21823838] DEBUG:  invoking IpcMemoryCreate(size=148676608)  ---  > running bootstrap script ... 2018-11-06 15:51:43.604 CST [26804718] DEBUG:  invoking IpcMemoryCreate(size=146415616)  33c33  < DEBUG: created dynamic shared memory control segment 944926165 (6928 bytes)   ---  > DEBUG: created dynamic shared memory control segment 203612733 (4620 bytes)   41c41  < NOTICE: database system was shut down at 2018-11-06 16:01:19 CST   ---  > NOTICE: database system was shut down at 2018-11-06 15:51:43 CST 
  146201,146202c146201,146202  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  147519,147520c147519,147520  < DEBUG: inserting column 3 value "8"       < DEBUG: inserted -> 8         ---  > DEBUG: inserting column 3 value "4"       > DEBUG: inserted -> 4       
  147553,147554c147553,147554  < DEBUG: inserting column 20 value "d"       < DEBUG: inserted -> d         ---  > DEBUG: inserting column 20 value "i"       > DEBUG: inserted -> i       
  148121,148122c148121,148122  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  148541,148542c148541,148542  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  151121,151122c151121,151122  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f         151181,151182c151181,151182
  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  151421,151422c151421,151422  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  153222,153223c153222,153223  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  155440,155441c155440,155441  < DEBUG: inserting column 3 value "8"       < DEBUG: inserted -> 8         ---  > DEBUG: inserting column 3 value "4"       > DEBUG: inserted -> 4       
  155474,155475c155474,155475  < DEBUG: inserting column 20 value "d"       < DEBUG: inserted -> d         ---  > DEBUG: inserting column 20 value "i"       > DEBUG: inserted -> i       
  ...
b) Comparaison of files: postmaster.log 64bit vs 32 bit :
 # cat log/postmaster.log | awk -v D=$D '{if($1==D){print $6, $7, $8, $9, $10, $11, $12, $13, $14, $15}else{print $0}}' > /tmp/postmaster.log.32
 # diff /tmp/postmaster.log.64 /tmp/postmaster.log.32
  246a248,249  > reaping dead processes         > server process (PID 18940280) exited with exit code 0   248c251  < DEBUG: postgres child[24969698]: starting with (      ---  > DEBUG: postgres child[18940282]: starting with (      253d255  < forked new backend, pid=24969698 socket=8       256,257c258  < reaping dead processes         < server process (PID 14549256) exited with exit code 0   ---  > forked new backend, pid=18940282 socket=8       745c746  < LOG: disconnection: session time: 0:00:00.142 user=pgstbf database=contrib_regression host=[local]    ---  > LOG: disconnection: session time: 0:00:00.010 user=pgstbf database=contrib_regression host=[local]    751,752c752  < server process (PID 24969698) exited with exit code 0   < forked new backend, pid=24969700 socket=8       ---  > server process (PID 18940282) exited with exit code 0   ...  3819,3821c3820
   < ERROR: cannot convert infinity to jsonb      < CONTEXT: PL/Perl function "roundtrip"        < STATEMENT: SELECT roundtrip('1E+131071');         ---  > DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0  ...  12572a12570,12571  > reaping dead processes         > server process (PID 18940284) exited with exit code 0   14324c14323  < INFO: $VAR1 =  '1' ;        ---  > INFO: $VAR1 =  '4.94065645841247e-324' ;        14573c14572  < INFO: $VAR1 = '0';        ---  > INFO: $VAR1 = '4.94065645841247e-324';
64bit:  ...  STATEMENT: SELECT roundtrip('true');  INFO: $VAR1 = '1';  CONTEXT: PL/Perl function "roundtrip"  DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0  DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0  LOG: statement: SELECT roundtrip('false');  LOG: parse tree:

32bit:  ...  STATEMENT: SELECT roundtrip('true');  INFO: $VAR1 = '4.94065645841247e-324' ;  CONTEXT: PL/Perl function "roundtrip"  DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0  DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0  LOG: statement: SELECT roundtrip('false');  LOG: parse tree:


Cordialement,

Tony Reix

tony.reix@atos.net

ATOS / Bull SAS
ATOS Expert
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France

RE: Issue with v11.0 within jsonb_plperl tests in 32bit on AIX

От
"REIX, Tony"
Дата:

Hummm The buildfarm does show that these tests are OK on AIX machines in 32bit, with GCC 4.8.1 .

Nuts !


Attached is the full diff between the expected results and the real results.


Cordialement,

Tony Reix

tony.reix@atos.net

ATOS / Bull SAS
ATOS Expert
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France



De : REIX, Tony
Envoyé : mardi 6 novembre 2018 17:26
À : pgsql-hackers@postgresql.org
Cc : REIX, Tony
Objet : Issue with v11.0 within jsonb_plperl tests in 32bit on AIX
 

Hi,


I'm building PostgreSQL v11.0 on AIX (6.1, 7.1, & 7.2).


The 2 new tests jsonb_plperl fail in 32bit, not in 64bit.

All other tests are OK.


 - Same issue for all 3 versions of AIX

 - Version of Perl :     5.24.0

 - Version of Python: 2.7.12



I have traced details, but it is still unclear to me what is the root cause.

I'd like to have some help.

Does someone has already built and tested PostgreSQL v11.0 in 32bit on Linux/x86_64 ?


Looking at details, it seems that some control of the conversion of infinity to json is not done in 32bit.


Do you think that this issue comes from inside PostgreSQL code of from the AIX tools used by PostgreSQL ?


Thanks


Tony



1) Traces of the execution of the tests:


for extra in contrib/jsonb_plperl; do gmake -C '../..'/$extra DESTDIR='/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit'/tmp_install install >>'/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit'/tmp_install/log/install.log || exit; done
PATH="/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/tmp_install/opt/freeware/bin:$PATH" LIBPATH="/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/tmp_install/opt/freeware/lib:$LIBPATH" ../../src/test/regress/pg_regress --temp-instance=./tmp_check --inputdir=. --bindir=     --dbname=contrib_regression jsonb_plperl jsonb_plperlu
============== creating temporary instance            ==============
============== initializing database system           ==============
============== starting postmaster                    ==============
running on port 60848 with PID 22610390
============== creating database "contrib_regression" ==============
CREATE DATABASE
ALTER DATABASE
============== running regression test queries        ==============
test jsonb_plperl                 ... FAILED
test jsonb_plperlu                ... FAILED
============== shutting down postmaster               ==============

======================
 2 of 2 tests failed.
======================


2) Details of the trace

64bit : OK
32bit : 2 failures :
============== running regression test queries        ==============
test jsonb_plperl                 ... FAILED
test jsonb_plperlu                ... FAILED
# diff ./contrib/jsonb_plperl/expected/jsonb_plperl.out ./contrib/jsonb_plperl/results/jsonb_plperl.out
68,70c68,70
<  roundtrip 
< -----------
<  1
---
>                                                                                                                                                                    roundtrip                                                                                                                                                                   
>  ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>   0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000266336279953129
74,75c74,78
< ERROR:  cannot convert infinity to jsonb
< CONTEXT:  PL/Perl function "roundtrip"
---
>                                                                                                                                                                     roundtrip                                                                                                                                                                  
>   ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>  0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000266336287858179
> (1 row)
>
etc........


cd contrib/jsonb_plperl/

sql/jsonb_plperl.sql :

...
CREATE FUNCTION roundtrip(val jsonb, ref text = ) RETURNS jsonb
LANGUAGE plperl
TRANSFORM FOR TYPE jsonb
AS $$
# can't use Data::Dumper, but let's at least check for unexpected ref type
die 'unexpected '.(ref($_[0]) || 'not a').' reference'   if ref($_[0]) ne $_[1];
return $_[0];
$$;


SELECT roundtrip('null') is null;
SELECT roundtrip('1');
SELECT roundtrip('1E+131071');
SELECT roundtrip('-1');
SELECT roundtrip('1.2');
SELECT roundtrip('-1.2');
SELECT roundtrip('"string"');
SELECT roundtrip('"NaN"');
...
How to reproduce :

su pgstbf -c "(set -x; ulimit -a; cd /opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/contrib/jsonb_plperl || exit 1; \      ulimit -f unlimited; \      PATH="/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/tmp_install/opt/freeware/bin:$PATH"        \      LIBPATH="/opt/freeware/src/packages/BUILD/postgresql-11.0/32bit/tmp_install/opt/freeware/lib:$LIBPATH"  \      ../../src/test/regress/pg_regress --debug       \      --temp-instance=./tmp_check     \      --inputdir=.    \      --bindir=       \      --dbname=contrib_regression     \      jsonb_plperl    \      jsonb_plperlu )"
../../src/test/regress/pg_regress : executable
If one uses the 64bit version of pg_regress : Same issue. Thus, not an issue due to pg_regress.
--debug option generates traces in files : log/initdb.log log/postmaster.log


a) Comparaison of files: initdb.log 64bit vs 32 bit :
  # export D=`date +"%Y-%m-%d"` # cat log/initdb.log | awk -v D=$D '{if($1==D){print $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15}else{print $0}}' > /tmp/initdb.log.32 Idem en 64bit
 # diff /tmp/initdb.log.64 /tmp/initdb.log.32  ...  23c23  < creating directory /home2/freeware/src/packages/BUILD/postgresql-11.0/64bit/contrib/jsonb_plperl/./tmp_check/data ... ok  ---  > creating directory /home2/freeware/src/packages/BUILD/postgresql-11.0/32bit/contrib/jsonb_plperl/./tmp_check/data ... ok  29c29  < running bootstrap script ... 2018-11-06 16:01:19.632 CST [21823838] DEBUG:  invoking IpcMemoryCreate(size=148676608)  ---  > running bootstrap script ... 2018-11-06 15:51:43.604 CST [26804718] DEBUG:  invoking IpcMemoryCreate(size=146415616)  33c33  < DEBUG: created dynamic shared memory control segment 944926165 (6928 bytes)   ---  > DEBUG: created dynamic shared memory control segment 203612733 (4620 bytes)   41c41  < NOTICE: database system was shut down at 2018-11-06 16:01:19 CST   ---  > NOTICE: database system was shut down at 2018-11-06 15:51:43 CST 
  146201,146202c146201,146202  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  147519,147520c147519,147520  < DEBUG: inserting column 3 value "8"       < DEBUG: inserted -> 8         ---  > DEBUG: inserting column 3 value "4"       > DEBUG: inserted -> 4       
  147553,147554c147553,147554  < DEBUG: inserting column 20 value "d"       < DEBUG: inserted -> d         ---  > DEBUG: inserting column 20 value "i"       > DEBUG: inserted -> i       
  148121,148122c148121,148122  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  148541,148542c148541,148542  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  151121,151122c151121,151122  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f         151181,151182c151181,151182
  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  151421,151422c151421,151422  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  153222,153223c153222,153223  < DEBUG: inserting column 4 value "true"       < DEBUG: inserted -> t         ---  > DEBUG: inserting column 4 value "false"       > DEBUG: inserted -> f       
  155440,155441c155440,155441  < DEBUG: inserting column 3 value "8"       < DEBUG: inserted -> 8         ---  > DEBUG: inserting column 3 value "4"       > DEBUG: inserted -> 4       
  155474,155475c155474,155475  < DEBUG: inserting column 20 value "d"       < DEBUG: inserted -> d         ---  > DEBUG: inserting column 20 value "i"       > DEBUG: inserted -> i       
  ...
b) Comparaison of files: postmaster.log 64bit vs 32 bit :
 # cat log/postmaster.log | awk -v D=$D '{if($1==D){print $6, $7, $8, $9, $10, $11, $12, $13, $14, $15}else{print $0}}' > /tmp/postmaster.log.32
 # diff /tmp/postmaster.log.64 /tmp/postmaster.log.32
  246a248,249  > reaping dead processes         > server process (PID 18940280) exited with exit code 0   248c251  < DEBUG: postgres child[24969698]: starting with (      ---  > DEBUG: postgres child[18940282]: starting with (      253d255  < forked new backend, pid=24969698 socket=8       256,257c258  < reaping dead processes         < server process (PID 14549256) exited with exit code 0   ---  > forked new backend, pid=18940282 socket=8       745c746  < LOG: disconnection: session time: 0:00:00.142 user=pgstbf database=contrib_regression host=[local]    ---  > LOG: disconnection: session time: 0:00:00.010 user=pgstbf database=contrib_regression host=[local]    751,752c752  < server process (PID 24969698) exited with exit code 0   < forked new backend, pid=24969700 socket=8       ---  > server process (PID 18940282) exited with exit code 0   ...  3819,3821c3820
   < ERROR: cannot convert infinity to jsonb      < CONTEXT: PL/Perl function "roundtrip"        < STATEMENT: SELECT roundtrip('1E+131071');         ---  > DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0  ...  12572a12570,12571  > reaping dead processes         > server process (PID 18940284) exited with exit code 0   14324c14323  < INFO: $VAR1 =  '1' ;        ---  > INFO: $VAR1 =  '4.94065645841247e-324' ;        14573c14572  < INFO: $VAR1 = '0';        ---  > INFO: $VAR1 = '4.94065645841247e-324';
64bit:  ...  STATEMENT: SELECT roundtrip('true');  INFO: $VAR1 = '1';  CONTEXT: PL/Perl function "roundtrip"  DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0  DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0  LOG: statement: SELECT roundtrip('false');  LOG: parse tree:

32bit:  ...  STATEMENT: SELECT roundtrip('true');  INFO: $VAR1 = '4.94065645841247e-324' ;  CONTEXT: PL/Perl function "roundtrip"  DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0  DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0  LOG: statement: SELECT roundtrip('false');  LOG: parse tree:


Cordialement,

Tony Reix

tony.reix@atos.net

ATOS / Bull SAS
ATOS Expert
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France
Вложения

Re: Issue with v11.0 within jsonb_plperl tests in 32bit on AIX

От
Alvaro Herrera
Дата:
On 2018-Nov-06, REIX, Tony wrote:

> Hummm The buildfarm does show that these tests are OK on AIX machines in 32bit, with GCC 4.8.1 .
> 
> Nuts !
> 
> 
> Attached is the full diff between the expected results and the real results.

Standard diffs are awful to read.  Would you mind using context or
unified diffs please (diff -c or diff -u)?  Also, keep in mind that the
regression tests save a file "regression.diffs" with all the diffs in
context format, so there's no need to create them yourself.

That said, this looks like there's an ABI mismatch somewhere, where
this:

<             roundtrip            
< ---------------------------------
<  {"1": {"2": [3, 4, 5]}, "2": 3}

ends up as

{
    "1": {
        "2": [

0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531017013119972,

0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531146529464635,

0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000530757980430645
        ]
    },
    "2":
0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026632835514017
}

Note that keys seem okay, but the values are corrupted.  (I wonder if
those values are actually representable in 32 bits.)  What catches my
attention is that the values for "3" in the two places where it appears
are different.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


RE: Issue with v11.0 within jsonb_plperl tests in 32bit on AIX

От
"REIX, Tony"
Дата:


Hi Alvaro,


Thanks for your help.


Here is the regression.diffs file.


About the root cause, I noticed that, for the 2nd error:

< ERROR:  cannot convert infinity to jsonb
< CONTEXT:  PL/Perl function "roundtrip"
---
>                                                                                                                                                                     roundtrip                                                                                                                                                                  
>   ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>  0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000266336287858179
> (1 row)
where an error message is expected, saying that converting infinity to jsonb is not possible, that deals with this code here below.


After generating the CPP pre-processed file jsonb_plperl.c by using -E, both for 32 and 64bit, I see that the 64 vs 32bit code of function SV_to_JsonbValuefunction differs only by:


# diff 64 32
34c34
<      ((Numeric) pg_detoast_datum((struct varlena *) ((Pointer) (DirectFunctionCall1Coll(int8_numeric, ((Oid) 0), ((Datum) ((int64) ival))))))) ;
---
>      ((Numeric) pg_detoast_datum((struct varlena *) ((Pointer) (DirectFunctionCall1Coll(int8_numeric, ((Oid) 0), Int64GetDatum((int64) ival)))))) ;




About your comment : "(I wonder if those values are actually representable in 32 bits.)"   , I see that that works fine in 32bit on AIX in the build-farm. So, I guess that there is something wrong with Perl in 32bit on my machine...




Doing a complete diff of the 32bit vs 64bit versions of the jsonb_plperl.o by means of: gcc -E .... jsonb_plperl.c , I see that there 674 differences... 😞




postgresql-11.0/32bit/contrib/jsonb_plperl/jsonb_plperl.c :
static JsonbValue * SV_to_JsonbValue(SV *in, JsonbParseState **jsonb_state, bool is_elem) {
... /* Dereference references recursively. */ while (SvROK(in)) in = SvRV(in); switch (SvTYPE(in)) { .... default: if (SvUOK(in)) { ... } else if (SvIOK(in)) { ... } else if (SvNOK(in)) { double nval = SvNV(in);
                               /*                               * jsonb doesn't allow infinity or NaN (per JSON                               * specification), but the numeric type that is used for the                               * storage accepts NaN, so we have to prevent it here                               * explicitly.  We don't really have to check for isinf()                               * here, as numeric doesn't allow it and it would be caught                               * later, but it makes for a nicer error message.                               */                              if (isinf(nval))                                      ereport(ERROR,                                                      (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),                                                       (errmsg("cannot convert infinity to jsonb"))));


Result of building with -E on routine SV_to_JsonbValue :


There are plenty of complex low-level computations and calls to Perl...


static JsonbValue *
SV_to_JsonbValue(SV *in, JsonbParseState **jsonb_state,
# 179 "jsonb_plperl.c" 3 4
                                                       _Bool
# 179 "jsonb_plperl.c"
                                                            is_elem)
{
 PerlInterpreter* my_perl __attribute__((unused)) = ((PerlInterpreter *)pthread_getspecific(PL_thr_key));
 JsonbValue out;
 while (((in)->sv_flags & 0x00000800))
  in = ((in)->sv_u.svu_rv);
 switch (((svtype)((in)->sv_flags & 0xff)))
 {
  case SVt_PVAV:
   return AV_to_JsonbValue((AV *) in, jsonb_state);
  case SVt_PVHV:
   return HV_to_JsonbValue((HV *) in, jsonb_state);
  case SVt_NULL:
   out.type = jbvNull;
   break;
  default:
   if ((((in)->sv_flags & (0x00000100|0x80000000)) == (0x00000100|0x80000000)))
   {
    const char *strval = ((((in)->sv_flags & (0x00000400|0x00200000)) == 0x00000400) ? ((in)->sv_u.svu_pv) : Perl_sv_2pv_flags(my_perl, in,0,2));
    out.type = jbvNumeric;
    out.val.numeric =
     ((Numeric) pg_detoast_datum((struct varlena *) ((Pointer) (DirectFunctionCall3Coll(numeric_in, ((Oid) 0), ((Datum) (strval)), ((Datum) (((Oid) 0))), ((Datum) (-1))))))) ;
   }
   else if (((in)->sv_flags & 0x00000100))
   {
    IV ival = ((((in)->sv_flags & (0x00000100|0x00200000)) == 0x00000100) ? ((XPVIV*) (in)->sv_any)->xiv_u.xivu_iv : Perl_sv_2iv_flags(my_perl, in,2));
    out.type = jbvNumeric;
    out.val.numeric =
     ((Numeric) pg_detoast_datum((struct varlena *) ((Pointer) (DirectFunctionCall1Coll(int8_numeric, ((Oid) 0), Int64GetDatum((int64) ival)))))) ;
   }
   else if (((in)->sv_flags & 0x00000200))
   {
    double nval = ((((in)->sv_flags & (0x00000200|0x00200000)) == 0x00000200) ? ((XPVNV*) (in)->sv_any)->xnv_u.xnv_nv : Perl_sv_2nv_flags(my_perl, in,2));
# 239 "jsonb_plperl.c"
    if (
# 239 "jsonb_plperl.c" 3 4
       ((1) ? ((sizeof(
# 239 "jsonb_plperl.c"
       nval
# 239 "jsonb_plperl.c" 3 4
       ) == sizeof(float)) ? _isinff(
# 239 "jsonb_plperl.c"
       nval
# 239 "jsonb_plperl.c" 3 4
       ) : _isinf(
# 239 "jsonb_plperl.c"
       nval
# 239 "jsonb_plperl.c" 3 4
       )) : (0))
# 239 "jsonb_plperl.c"
                  )
     do { if (errstart(20,
                                                     "jsonb_plperl.c"
# 240 "jsonb_plperl.c"
     ,
                                                     242
# 240 "jsonb_plperl.c"
     , __func__,
# 240 "jsonb_plperl.c" 3 4
    ((void *)0)
# 240 "jsonb_plperl.c"
    )) errfinish (errcode((((('2') - '0') & 0x3F) + (((('2') - '0') & 0x3F) << 6) + (((('0') - '0') & 0x3F) << 12) + (((('0') - '0') & 0x3F) << 18) + (((('3') - '0') & 0x3F) << 24))), (errmsg("cannot convert infinity to jsonb"))); if (__builtin_constant_p(20) && (20) >= 20) __builtin_unreachable(); } while(0) ;
    if (
# 243 "jsonb_plperl.c" 3 4
       ((1) ? ((sizeof(
# 243 "jsonb_plperl.c"
       nval
# 243 "jsonb_plperl.c" 3 4
       ) == sizeof(float)) ? _isnanf(
# 243 "jsonb_plperl.c"
       nval
# 243 "jsonb_plperl.c" 3 4
       ) : _isnan(
# 243 "jsonb_plperl.c"
       nval
# 243 "jsonb_plperl.c" 3 4
       )) : (0))
# 243 "jsonb_plperl.c"
                  )
     do { if (errstart(20,
                                                "jsonb_plperl.c"
# 244 "jsonb_plperl.c"
     ,
                                                246
# 244 "jsonb_plperl.c"
     , __func__,
# 244 "jsonb_plperl.c" 3 4
    ((void *)0)
# 244 "jsonb_plperl.c"
    )) errfinish (errcode((((('2') - '0') & 0x3F) + (((('2') - '0') & 0x3F) << 6) + (((('0') - '0') & 0x3F) << 12) + (((('0') - '0') & 0x3F) << 18) + (((('3') - '0') & 0x3F) << 24))), (errmsg("cannot convert NaN to jsonb"))); if (__builtin_constant_p(20) && (20) >= 20) __builtin_unreachable(); } while(0) ;
    out.type = jbvNumeric;
    out.val.numeric =
     ((Numeric) pg_detoast_datum((struct varlena *) ((Pointer) (DirectFunctionCall1Coll(float8_numeric, ((Oid) 0), Float8GetDatum(nval)))))) ;
   }
   else if (((in)->sv_flags & 0x00000400))
   {
    out.type = jbvString;
    out.val.string.val = sv2cstr(in);
    out.val.string.len = strlen(out.val.string.val);
   }
   else
   {
    do { if (errstart(20,
                                                            "jsonb_plperl.c"
# 265 "jsonb_plperl.c"
    ,
                                                            267
# 265 "jsonb_plperl.c"
    , __func__,
# 265 "jsonb_plperl.c" 3 4
   ((void *)0)
# 265 "jsonb_plperl.c"
   )) errfinish (errcode((((('0') - '0') & 0x3F) + (((('A') - '0') & 0x3F) << 6) + (((('0') - '0') & 0x3F) << 12) + (((('0') - '0') & 0x3F) << 18) + (((('0') - '0') & 0x3F) << 24))), (errmsg("cannot transform this Perl type to jsonb"))); if (__builtin_constant_p(20) && (20) >= 20) __builtin_unreachable(); } while(0) ;
    return
# 268 "jsonb_plperl.c" 3 4
          ((void *)0)
# 268 "jsonb_plperl.c"
              ;
   }
 }
 return *jsonb_state
  ? pushJsonbValue(jsonb_state, is_elem ? WJB_ELEM : WJB_VALUE, &out)
  : memcpy(palloc(sizeof(JsonbValue)), &out, sizeof(JsonbValue));
}



Cordialement,

Tony Reix

tony.reix@atos.net

ATOS / Bull SAS
ATOS Expert
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France



De : Alvaro Herrera <alvherre@2ndquadrant.com>
Envoyé : mardi 6 novembre 2018 18:45
À : REIX, Tony
Cc : pgsql-hackers@postgresql.org
Objet : Re: Issue with v11.0 within jsonb_plperl tests in 32bit on AIX
 
On 2018-Nov-06, REIX, Tony wrote:

> Hummm The buildfarm does show that these tests are OK on AIX machines in 32bit, with GCC 4.8.1 .
>
> Nuts !
>
>
> Attached is the full diff between the expected results and the real results.

Standard diffs are awful to read.  Would you mind using context or
unified diffs please (diff -c or diff -u)?  Also, keep in mind that the
regression tests save a file "regression.diffs" with all the diffs in
context format, so there's no need to create them yourself.

That said, this looks like there's an ABI mismatch somewhere, where
this:

<             roundtrip           
< ---------------------------------
<  {"1": {"2": [3, 4, 5]}, "2": 3}

ends up as

{
    "1": {
        "2": [
            0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531017013119972,
            0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531146529464635,
            0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000530757980430645
        ]
    },
    "2": 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026632835514017
}

Note that keys seem okay, but the values are corrupted.  (I wonder if
those values are actually representable in 32 bits.)  What catches my
attention is that the values for "3" in the two places where it appears
are different.

--
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Вложения