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 1nKUTk-00021H-4y for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Feb 2022 00:17:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nKUTi-0001in-Fz for pgsql-bugs@arkaria.postgresql.org; Thu, 17 Feb 2022 00:16:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nKUTh-0001iX-Oc for pgsql-bugs@lists.postgresql.org; Thu, 17 Feb 2022 00:16:58 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nKUTc-0003q2-4Q for pgsql-bugs@lists.postgresql.org; Thu, 17 Feb 2022 00:16:56 +0000 Received: by mail-ed1-x534.google.com with SMTP id w3so6713367edu.8 for ; Wed, 16 Feb 2022 16:16:51 -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 :cc:references:from:in-reply-to:content-transfer-encoding; bh=OlcEBEoj80yfUqJI5l9klpMyPA6ub8DjhhAybFPEjWk=; b=QjRKRynlsmrtwf6PqrOWS1qFVoT/jIUQ61ueRz+nfLMJlG/BuKo0CgUEm5/CfUsLxm nJ6R//fN64B7BkLN4dm5p13io964Xb9e1lxNFhG5vqMZPKGe/uLRQugYZhP45avnSnQP g8vUqc/UgC9DoF/8bZzMovYeiUy4S2OyPIZ12/2VyYKG3U+qAlk/0ps8zVrevTozvETF OajyM07qOEM0FiPgruDjBj1AWXHwUwy0kNuvpDLZ4hV8cvvJHtdIv87dJ4FW/FkwRqCM GYEGh1HJU7y3q0XnGQ4sX476gX7pImeuDuE9LTtfQI4XkfwypTt13GaAC2YVPiML3v0d srsg== 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:cc:references:from:in-reply-to :content-transfer-encoding; bh=OlcEBEoj80yfUqJI5l9klpMyPA6ub8DjhhAybFPEjWk=; b=n6We/RgEPstCzOwth0ir1OMTif4X7W/wv7KJexInjqLHqDenoCBqBQrrrWLFCNEa16 b4lZZta+lTgaxumdQHFT7WfkqAKxP8W1qeGrJY8gSx3IlMKzAMpIwEq7zT4tl9zFmGkE 7XTqJub5l6vXV1ll1WitV3QB+Mw6a+CYgxCH+0v8A1o8g64bfCrcBm5igFDCpIMfanqr vnND/5UHTQ3TCC6VAMGjsI+kzx9vsfwHEI6EEqmAUKuq8d0LbNl8AfouLOI+z6EBWC99 UMO6gOaG9xuyTxxcpA5+ihWDNXk3Es0ppeKLmyyyD8yHug1o5eFBWiMn4f0w2b0WDrJO ZnnA== X-Gm-Message-State: AOAM531GY8lZtDKtkHkcIQB9unMo/leNkWBZ9wJt05Kof3QoeWw4ffSw 0VxvxmECioL0za5I2VtGr0rNFRQLMuejUXgQw4eUkArCFDYXdqJNSTmq9wx5C/uyZxtg+WfuyV+ M1IK06tXHlk6htkRJmewAcXDAK42rCVBlCoeU1e00up+9tDRvq1uJSx6K5Jnoowgul9KxR4F08t Mg6m6iM7JOMeKNetEHc+2l92LdD88jK1mCfrac8lidFehO X-Google-Smtp-Source: ABdhPJxaeac+8WZQ9i9S8gJwUxTEDGSFkeDsofPevLeOFnHiGM2KiVzFSYWMxhlsDE3RoH7CSFEWTA== X-Received: by 2002:a05:6402:50c7:b0:410:b745:1a6c with SMTP id h7-20020a05640250c700b00410b7451a6cmr253826edb.228.1645057010529; Wed, 16 Feb 2022 16:16:50 -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 b11sm2563606edd.17.2022.02.16.16.16.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Feb 2022 16:16:49 -0800 (PST) Message-ID: <788a0a51-b1e3-3601-5783-3f6488796ec4@enterprisedb.com> Date: Thu, 17 Feb 2022 01:16:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: BUG #17406: Segmentation fault on GiST index after 14.2 upgrade Content-Language: en-US To: Victor Yegorov Cc: PostgreSQL mailing lists References: <17406-71e02820ae79bb40@postgresql.org> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 2/16/22 09:14, Victor Yegorov wrote: > вт, 15 февр. 2022 г. в 22:51, Tomas Vondra > >: > > Hmm. So I guess there are three options: > > 1) The index was already broken on 12.9, but for some reason (choice of > a different plan, ...) it was not causing any issues. > > > Nope, index is actively used on 12.9, plan hasn't changed. > OK, that's valuable information. > How large is the table/index? Are you able to run the query with a > custom build (without values optimized out)? Any chance you still > have a > backup from before the pg_upgrade, on which you might run the query? > > > Yes, this is a test DB restored from backup in order to test out 14 > upgrade, production is still running on 12.9. > v3_region is 2832 kB > region_ltree_path_idx_gist is 472 kB > That means it should be possible to reproduce the issue elsewhere by copying the files (and schema). Is there any sensitive data that'd prevent handing over this data? > > (gdb) frame 7 > #7  gistScanPage (scan=scan@entry=0x55bbbd4196c8, > pageItem=pageItem@entry=0x7ffdac2e3fe0, > myDistances=myDistances@entry=0x0, tbm=tbm@entry=0x0, > ntids=ntids@entry=0x0) at ./build/../src/backend/access/gist/gistget.c:438 > 438     ./build/../src/backend/access/gist/gistget.c: No such file or > directory. > (gdb) p pageItem->blkno > $1 = 0 > (gdb) p pageItem->data->heap > $5 = {heapPtr = {ip_blkid = {bi_hi = 0, bi_lo = 0}, ip_posid = 0}, > recheck = false, recheckDistances = false, recontup = 0x55bbbb96927e > , offnum = 38600} > > This query below also crashes with SegFault: > SELECT * FROM gist_page_items(get_raw_page('region_ltree_path_idx_gist', > 0), 'region_ltree_path_idx_gist'); > Interesting! What's the backtrace from the crash? FWIW when I try that query on the gist index from the ltree example in our documentation, I get this: test=# SELECT * FROM gist_page_items(get_raw_page('path_gist_idx', 0), 'path_gist_idx'); WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b4ae0, chunk 0x21b5ff8 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b4ae0, chunk 0x21b6f20 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b4ae0, chunk 0x21b7e48 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b4ae0, chunk 0x21b8db0 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b4ae0, chunk 0x21b9d18 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b4ae0, chunk 0x21bac80 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b0ad0, chunk 0x21b1360 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b0ad0, chunk 0x21b2288 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b0ad0, chunk 0x21b31f0 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21b0ad0, chunk 0x21b4158 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21aaab0, chunk 0x21adb20 WARNING: problem in alloc set ExprContext: detected write past chunk end in block 0x21aaab0, chunk 0x21ae5c8 itemoffset | ctid | itemlen | dead | keys ------------+--------+---------+------+----------- 1 | (0,1) | 32 | f | (path)=() 2 | (0,2) | 48 | f | (path)=() 3 | (0,3) | 64 | f | (path)=() 4 | (0,4) | 80 | f | (path)=() 5 | (0,5) | 80 | f | (path)=() 6 | (0,6) | 48 | f | (path)=() 7 | (0,7) | 72 | f | (path)=() 8 | (0,8) | 48 | f | (path)=() 9 | (0,9) | 64 | f | (path)=() 10 | (0,10) | 80 | f | (path)=() 11 | (0,11) | 88 | f | (path)=() 12 | (0,12) | 96 | f | (path)=() 13 | (0,13) | 96 | f | (path)=() (13 rows) This is on debug build with asserts. On non-assert build it crashes in AllocSetAlloc, but I'd bet the exact place where it crashes just depends on what place we corrupt by writing out of ExprContext. The empty paths seem strange too, of course. But the confusing thing is I get similar issues even on 12.10 (after backporting the pageinspect gist changes) - but only with asserts, and without asserts it works (but the paths are still empty). Perhaps I backported that incorrectly, though. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company