Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ql37C-000pb0-O8 for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Sep 2023 08:08:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ql37A-00Aeg1-Ql for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Sep 2023 08:08:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ql37A-00Aefs-F8 for pgsql-bugs@lists.postgresql.org; Tue, 26 Sep 2023 08:08:16 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1ql377-007dt3-4W for pgsql-bugs@lists.postgresql.org; Tue, 26 Sep 2023 08:08:15 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-50437f39c9dso10835080e87.3 for ; Tue, 26 Sep 2023 01:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695715691; x=1696320491; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=nY3R/Ibfsyrxu3wOWJl2jxU2ZhX6xfRSaSPfiZ0UnM4=; b=gqnRlhUB2QfvSu/XA/zSL4AfhHmmt3Gdtrb1yf0CS4gZ/2VtyfqCj6oZw76oqU9naO oJtBXQr7z8DnIr0CDvQq8rjUecLmcPOVfJBZVfqfKeLFrMbP4nQR2krqP8GLWWyer/TE CcUL5CaI20VJpS5028vG/fBUVx5QyhhUIgn6LYlnVmHYYaYmSUepcPMi89AlqZrSCgih 9bFqfyY9mkwQMgDJOqB7/v0aQnnkrBwTzCPhbPLgMNpEN3nJaQfDWHHX88ZIFgGq1X5K qqLob4wCHlstbwhokKSUuTN+4mZ4nzpIdsqVcQftYehKNISgi84USMypkX9m71pvXGS1 vjOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695715691; x=1696320491; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nY3R/Ibfsyrxu3wOWJl2jxU2ZhX6xfRSaSPfiZ0UnM4=; b=IILitf3IY/mKhZaC63BJvZj3z7CuCdWF2KSFz4UE618QXRRDFzPNdzpwX1XLHxM/Aa twQUEKn7SqYSRlqfpuiUHt1TVbZlOc5wDa0q17Ap/JnInUVV/J0IT8+3qTvAOaMkQlWu rjzW4zB4x8Nz3tBCkYcvISc/+nmN3rdD77Z224CM0okJEHIkBDprGes5aM4NyD51+zaB QBTaRyE0w95vNeT7iPbAAY/HMbbJYpVeoEImrDCWIiUMxBIN1mEtFoEjpdy87FsuP5Hq MVevbAibk24JEFE+L9RhyhDPtGwXmJREpv9IGUzQpSnEUzYlFyUKpAPyuMaq44MemZsu h0BQ== X-Gm-Message-State: AOJu0Ywyq6nfMDhvaC9WonZRTAt4ra/tF0ft3gX6cqAdZ2lpUAnehqab 7NoSLI5Lm70Kikq6sQyjikI= X-Google-Smtp-Source: AGHT+IGUNKxge/s346+Zps13JdOb72CjwrrvVYsQvd90ceblCdGLOKSLBuojMyKwnrAVmd/sQTEmag== X-Received: by 2002:a05:6512:2520:b0:500:8022:3dc7 with SMTP id be32-20020a056512252000b0050080223dc7mr8037333lfb.10.1695715691086; Tue, 26 Sep 2023 01:08:11 -0700 (PDT) Received: from [1.0.0.7] ([178.155.21.181]) by smtp.gmail.com with ESMTPSA id w30-20020a05651204de00b0050338932f05sm2128801lfq.138.2023.09.26.01.08.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Sep 2023 01:08:10 -0700 (PDT) Message-ID: Date: Tue, 26 Sep 2023 11:08:08 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #18129: GiST index produces incorrect query results Content-Language: en-US To: Heikki Linnakangas , pgsql-bugs@lists.postgresql.org References: <18129-caca016eaf0c3702@postgresql.org> <80e4ef74-4a00-4631-963f-3dd11e64c6fe@iki.fi> From: Alexander Lakhin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Heikki, 26.09.2023 00:24, Heikki Linnakangas wrote: > I spent a while trying to create a test case for this that would not require expanding the test data so much, but no > avail. I even tried to take the same data set, but instead of duplicating each element like you did, I appended a > random number of integers to each array, but even that did not trigger the failure. That particular data set seems > cursed; how did you stumble upon it? > > I'm reluctant to just make all the arrays larger, as it makes the test 2x slower. So instead of running all the > commands over the larger data set, I added one more copy of the CREATE INDEX and the test queries to the end that uses > the larger set. > > See attached. It's squashed version of the previous patches I posted, with the test case. Barring objections, I'll > commit this. Thank you for working on this! I can't review the code change in depth, unfortunately (I need time to study gist guts), but I've tried to just test it. And with the patch applied I get an assertion failure when the server compiled --with-blocksize=1 (and -O0): CPPFLAGS="-O0" ./configure -q --with-blocksize=1 --enable-debug --enable-cassert && make -s -j8 && make -s -j8 -C contrib && make -s check -C contrib/intarray not ok 1     - _int                                      806 ms # (test process exited with exit code 2) ^C# could not stop postmaster: exit code was 2 (gdb) bt #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140373756303168) at ./nptl/pthread_kill.c:44 #1  __pthread_kill_internal (signo=6, threadid=140373756303168) at ./nptl/pthread_kill.c:78 #2  __GI___pthread_kill (threadid=140373756303168, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3  0x00007fab4f409476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4  0x00007fab4f3ef7f3 in __GI_abort () at ./stdlib/abort.c:79 #5  0x0000559563a87ed9 in ExceptionalCondition (conditionName=0x559563b17a28 "ItemIdHasStorage(itemId)", fileName=0x559563b17990 "../../../../src/include/storage/bufpage.h", lineNumber=355) at assert.c:66 #6  0x00005595633334fb in PageGetItem (page=0x7fab43d15800 "", itemId=0x7fab43d1581c) at ../../../../src/include/storage/bufpage.h:355 #7  0x00005595633358e9 in gistFindCorrectParent (r=0x7fab4176b118, child=0x559565b45b18, is_build=true) at gist.c:1063 #8  0x00005595633361b5 in gistfinishsplit (state=0x7ffc087cd250, stack=0x559565b45b18, giststate=0x559565b7ecd8, splitinfo=0x559565be0290, unlockbuf=false) at gist.c:1392 #9  0x0000559563335fdb in gistinserttuples (state=0x7ffc087cd250, stack=0x559565b45b18, giststate=0x559565b7ecd8, tuples=0x559565b6b5d8, ntup=1, oldoffnum=0, leftchild=12421, rightchild=12422, unlockbuf=false, unlockleftchild=false)     at gist.c:1322 #10 0x000055956333612c in gistfinishsplit (state=0x7ffc087cd250, stack=0x559565b45fc8, giststate=0x559565b7ecd8, splitinfo=0x559565b6b560, unlockbuf=false) at gist.c:1368 #11 0x0000559563335fdb in gistinserttuples (state=0x7ffc087cd250, stack=0x559565b45fc8, giststate=0x559565b7ecd8, tuples=0x559565b692a8, ntup=1, oldoffnum=0, leftchild=12419, rightchild=12420, unlockbuf=false, unlockleftchild=false)     at gist.c:1322 .... (in fact it crashes even on `make check`) I haven't understand the reason yet, just wanted to let you know that maybe the patch needs one more fix before committing. > > ERROR:  failed to add item to index page in "byteatest_a_idx1" > > If you make that value even larger, then it fails with a better error message: > > ERROR:  index row requires 8208 bytes, maximum size is 8191 > > So the "failed to add item" error doesn't seem expected. > Yeah, I saw that anomaly too. Best regards, Alexander