Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YvUbD-0005ex-Lp for pgsql-bugs@arkaria.postgresql.org; Thu, 21 May 2015 17:49:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YvUbD-00044J-6i for pgsql-bugs@arkaria.postgresql.org; Thu, 21 May 2015 17:49:39 +0000 Received: from makus.postgresql.org ([174.143.35.229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YvUbC-00044D-EA for pgsql-bugs@postgresql.org; Thu, 21 May 2015 17:49:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1YvUb9-0002WH-OX for pgsql-bugs@postgresql.org; Thu, 21 May 2015 17:49:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t4LHnLTX030650; Thu, 21 May 2015 13:49:21 -0400 From: Tom Lane To: cpro29a@gmail.com cc: pgsql-bugs@postgresql.org, Heikki Linnakangas Subject: Re: BUG #13327: Error on insert (gist index) In-reply-to: <20150521071448.26511.8665@wrigleys.postgresql.org> References: <20150521071448.26511.8665@wrigleys.postgresql.org> Comments: In-reply-to cpro29a@gmail.com message dated "Thu, 21 May 2015 07:14:48 -0000" Date: Thu, 21 May 2015 13:49:21 -0400 Message-ID: <30649.1432230561@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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=, fmt=) at elog.c:1368 #2 0x000000000048464c in gistplacetopage (rel=0x7f7dfc2f2ff0, freespace=140735375882944, giststate=0xffffffff, buffer=, itup=0x287f950, ntup=, 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=, ntup=, oldoffnum=, 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=, unlockbuf=0 '\000') at gist.c:1223 #5 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, stack=0x21ad028, giststate=0x21b67e8, tuples=, ntup=, oldoffnum=, 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=, unlockbuf=0 '\000') at gist.c:1223 #7 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, stack=0x255cb10, giststate=0x21b67e8, tuples=, ntup=, oldoffnum=, 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=, unlockbuf=0 '\000') at gist.c:1223 #9 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, stack=0x2578830, giststate=0x21b67e8, tuples=, ntup=, oldoffnum=, 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=, unlockbuf=0 '\000') at gist.c:1223 #11 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, stack=0x25942e8, giststate=0x21b67e8, tuples=, ntup=, oldoffnum=, 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=, unlockbuf=0 '\000') at gist.c:1223 #13 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, stack=0x259f0b0, giststate=0x21b67e8, tuples=, ntup=, oldoffnum=, 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=, unlockbuf=0 '\000') at gist.c:1223 #15 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, stack=0x25cbdc8, giststate=0x21b67e8, tuples=, ntup=, oldoffnum=, 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=, unlockbuf=1 '\001') at gist.c:1223 #17 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, stack=0x25e7880, giststate=0x21b67e8, tuples=, ntup=, oldoffnum=, 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=, unlockbuf=0 '\000') at gist.c:1248 #19 0x0000000000484d9b in gistinserttuples (state=0x7fff82164470, stack=0x2603338, giststate=0x21b67e8, tuples=, ntup=, oldoffnum=, leftchild=0, rightchild=0, unlockbuf=0 '\000', unlockleftchild=0 '\000') at gist.c:1167 #20 0x0000000000484fb9 in gistinserttuple (state=, stack=, giststate=, tuple=0x2605e78, oldoffnum=) at gist.c:1101 #21 0x000000000048587e in gistdoinsert (r=0x7f7dfc2f2ff0, itup=0x21ba158, freespace=, giststate=0x21b67e8) at gist.c:672 #22 0x0000000000485b79 in gistinsert (fcinfo=) at gist.c:132 #23 0x00000000007b7984 in FunctionCall6Coll (flinfo=, collation=, arg1=, arg2=, arg3=, arg4=, 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