Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mwXox-0000fq-UX for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Dec 2021 22:59:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mwXov-0000kQ-09 for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Dec 2021 22:59:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mwXou-0000kH-Bc for pgsql-bugs@lists.postgresql.org; Sun, 12 Dec 2021 22:59:52 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mwXop-0007sK-Ow for pgsql-bugs@lists.postgresql.org; Sun, 12 Dec 2021 22:59:51 +0000 Received: by mail-ed1-x535.google.com with SMTP id y13so46167139edd.13 for ; Sun, 12 Dec 2021 14:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=zSbkyaB70Oed8mKXQtN+DZs26po0lO093k/U8eZPZ8A=; b=TkoKSngSUEwNCOrO6PPJ3PwqqxBMBzHKdSEnL7k73WnBqzn7lZDnF3u64eie2H8VS/ eP7hKNVIDhV5P7AGwtUgYgoHhjXmVwk+pwtzA+w2o9jpQbQ0OmkfkKAzZEegY2bDCFYa lNIFnaUoFc1mi0q5vEqZ2PQ5uxIXycSeIf1V9E+QRGoaCNgpvFEFgpDy0a2HolZpXbI8 mQ+v881Av1oyfmOi4dktKYDNBNilcT96HMwC0fQ5wOxIzZpr4pmJtzns0W7Thw3r5qW7 XdAHA8ypoesdJUG4Sbk9B8srY46aG3OptlihRRO4OXhRfYsDWZ7lOadG7806erJOTxaU K+Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=zSbkyaB70Oed8mKXQtN+DZs26po0lO093k/U8eZPZ8A=; b=dj+GPJLZu+Xtr6iSljrS6EcK+LLgXDBoRAtHla0TO9I5ReB11QpWj8L/0y7Crh26h6 Km1AmARPWzPY9MN8W9qLZx7ClIpA48aa1CxikoSnOHt6mag6Gp3eZT70vHImpusRTuW5 fIdgXxZ8YbMdpu9tdqMaEfXHtSW04Snbjf2OwCwFnrnZqhUbWRAmvvH9gdzItEKCtH07 eX/GXmKNSor8qLIwsGzBmEbAonYjoYHcS+O9SqShaT9/eZ4gtDXK91+kdjICG28i1N7M j7vbmlQsQX00wiZe5cVWn6TIa6hBHBPIZ1XqjYdf6n02IMUDCl+rgxMIP3ru3GqB1GpF 6Bfw== X-Gm-Message-State: AOAM532Uo8qg49YcOfgD2tg+57fuh5Fk77v1nmAsMc1Gpjt+SZUKXcFN Qia8ALUxNrzEujC0mzDCgO+Wc9AHrQFbcS86QI8v7ULcA8dXBqIzmKIONccdJ0P2AkW5Lwb8U/y 1oxzExBD8sIg2Ls/zvaQlDEXJTr/rfBB9rnGBxgTHW3TmfPouQkUGtje2SLBn+BBd72eblpIqvy OozPrM0LSuAzfOvUSIFTJ7EnPCSnbjOMdwPTjG8LY5g3p7 X-Google-Smtp-Source: ABdhPJxYNsIUlehG6TOW90CeoEfUHSSdXaTZKhj52NP563lXzv09zqUZ3xuHKMm73JQ2BueHgYgjGw== X-Received: by 2002:a50:e0c9:: with SMTP id j9mr59542552edl.336.1639349986497; Sun, 12 Dec 2021 14:59:46 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-251-241.net.upcbroadband.cz. [86.49.251.241]) by smtp.gmail.com with ESMTPSA id r24sm5163505edv.18.2021.12.12.14.59.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Dec 2021 14:59:45 -0800 (PST) Message-ID: <7c191fd2-9103-ae81-8f4f-22f39edd3c90@enterprisedb.com> Date: Sun, 12 Dec 2021 23:59:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: BUG #17334: Assert failed inside computeDistance() on gist index scanning Content-Language: en-US To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form References: <17334-135f485c21739caa@postgresql.org> From: Tomas Vondra In-Reply-To: <17334-135f485c21739caa@postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/12/21 17:00, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 17334 > Logged by: Alexander Lakhin > Email address: exclusion@gmail.com > PostgreSQL version: 14.1 > Operating system: Ubuntu 20.04 > Description: > > When executing the following queries: > CREATE TABLE point_tbl(f1 point); > CREATE INDEX gpointind ON point_tbl USING gist(f1); > INSERT INTO point_tbl SELECT ('0,0') FROM generate_series(1, 185); > INSERT INTO point_tbl VALUES ('0,NaN'); > SET enable_seqscan=off; SELECT f1 <-> point '(0,0)' AS dist FROM point_tbl > ORDER BY dist; > FWIW I can reproduce this on master too. The failure happens because of NaN value in the index: #3 0x00000000004d3e72 in computeDistance (isLeaf=false, box=0x760f5ce13b28, point=0x1f99608) at gistproc.c:1240 1240 Assert(box->low.y <= box->high.y); (gdb) p box->high $1 = {x = 0, y = nan(0x8000000000000)} and indeed, pageinspect says this: test=# select * from gist_page_items(get_raw_page('gpointind', 2), 'gpointind'::regclass); itemoffset | ctid | itemlen | dead | keys ------------+---------+---------+------+---------------- 1 | (0,94) | 40 | f | (f1)=((0,0)) 2 | (0,95) | 40 | f | (f1)=((0,0)) ... 92 | (0,185) | 40 | f | (f1)=((0,0)) 93 | (1,1) | 40 | f | (f1)=((0,NaN)) (93 rows) I'm not sure if the issue is in allowing the NaN to be added to the index, or not handling it correctly during the index scan. It's interesting btree_gist does not have issues (for NaN in float8 columns). It seems not to store NaN in the index, It seems to replace them with tiny values, at least according to pageinspect. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company