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 1pLJUB-0002aU-0T for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Jan 2023 07:49:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pLJU9-00013T-OC for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Jan 2023 07:49:21 +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 1pLJU9-00011R-DE for pgsql-hackers@lists.postgresql.org; Fri, 27 Jan 2023 07:49:21 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pLJU6-0004Vj-PH for pgsql-hackers@postgresql.org; Fri, 27 Jan 2023 07:49:20 +0000 Received: by mail-wr1-x42d.google.com with SMTP id q5so4200851wrv.0 for ; Thu, 26 Jan 2023 23:49:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vXCEba2E/iyGvwF0kArkEnshoV/sNPcTvui1eI4Dt1c=; b=arGnj/fAfESWz6DalOGRwT2JcvvvYEZ6/YTfQZeNkgMn2dvzipJwjuJyx99SGHF9Hd q6pkprX7JdyVu6HcHu7OwWBqLgOGH0AVnIZiXzXLnygk2kdMVDMHWhR/ljCD+ExP99rw iVzz8ThCXvXsGODKnDc2gv59UglPTTYKyqZgM6pAzlKcyFZmr1b5NT3IbwaN7wLPi7Qh hwmBHHwe3a5vSaCoGts8eSNlidZw+TAhLoFhZeatx8JdBnlE0qevOhBUqZzHJwAq6Fwm 4fRylUyVWwNwzoV68tZFcXzikYijVldeiDsX2EO62RYepXByPb2IJAbzQdeMd+j78S8E CSGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc: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=vXCEba2E/iyGvwF0kArkEnshoV/sNPcTvui1eI4Dt1c=; b=AQ1v2kTelbwIJHI/Cnr7Ea5tOb3af7SLvgDhDiBtyc55tFsOE+sUSqmAshdBqZzulH /088FEw9sTwX0nB/SslJLevYfMveICG40azzgxzUO9ur3CMkYgo+oYnQempPjDKEflHf 7Lb2mU2Gj6ZN24sOWSdEP7Z4FHgC/2xsQeLw12D3YhlSZUKu2+WFysqmGgyN99DPg971 QUeY+I0TfPmYpaZtIJ4ZSrR4+wbZhOnfdlD7AAegcQOd8bjraBG+a9OgY9eOqHoOJAFX Bdh8df/stftyUupLBd5liQ9QfChY2CWjFFaLtsbDqqNQUYulp1ox/OIB3Cw6E3Wfbo1R OR+g== X-Gm-Message-State: AO0yUKXp23XSEDnNNRExM4nf+tVqL7IL7QMCjCeYJFwW/aajrK8EYeO+ 4HFLDHNG5y8yj99ULGAa/dY= X-Google-Smtp-Source: AK7set/uPrvk8sGLMCtuCEx0IdLQXXxGrm5IaHXAQXCNFB3ixJd3m398bByv2o8XiWOvPIWsszVbdQ== X-Received: by 2002:adf:ef4d:0:b0:2bf:d115:f0fd with SMTP id c13-20020adfef4d000000b002bfd115f0fdmr2004995wrp.13.1674805757331; Thu, 26 Jan 2023 23:49:17 -0800 (PST) Received: from [192.168.10.24] ([54.239.6.186]) by smtp.gmail.com with ESMTPSA id z14-20020a5d4d0e000000b002bde537721dsm3270890wrt.20.2023.01.26.23.49.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Jan 2023 23:49:16 -0800 (PST) Message-ID: <85546caa-0402-382f-4f9d-9f0ff4af6d58@gmail.com> Date: Fri, 27 Jan 2023 08:49:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: Minimal logical decoding on standbys Content-Language: en-US To: Andres Freund Cc: Robert Haas , Thomas Munro , Alvaro Herrera , Ibrar Ahmed , Amit Khandekar , fabriziomello@gmail.com, tushar , Rahila Syed , pgsql-hackers References: <05c0c4f3-82eb-bc6d-c876-5a265c05927b@gmail.com> <20230106034036.2m4qnn7ep7b5ipet@awork3.anarazel.de> <490206c5-bcde-e558-628a-dc67dae4d439@gmail.com> <20230119024617.jzsgpcrgjdc6ysge@awork3.anarazel.de> <20230124004612.xmryok6tcyk6i4pc@awork3.anarazel.de> <9dfd49e6-6675-526e-0636-0ba09396744e@gmail.com> <20230126201349.pjdjdbxy4j4dn2vc@awork3.anarazel.de> From: "Drouvot, Bertrand" In-Reply-To: <20230126201349.pjdjdbxy4j4dn2vc@awork3.anarazel.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 1/26/23 9:13 PM, Andres Freund wrote: > Hi, > > On 2023-01-26 18:56:10 +0100, Drouvot, Bertrand wrote: >> - I'm struggling to create a test for btree killtuples as there is a need for rows removal on the table (that could produce a conflict too): >> Do you've a scenario in mind for this one? (and btw in what kind of WAL record should the conflict be detected in such a case? xl_btree_delete?) > > Hm, it might indeed be hard in "modern" postgres. I think you'd need at least > two concurrent sessions, to prevent on-access pruning on the table. > > > DROP TABLE IF EXISTS indexdel; > CREATE TABLE indexdel(id int8 primary key); > INSERT INTO indexdel SELECT generate_series(1, 10000); > VACUUM indexdel; -- ensure hint bits are set etc > > DELETE FROM indexdel; > > SELECT pg_current_wal_insert_lsn(); > > SET enable_indexonlyscan = false; > -- This scan finds that the index items are dead - but doesn't yet issue a > -- btree delete WAL record, that only happens when needing space on the page > -- again. > EXPLAIN (COSTS OFF, SUMMARY OFF) SELECT id FROM indexdel WHERE id < 10 ORDER BY id ASC; > SELECT id FROM indexdel WHERE id < 100 ORDER BY id ASC; > > -- The insertions into the range of values prev > INSERT INTO indexdel SELECT generate_series(1, 100); > > > Does generate the btree deletion record, but it also does emit a PRUNE (from > heapam_index_fetch_tuple() -> heap_page_prune_opt()). > > While the session could create a cursor to prevent later HOT cleanup, the > query would also trigger hot pruning (or prevent the rows from being dead, if > you declare the cursor before the DELETE). So you'd need overlapping cursors > in a concurrent session... > Thanks for the scenario and explanation! I agree that a second session would be needed (and so I understand why I was struggling when trying with a single session ;-) ) > Too complicated. > Yeah. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com