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