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.96) (envelope-from ) id 1wFbIh-005LTM-1E for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Apr 2026 17:23:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFbIe-00EYxW-2H for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Apr 2026 17:23:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wFbIe-00EYxO-1S for pgsql-bugs@lists.postgresql.org; Wed, 22 Apr 2026 17:23:44 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wFbIc-00000002Hhp-1Wf8 for pgsql-bugs@lists.postgresql.org; Wed, 22 Apr 2026 17:23:43 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-b9c01854477so1030660666b.0 for ; Wed, 22 Apr 2026 10:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776878621; x=1777483421; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bRYwZNYGIkTa+hEWMyX3EtpwtdJnRqrTAaGGGwtk1HQ=; b=LShn5cG/71yKhRR0X6NioH2gzp/rh+Ft6Thkg16kDq4cd8mzUAp9zULyHLGEAcsXLE Ha2bD34/WftR1CupW45wINrCJEVnN8h3i9V3ppGnVX4/80e1Q+wW83ybYna4Zf3rkzGL BhXh1J+swuuAhr2Nsu5TxVoaE0d6avFYu6dvblo0QwYl2zokqI+3EebD+7ZMVbXQhkWp YDYOtHmQYTjpvw5FRk/UH5AnJiGm7qlJ3YpLSVvRUzUGGc1XUJrunXuDqcg7kjPy7tEP ffAFTSAkd6WbKsTRfUT23SBbKObpUvf1WXs48FVA4Q07SnOZJFZhe5808vB9xdGaIkYs KDjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776878621; x=1777483421; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bRYwZNYGIkTa+hEWMyX3EtpwtdJnRqrTAaGGGwtk1HQ=; b=YPWLuvKtKGpC4sGlSq04ReOrrhmRfJTXWkzOGNv42rBcJFX+/KV2I++Yc21ko7PfLA JYIOm8hqAInTSYkag8uGK6JWQv+aZ5K1DSmNV1P1HkXMf0MEjVvjByET19l/agH6rSmm evRnYdsccDjfQ7IfN9xU1ZtXD0VTu5A0+bLVO57ZHytHeHCkVJR7amNwAxOOZJ3o3HA1 P3tR8GtGIk2EXiqKxjh1r8ZXBPWwho6jgReN6G2jUPu5ktgHtQSVQvswUzVeJ8lSqS9+ z0tSTpB8XYNya5MWaMAYdj8Hiq9pxepyMYvLipIUuMdQx4Zgg8SVclfvyQnQku+FPgLr ihgA== X-Gm-Message-State: AOJu0Yzdi2pfypC8wtddGXWYlLX+Rv/0TottmYxe4cTq5kS9n0Jc1M0Y FmoomJDr2SpueovauI7zmrkwVDG3D6T8U800OOBQCwhyDa7WbfW0PhoZ X-Gm-Gg: AeBDievsvNVgtv1F3rQeoltLUgpbvG+7OI8O+Gx5tUxvp7ni0Ur5lsziM85+HWTlZPp LIOuJrdxgQJGyHCd3FDFoGq0faMZaq0bNiziR1cug4wyNpUE43Bs7WoS+v0SsX0oP0ycqAC3BT7 VICIGPgEEMS+3/imhB4E0B7wefYmLCj46xkX87d8fJW6JJu7KU+pKbb/rzCnOnjCIMqnR4PmLOO 2r4z8I4QRFGWI33V99l/5Vgzyfm1/jYrJRcjk+dugWv3LYsGCB5JHqNEKk9FYPGI0+1t9ke/ey7 5ycgGTFV5QfC26d5k4oB9SxXFMyL2k0+j5Ppvy2TIlyaApPZqGOgbnstodCQdGQS0tJQE9YA+Yt y2rztOuBwKsFlIXhhVEX7BDiRudqOcyby/lCYQ2qugWEsFn0QrXaBs3lBGcymOsxUiV7cndL4A+ aqw1K3vQuxV6PadYE1stt22TDTUs9MasIP3cHC6KuvTDs5G6/ipwxB96kxrDYNESnD1tvH3NHfx pAyTB0ggw== X-Received: by 2002:a17:906:c142:b0:ba8:7211:58c with SMTP id a640c23a62f3a-ba8721111d5mr705874066b.18.1776878620897; Wed, 22 Apr 2026 10:23:40 -0700 (PDT) Received: from [192.168.0.86] (84.123.230.95.dyn.user.ono.com. [84.123.230.95]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488ffad20f2sm213869365e9.0.2026.04.22.10.23.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Apr 2026 10:23:40 -0700 (PDT) Message-ID: <9dece148-3e1d-4b0f-b798-574988fe76fe@gmail.com> Date: Wed, 22 Apr 2026 19:23:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: TRAP: failed Assert("offsets[i] > offsets[i - 1]"), File: "tidstore.c" To: Masahiko Sawada Cc: PostgreSQL mailing lists References: <119bd418-1d7a-42c7-9270-86f3b6696399@gmail.com> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 22/04/2026 18:51, Masahiko Sawada wrote: > On Fri, Apr 17, 2026 at 2:26 PM Andrei Lepikhov wrote: >> >> On 16/04/2026 19:58, Masahiko Sawada wrote: > Understood. After more thoughts, I think your idea would be better. > > One thing still unclear to me is in which situation the query inthe > test produces an array of unsorted offset numbers. While I understand > it's not guaranteed that the DISTINCT clause returns the sorted > result, doing DISTINCT in an aggregation function is using sort-based > deduplication. I'd like to confirm that the queries in the test could > end up producing the results that violate the assertion. Is it > possible to do that by changing GUC parameters or something? No, this is part of ongoing research into Postgres Optimizer vulnerabilities. I used two tools: pg_pathcheck [1] and pg-chaos-mode [2]. The first tool finds hidden dangling pointers in pathlists, which we are currently discussing in another thread. The second is a patch that makes the cost-based decision random to help uncover hidden or unwritten coding contracts. Both tools are experimental and not meant for core use; they are only used to trigger potential issues. In this case, I think the query picked a costly sorted path, which led to the crash. [1] https://github.com/danolivo/pg_pathcheck [2] https://github.com/danolivo/pg-chaos-test -- regards, Andrei Lepikhov, pgEdge