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 1wDqjD-003QVW-1c for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Apr 2026 21:27:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDqiC-00BAy5-18 for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Apr 2026 21:26:52 +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.96) (envelope-from ) id 1wDqiC-00BAxx-08 for pgsql-bugs@lists.postgresql.org; Fri, 17 Apr 2026 21:26:52 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wDqi9-00000001iUP-3qlE for pgsql-bugs@lists.postgresql.org; Fri, 17 Apr 2026 21:26:51 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-43d6fbd0954so844090f8f.1 for ; Fri, 17 Apr 2026 14:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776461208; x=1777066008; 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=1aR5w8Ry0YkUk6vGfKZckMITdSa+UvYQ6CkhCSAjIKw=; b=Mj3BCwlCUew1fAIutITBWjcPKf4Uk9ijThRJGRAXRjUN9BRqHBFNh3me3MF6kgJ2yL ExhdvRjACCWm2/JI14xd3k+V7hG8Qz8HxvB+m0d4b1BgeoGB8UWvtn0dXusNwJSyj04b ZGhBIHXi18L8tAlnLY5tJ/q39DdtGZ2moiy3JNEOt8E+yMoIK3XR+1jCzXPCHW2RqefZ FWhnS4NN0sPm25W8vhrctvz7kV9Mfxq5ali2gfud8UP2ceqk3IM4iHPf3e3ik3SglQec qHUIqAOPrCzB1nAaamAq/3NdwxhAixRz7eStE5VbBgqr3bkW6ZJFqioPUbxd8hyvQGVf /aKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776461208; x=1777066008; 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=1aR5w8Ry0YkUk6vGfKZckMITdSa+UvYQ6CkhCSAjIKw=; b=dAPWL8wz4dIftK46FEsDutSyzH7fHkiZg7hEdPIaOXLMdhcuVe35OfTtbt0bjf1kIF OxevMUKeUGGzlkv3OUFdqzmFx3AYVGgncEoactgnt/I1vUCqlXAMKAlvTy2EACy43D2D /G7bw7k6WnkyOkDpYTwGiZN5DyFEzIq/JmjDWN7YJR3BGZcOJ4ErkficwAiM/D3tExdC HTWA/wy55oieXwWsD9NL8x2RiA/BJMHeOFw64IHJ/lkMUbEz4qF7dXcwvy5U0kGsAWK5 zdS75dTUkFcm3dZ53V+zM0w4zq0W6oc/D1Bmu3ddCQbz0S8jNj+KoSSCHGUzeJ1ZEWw5 5rPQ== X-Gm-Message-State: AOJu0YwJWWiLDoOC61O090lE36DSb8bgC6aTiei2eLobGJ8eA0jgJmXt XnUPZuJr5yb+F6gQ9c/IuFAvH2iuu4YgAHtsVGsphTWE5DcDxNLQq52i X-Gm-Gg: AeBDiesLwJPEo78TBnICAJri93x06iSzPxLRBF3wmNSVJYnp/eMzZKOcR8c3Ez5KtOj 2rnAa6b8uxBScoPR1+qhb8BGIAv7javkqsbO2LhiLKVisOX9znA0U96/S9dQ0mwS1+z3GF3RHHm TAAy9Gy1DiEKDHMfKzMASUX/jraQKyaIYaMiY/bmIdyUtxBFhkzAYbVAnp9b5f0X7FM3mdmeWjA 5vYFYOrLtDBHppLCQ9XhfZARzeII9XSE/qLV779FCBa6HoO8HL0cgepopmcP16jwOxCXJ+t1WJT q0k0IBU6urwTMLMnDkT0YxxPBKU+BbkUf81SFXiBmuS1MXw47F/S9cnraSPuWrOWTpLEbw3JhV2 McapwCxFQSgs1s47xO2qsfW6aglTawfvYErneQo3GDdGESfnMchUbCHLdgjf69wo/6AxRItu25u y1LDp1JiZkNPC6+Q+cDArKFXLHzPm/gCwKyWPgiYyvAe/7tRq6ezgh7DZzeK8as8r5CCKJdDwkR HVVHCcA/A== X-Received: by 2002:a05:6000:2282:b0:43d:7883:87c2 with SMTP id ffacd0b85a97d-43fe3e0ab3amr6444773f8f.39.1776461207640; Fri, 17 Apr 2026 14:26:47 -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 ffacd0b85a97d-43fe4e3a397sm7947864f8f.23.2026.04.17.14.26.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Apr 2026 14:26:46 -0700 (PDT) Message-ID: Date: Fri, 17 Apr 2026 23:26:45 +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 16/04/2026 19:58, Masahiko Sawada wrote: > On Thu, Apr 16, 2026 at 1:26 AM Andrei Lepikhov wrote: >> >> On 16/04/2026 10:11, Masahiko Sawada wrote: >>> On Thu, Apr 16, 2026 at 12:13 AM Andrei Lepikhov wrote: >>> -- Random TIDs test. The offset numbers are randomized and must be -- >>> unique and ordered. INSERT INTO hideblocks (blockno) SELECT >>> do_set_block_offsets(blkno, array_agg(DISTINCT greatest((random() * >>> :maxoffset)::int, 1))::int2[]) FROM generate_series(1, 100) >>> num_offsets, generate_series(1000, 1100, 1) blkno GROUP BY blkno; >> >> Alright, I used an explicit sort in reverse order to make sure the test is >> stable. I usually create modules that may change different paths, costs, and >> orders, and using random can make things unpredictable. But for this specific >> test, I don't see any risk. >> >>> >>> While I agree that we need to sort the offset numbers, I think it >>> would be better to make sure the offset numbers in the array to be >>> sorted in a test_tidstore.sql file where required, instead of doing so >>> for all cases. >> >> I'm not sure I follow. Are you saying that do_set_block_offsets shouldn't sort >> the incoming offsets? > > No, I wanted to mean that if we sort the given array in > do_set_block_offsets() as the proposed patch does, we end up always > sorting arrays even if the sorting is no actually required (e.g., when > executing "SELECT do_set_block_offsets(1, > array[1,2,3,4,100]::int2[]);"). So an alternative idea to stabilize > the regression test would be to create a SQL function to return a list > of sorted offsets and use it where it's required. While the patch gets > a little bigger, It would also help simplify the tests somewhat by > removing the redundant codes. I've attached the patch for this idea. Ok. No objections. Both changes are just test routines registered by the test_tidstore module. I decided to add C code, mostly following the idea that we reuse examples from the Postgres codebase when writing our patches/extensions. An explicit demonstration of the sort contract on the TidStoreSetBlockOffsets() call might help developers who don't read function comments each time. -- regards, Andrei Lepikhov, pgEdge