Pivotal Knowledge Base

Follow

Wrong syntax on CONVERT function results in PANIC and then crash recovery

Environment

Product Version
GPDB All Version

Symptom

Wrong syntax for CONVERT function results in PANIC of the GPDB segments causing the segments to go under recovery mode.

gpadmin=# select case when length(r.m[1])=1 then convert(r.m[1],'SQL_ASCII') else substring(r.m[1] from 2 for 2) end from regexp_matches('%2f%2Fform%2flist%2f','%[0-9A-F][0-9A-F]|.','gi') as r(m)                   ;
FATAL:  Unexpected internal error: Master process received signal SIGSEGV (postgres.c:3442)
DETAIL:  (interrupt holdoff count 0, critical section count 0)
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
gpadmin=# 

During the time of the PANIC, the below stack is observed

2013-03-04 14:38:17.891716 BRT,"gpadmin","gpadmin",p2808,th1997481888,"[local]",,2013-03-04 14:38:13 BRT,1148,con63,cmd2,seg-1,,dx91,x1148,sx1,"FATAL","XX000","Unexpected internal error: Master process received signal SIGSEGV (postgres.c:3442)","(interrupt holdoff count 0, critical section count 0)",,,,,"select case when length(r.m[1])=1 then convert(r.m[1],'SQL_ASCII') else substring(r.m[1] from 2 for 2) end from regexp_matches('%2f%2Fform%2flist%2f','%[0-9A-F][0-9A-F]|.','gi') as r(m)
 ;",0,,"postgres.c",3442,"Stack trace:
1    0xa64835 postgres errstart (elog.c:466)
2    0x8ff168 postgres  (postgres.c:3436)
3    0x31ac0302f0 libc.so.6  (??:0)
4    0xa7f4e9 postgres pg_char_to_encoding (encnames.c:474)
5    0xa8308b postgres pg_convert (mbutils.c:374)
6    0x6f68a2 postgres  (execQual.c:1734)
7    0x6f708d postgres  (execQual.c:2182)
8    0x6f4472 postgres ExecProject (execQual.c:5195)
9    0x6ecf15 postgres ExecProcNode (execProcnode.c:605)
10   0x6ea894 postgres  (execMain.c:2353)
11   0x6ec570 postgres ExecutorRun (execMain.c:872)
12   0x90ab09 postgres PortalRun (pquery.c:1287)
13   0x8ff855 postgres  (postgres.c:1728)
14   0x901167 postgres PostgresMain (postgres.c:4704)
15   0x86d371 postgres  (postmaster.c:6779)
16   0x873a20 postgres PostmasterMain (postmaster.c:2340)
17   0x7796ba postgres main (main.c:212)
18   0x31ac01d994 libc.so.6 __libc_start_main (??:0)
19   0x47a889 postgres  (??:0)
"

And, the core file stack is the following:

#0 0x00000031ac030285 in raise () from /lib64/libc.so.6
#1 0x0000000000a621f2 in SafeHandlerForSegvBusIll (processName=<value optimized out>, postgres_signal_arg=11) at elog.c:4431
#2 <signal handler called>
#3 pg_char_to_encname_struct (name=0x7fff00000001 <Address 0x7fff00000001 out of bounds>) at encnames.c:474
#4 pg_char_to_encoding (name=0x7fff00000001 <Address 0x7fff00000001 out of bounds>) at encnames.c:520
#5 0x0000000000a88e4b in pg_convert (fcinfo=0x7fffcee6b280) at mbutils.c:368
#6 0x00000000006f74c2 in ExecMakeFunctionResult (fcache=<value optimized out>, econtext=<value optimized out>, isNull=<value optimized out>, isDone=<value optimized out>) at execQual.c:1733
#7 0x00000000006f7cad in ExecEvalFunc (fcache=0x17e63ee0, econtext=0x17e30188, isNull=<value optimized out>, isDone=0x17e66208) at execQual.c:2181
#8 0x00000000006f5092 in ExecTargetList (projInfo=<value optimized out>, isDone=<value optimized out>) at execQual.c:5195
#9 ExecProject (projInfo=<value optimized out>, isDone=<value optimized out>) at execQual.c:5381
#10 0x00000000006edb35 in ExecProcNode (node=0x17e60c20) at execProcnode.c:605
#11 0x00000000006eb994 in ExecutePlan (estate=0x17e2fce0, planstate=<value optimized out>, operation=<value optimized out>, numberTuples=<value optimized out>, direction=<value optimized out>,
dest=<value optimized out>) at execMain.c:2353
#12 0x00000000006ed190 in ExecutorRun (queryDesc=<value optimized out>, direction=<value optimized out>, count=<value optimized out>) at execMain.c:872
#13 0x0000000000910039 in PortalRunSelect (portal=<value optimized out>, count=0, isTopLevel=<value optimized out>, dest=<value optimized out>, altdest=<value optimized out>, completionTag=<value optimized out>)
at pquery.c:1287
#14 PortalRun (portal=<value optimized out>, count=0, isTopLevel=<value optimized out>, dest=<value optimized out>, altdest=<value optimized out>, completionTag=<value optimized out>) at pquery.c:1109
#15 0x00000000009048e5 in exec_simple_query (query_string=<value optimized out>, seqServerHost=<value optimized out>, seqServerPort=<value optimized out>) at postgres.c:1721
#16 0x00000000009061f7 in PostgresMain (argc=<value optimized out>, argv=<value optimized out>, username=<value optimized out>) at postgres.c:4612
#17 0x000000000086e1c1 in BackendRun (port=0x17d32b90) at postmaster.c:6779
#18 BackendStartup (port=0x17d32b90) at postmaster.c:6380
#19 0x0000000000874870 in ServerLoop (argc=<value optimized out>, argv=<value optimized out>) at postmaster.c:2334
#20 PostmasterMain (argc=<value optimized out>, argv=<value optimized out>) at postmaster.c:1546
#21 0x000000000077a32a in main (argc=18, argv=0x17d0b030) at main.c:212
(gdb)

Cause

This is due to bug and is still worked on via bug MPP-1932 closed as a duplicate of MPP-17314, not yet solved during the time of writing the document

Workaround

Ensure using the correct syntax for the CONVERT function, which accepts values in the format:

convert(string bytea, src_encoding name, dest_encoding name) 

So placing the above syntax in the query failed at Symptom statement; it would look like:

gpadmin=# select case when length(r.m[1])=1 then convert(r.m[1],'UTF8','SQL_ASCII')
gpadmin-# else substring(r.m[1] from 2 for 2) end from regexp_matches('%2f%2Fform%2flist%2f','%[0-9A-F][0-9A-F]|.','gi') as r(m);
 substring 
-----------
 2f
 2F
 f
 o
 r
 m
 2f
 l
 i
 s
 t
 2f
(12 rows)

Comments

Powered by Zendesk