pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: cpro29a@gmail.com
Cc: pgsql-bugs@postgresql.org
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Subject: Re: BUG #13327: Error on insert (gist index)
Date: Thu, 21 May 2015 13:49:21 -0400
Message-ID: <30649.1432230561@sss.pgh.pa.us> (raw)
In-Reply-To: <20150521071448.26511.8665@wrigleys.postgresql.org>
References: <20150521071448.26511.8665@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

cpro29a@gmail.com writes:
> create table test_gist(id serial primary key, a1 int[],a2 int[], a3 int[],
> a4 int[], a5 int[]);
> create index test_gist_i on test_gist using gist (a1,a2,a3,a4,a5);

> --Simple random array generator
> create or replace function rnd_arr(p_len int) returns int[]
> as $$
>  select array_agg(val)
>  from (select trunc(random()*1000.0)::int val
>        from generate_series(1,trunc(random()*p_len*1.0)::int+1)
>        ) v;
> $$ language sql;

> --##THIS FAILS:
> insert into test_gist(a1,a2,a3,a4,a5)
> select rnd_arr(10),rnd_arr(10),rnd_arr(10),rnd_arr(10),rnd_arr(10)
>   from generate_series(1,100000);
> --##WITH MESSAGE:
> --ERROR:  failed to add item to index page in "test_gist_i"

I can reproduce this on HEAD (after installing contrib/intarray).
It's not very clear if this is a core-code bug or a fault in intarray's
picksplit function, but the stack trace is suspicious:

#0  errfinish (dummy=0) at elog.c:408
#1  0x00000000007b4df8 in elog_finish (elevel=<value optimized out>, 
    fmt=<value optimized out>) at elog.c:1368
#2  0x000000000048464c in gistplacetopage (rel=0x7f7dfc2f2ff0, 
    freespace=140735375882944, giststate=0xffffffff, 
    buffer=<value optimized out>, itup=0x287f950, ntup=<value optimized out>, 
    oldoffnum=0, newblkno=0x0, leftchildbuf=6689, splitinfo=0x7fff82163b88, 
    markfollowright=1 '\001') at gist.c:358
#3  0x0000000000484cfb in gistinserttuples (state=0x7fff82164470, 
    stack=0x7fff82164490, giststate=0x21b67e8, tuples=<value optimized out>, 
    ntup=<value optimized out>, oldoffnum=<value optimized out>, 
    leftchild=6689, rightchild=6687, unlockbuf=0 '\000', 
    unlockleftchild=0 '\000') at gist.c:1142
#4  0x0000000000484eb3 in gistfinishsplit (state=0x7fff82164470, 
    stack=0x21ad028, giststate=0x21b67e8, splitinfo=<value optimized out>, 
    unlockbuf=0 '\000') at gist.c:1223
#5  0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, 
    stack=0x21ad028, giststate=0x21b67e8, tuples=<value optimized out>, 
    ntup=<value optimized out>, oldoffnum=<value optimized out>, 
    leftchild=6694, rightchild=6692, unlockbuf=0 '\000', 
    unlockleftchild=0 '\000') at gist.c:1167
#6  0x0000000000484eb3 in gistfinishsplit (state=0x7fff82164470, 
    stack=0x255cb10, giststate=0x21b67e8, splitinfo=<value optimized out>, 
    unlockbuf=0 '\000') at gist.c:1223
#7  0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, 
    stack=0x255cb10, giststate=0x21b67e8, tuples=<value optimized out>, 
    ntup=<value optimized out>, oldoffnum=<value optimized out>, 
    leftchild=6698, rightchild=6696, unlockbuf=0 '\000', 
    unlockleftchild=0 '\000') at gist.c:1167
#8  0x0000000000484eb3 in gistfinishsplit (state=0x7fff82164470, 
    stack=0x2578830, giststate=0x21b67e8, splitinfo=<value optimized out>, 
    unlockbuf=0 '\000') at gist.c:1223
#9  0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, 
    stack=0x2578830, giststate=0x21b67e8, tuples=<value optimized out>, 
    ntup=<value optimized out>, oldoffnum=<value optimized out>, 
    leftchild=6707, rightchild=6700, unlockbuf=0 '\000', 
    unlockleftchild=0 '\000') at gist.c:1167
#10 0x0000000000484eb3 in gistfinishsplit (state=0x7fff82164470, 
    stack=0x25942e8, giststate=0x21b67e8, splitinfo=<value optimized out>, 
    unlockbuf=0 '\000') at gist.c:1223
#11 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, 
    stack=0x25942e8, giststate=0x21b67e8, tuples=<value optimized out>, 
    ntup=<value optimized out>, oldoffnum=<value optimized out>, 
    leftchild=6711, rightchild=6709, unlockbuf=0 '\000', 
    unlockleftchild=0 '\000') at gist.c:1167
#12 0x0000000000484eb3 in gistfinishsplit (state=0x7fff82164470, 
    stack=0x259f0b0, giststate=0x21b67e8, splitinfo=<value optimized out>, 
    unlockbuf=0 '\000') at gist.c:1223
#13 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, 
    stack=0x259f0b0, giststate=0x21b67e8, tuples=<value optimized out>, 
    ntup=<value optimized out>, oldoffnum=<value optimized out>, 
    leftchild=6714, rightchild=6713, unlockbuf=0 '\000', 
    unlockleftchild=0 '\000') at gist.c:1167
#14 0x0000000000484eb3 in gistfinishsplit (state=0x7fff82164470, 
    stack=0x25cbdc8, giststate=0x21b67e8, splitinfo=<value optimized out>, 
    unlockbuf=0 '\000') at gist.c:1223
#15 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, 
    stack=0x25cbdc8, giststate=0x21b67e8, tuples=<value optimized out>, 
    ntup=<value optimized out>, oldoffnum=<value optimized out>, 
    leftchild=6718, rightchild=6717, unlockbuf=0 '\000', 
    unlockleftchild=0 '\000') at gist.c:1167
#16 0x0000000000484eb3 in gistfinishsplit (state=0x7fff82164470, 
    stack=0x25e7880, giststate=0x21b67e8, splitinfo=<value optimized out>, 
    unlockbuf=1 '\001') at gist.c:1223
#17 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, 
    stack=0x25e7880, giststate=0x21b67e8, tuples=<value optimized out>, 
    ntup=<value optimized out>, oldoffnum=<value optimized out>, 
    leftchild=6740, rightchild=6720, unlockbuf=1 '\001', 
    unlockleftchild=0 '\000') at gist.c:1167
#18 0x0000000000484f3a in gistfinishsplit (state=0x7fff82164470, 
    stack=0x2603338, giststate=0x21b67e8, splitinfo=<value optimized out>, 
    unlockbuf=0 '\000') at gist.c:1248
#19 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, 
    stack=0x2603338, giststate=0x21b67e8, tuples=<value optimized out>, 
    ntup=<value optimized out>, oldoffnum=<value optimized out>, leftchild=0, 
    rightchild=0, unlockbuf=0 '\000', unlockleftchild=0 '\000') at gist.c:1167
#20 0x0000000000484fb9 in gistinserttuple (state=<value optimized out>, 
    stack=<value optimized out>, giststate=<value optimized out>, 
    tuple=0x2605e78, oldoffnum=<value optimized out>) at gist.c:1101
#21 0x000000000048587e in gistdoinsert (r=0x7f7dfc2f2ff0, itup=0x21ba158, 
    freespace=<value optimized out>, giststate=0x21b67e8) at gist.c:672
#22 0x0000000000485b79 in gistinsert (fcinfo=<value optimized out>)
    at gist.c:132
#23 0x00000000007b7984 in FunctionCall6Coll (flinfo=<value optimized out>, 
    collation=<value optimized out>, arg1=<value optimized out>, 
    arg2=<value optimized out>, arg3=<value optimized out>, 
    arg4=<value optimized out>, arg5=140179078598768, arg6=0) at fmgr.c:1436
#24 0x00000000004aac8f in index_insert (indexRelation=0x7f7dfc2f2ff0, 
    values=0x7fff82164a10, isnull=0x7fff821649f0 "", heap_t_ctid=0x203f81c, 
    heapRelation=0x7f7dfc2f5070, checkUnique=UNIQUE_CHECK_NO) at indexam.c:226
#25 0x00000000005c7b1d in ExecInsertIndexTuples (slot=0x2035d80, 
    tupleid=0x203f81c, estate=0x20357b8, noDupErr=0 '\000', specConflict=0x0, 
    arbiterIndexes=0x0) at execIndexing.c:384
#26 0x00000000005e49cd in ExecInsert (node=0x2035a20) at nodeModifyTable.c:459
#27 ExecModifyTable (node=0x2035a20) at nodeModifyTable.c:1432


Should gistfinishsplit really be recursing like that?

Also, if you execute the INSERT a second time, it fails immediately,
apparently from trying to finish the uncompleted page split.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (4+ messages)  latest in thread

Message-ID: <30649.1432230561@sss.pgh.pa.us>
Permalink:  ../30649.1432230561@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/30649.1432230561@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, cpro29a@gmail.com, hlinnaka@iki.fi
  Subject: Re: BUG #13327: Error on insert (gist index)
  In-Reply-To: <30649.1432230561@sss.pgh.pa.us>
  References: <20150521071448.26511.8665@wrigleys.postgresql.org> <30649.1432230561@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox