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.94.2) (envelope-from ) id 1tpj0J-00B15A-JH for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Mar 2025 07:17:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tpj0G-003IUg-Av for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Mar 2025 07:17:16 +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.94.2) (envelope-from ) id 1tpj0F-003IUX-TX for pgsql-hackers@lists.postgresql.org; Wed, 05 Mar 2025 07:17:16 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tpj0C-0013Jq-0o for pgsql-hackers@lists.postgresql.org; Wed, 05 Mar 2025 07:17:15 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-390df942558so4992592f8f.2 for ; Tue, 04 Mar 2025 23:17:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741159032; x=1741763832; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=6GyGbMXfOu1VdMG1kA2U6MuNkHEmF0FYqNILKu3B34A=; b=KVYenLG1YHOWJDxnvV7D2YeK106RfMUq+mqvGdAl6qRADtoY3WQrJ+2p6JnqI/Qq1H sXzFpGkd9cp36AcF1HmrcysfC+cPDBYhkvmaZ/lVkLW9m/X4P1RKvDuzvL/Hl8QhbRhm u2be8qVrDYFXfHYNQg/3/PjZ4kl9CdWZBuY7kuTEdy5+4iAMygBACLc7fZVsSp4Ucqaq 54Izd4lRBkTgwnRgmql4phP5OLJz0udVkE4JbmffdZHnAjlLTdwK5CVD2CMgSEA0w7qq u6KMHcG0K3wy3msZ8i4+fsHFgRLqlkKBe3cWGqgGJyMFhUGfNsWAqDVVbUAEFBAyaacw qgNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741159032; x=1741763832; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6GyGbMXfOu1VdMG1kA2U6MuNkHEmF0FYqNILKu3B34A=; b=ECIOMfZv9AD44kGcColaicUUoO8zd8NBebCoBkiszklRUod8TIEGGagfUMMnJj4tpY NhL1rGP1lmoyrbdGt+9asiiOYX+dmZg0Qaf+3Xix/BGvu1c7qipGNwJk39LuUYDTRl5P r8ejSw0CcEmLbqCT7r0+I5nLpUXhEEmUT80V/nOytHgdZp8rRtm2huD9mDS7mQQH9uC0 r3IHD7MzlRXcggUQPmhBkNJiW/DY5hzWqsCT+BHiaNejkkum63KUEMFf44kt5xTM4rGF 3R23q/JvZcSKwyOhOWjj0QzslTBsm12xe6iTvNkRDvra8H/HDq79kComoxxiB69yDtX7 gw2Q== X-Forwarded-Encrypted: i=1; AJvYcCXdWg/qKSJJ+V8M39omXBDd54ZOwPWGH6bH+Gh1zqy5CtOWfqyfpMSBCy6r98pexKjEvw4y34JHb5THwcq4@lists.postgresql.org X-Gm-Message-State: AOJu0Yz5f4AUzjZN8TCKwcFG+HeIYt0YgISgOFFpk7BobdVdulVqjO3o O0viRRD0+tesHdTXWdtA1dJh/JNzqVkYxQIASgZSSZ8KytGfZxWr X-Gm-Gg: ASbGncuTTZDATQ/Q4OouIBexkKoVeh66CL2H+1wPzd/8uOL0W7NDTG2NLh+T+eToTS6 6O9vHuUgGaMK9CtMmeXDEPqHJQTu7FuBLfCNwtYAlGkA2oCQy4j0vaAw7KRYTFLasvpoDWqrAAe mWjVb6C4WyoaxbVSMrvpiJqVBPIEN3ECsLTsre0p4KHWwx6iAkzXtC0aFPSBrevsmfhCzaaxxy1 EO7YKTi6Q+vz1SPJhmJMRdnpeoIZqK9J19+UABTc8m4LAJGOs0ZXJ77v5/ZYOawybDMxxq0kx4q qfnddT+shMbUOiAOUm0mTtDIslSjQ1sEuq8NNuji4vs4c3fq6aAq5djRgj+C+8ISrPFdu4g7PG4 BnJ0NRpBxzpxmFXhp+uNoMEp+b3YGlWFRWs6ZpXF1qSNN5xx0wzuD0Mxc4rlizqvBU3GQTWNsdF pj X-Google-Smtp-Source: AGHT+IEEmGnjI81u3eahUlY3qH32/y0ClXEOg6aGEvXOrJVe9J8GwO4l205IPKbMDMex8gPhR2XRqQ== X-Received: by 2002:a05:6000:1562:b0:391:901:311c with SMTP id ffacd0b85a97d-3911f74bd4emr1259143f8f.32.1741159032045; Tue, 04 Mar 2025 23:17:12 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-181-182.eu-west-3.compute.amazonaws.com. [15.237.181.182]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43bd4291cb9sm8552875e9.13.2025.03.04.23.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 23:17:11 -0800 (PST) Date: Wed, 5 Mar 2025 07:17:09 +0000 From: Bertrand Drouvot To: Masahiko Sawada Cc: Andres Freund , Peter Smith , Peter Eisentraut , shveta malik , Amit Kapila , Bharath Rupireddy , pgsql-hackers@lists.postgresql.org Subject: Re: Add contrib/pg_logicalsnapinspect Message-ID: References: <5qbxud4pvnvmtuoi7weiizm5hmumxaeohx4vztfhrwlfhyz6rj@buh4435mllwo> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="VovpDQTxM1mVjnnL" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --VovpDQTxM1mVjnnL Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, On Tue, Mar 04, 2025 at 10:25:57PM -0800, Masahiko Sawada wrote: > On Tue, Mar 4, 2025 at 1:56 PM Andres Freund wrote: > > > Thank you for the report. +1 > It seems that bgwriter wrote another RUNNING_XACTS record during the > test, making the logical decoding write an extra snapshot on the disk. Yup. > One way to stabilize the regression test would be that we check if > there is a serialized snapshot that has expected number of catchange > transactions and number of committed transactions, instead of dumping > all serialized snapshots. Agree, PFA a patch doing so. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --VovpDQTxM1mVjnnL Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-Modify-pg_logicalinspect-isolation-test.patch" From d590d3184d4345908f1b033aa8a5d19cf98e88ba Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Wed, 5 Mar 2025 07:06:58 +0000 Subject: [PATCH v1] Modify pg_logicalinspect isolation test The previous version was relying on the fact that the test produces exactly 2 snapshots on disk, while in fact it can produce more. Changing the test knowing that at least 2 snapshots are generated. Per buildfarm member skink. --- .../expected/logical_inspect.out | 29 +++++++++++-------- .../specs/logical_inspect.spec | 7 +++-- 2 files changed, 21 insertions(+), 15 deletions(-) 57.3% contrib/pg_logicalinspect/expected/ 42.6% contrib/pg_logicalinspect/specs/ diff --git a/contrib/pg_logicalinspect/expected/logical_inspect.out b/contrib/pg_logicalinspect/expected/logical_inspect.out index d95efa4d1e5..ecba05b9ab1 100644 --- a/contrib/pg_logicalinspect/expected/logical_inspect.out +++ b/contrib/pg_logicalinspect/expected/logical_inspect.out @@ -1,6 +1,6 @@ Parsed test spec with 2 sessions -starting permutation: s0_init s0_begin s0_savepoint s0_truncate s1_checkpoint s1_get_changes s0_commit s0_begin s0_insert s1_checkpoint s1_get_changes s0_commit s1_get_changes s1_get_logical_snapshot_info s1_get_logical_snapshot_meta +starting permutation: s0_init s0_begin s0_savepoint s0_truncate s1_checkpoint s1_get_changes s0_commit s0_begin s0_insert s1_checkpoint s1_get_changes s0_commit s1_get_changes s1_get_logical_snapshot_info_catchange s1_get_logical_snapshot_info_committed s1_get_logical_snapshot_meta step s0_init: SELECT 'init' FROM pg_create_logical_replication_slot('isolation_slot', 'test_decoding'); ?column? -------- @@ -37,16 +37,21 @@ table public.tbl1: INSERT: val1[integer]:1 val2[integer]:null COMMIT (3 rows) -step s1_get_logical_snapshot_info: SELECT info.state, info.catchange_count, array_length(info.catchange_xip,1) AS catchange_array_length, info.committed_count, array_length(info.committed_xip,1) AS committed_array_length FROM pg_ls_logicalsnapdir(), pg_get_logical_snapshot_info(name) AS info ORDER BY 2; -state |catchange_count|catchange_array_length|committed_count|committed_array_length -----------+---------------+----------------------+---------------+---------------------- -consistent| 0| | 2| 2 -consistent| 2| 2| 0| -(2 rows) - -step s1_get_logical_snapshot_meta: SELECT COUNT(meta.*) from pg_ls_logicalsnapdir(), pg_get_logical_snapshot_meta(name) as meta; -count ------ - 2 +step s1_get_logical_snapshot_info_catchange: SELECT count(*) > 0 as has_catchange FROM pg_ls_logicalsnapdir(), pg_get_logical_snapshot_info(name) AS info where info.catchange_count = 2 and array_length(info.catchange_xip,1) = 2 and info.committed_count = 0; +has_catchange +------------- +t +(1 row) + +step s1_get_logical_snapshot_info_committed: SELECT count(*) > 0 as has_committed FROM pg_ls_logicalsnapdir(), pg_get_logical_snapshot_info(name) AS info where info.committed_count = 2 and array_length(info.committed_xip,1) = 2 and info.catchange_count = 0; +has_committed +------------- +t +(1 row) + +step s1_get_logical_snapshot_meta: SELECT COUNT(meta.*) > 1 AS has_meta from pg_ls_logicalsnapdir(), pg_get_logical_snapshot_meta(name) as meta; +has_meta +-------- +t (1 row) diff --git a/contrib/pg_logicalinspect/specs/logical_inspect.spec b/contrib/pg_logicalinspect/specs/logical_inspect.spec index 9851a6c18e4..673d2f5ed0a 100644 --- a/contrib/pg_logicalinspect/specs/logical_inspect.spec +++ b/contrib/pg_logicalinspect/specs/logical_inspect.spec @@ -28,7 +28,8 @@ session "s1" setup { SET synchronous_commit=on; } step "s1_checkpoint" { CHECKPOINT; } step "s1_get_changes" { SELECT data FROM pg_logical_slot_get_changes('isolation_slot', NULL, NULL, 'skip-empty-xacts', '1', 'include-xids', '0'); } -step "s1_get_logical_snapshot_meta" { SELECT COUNT(meta.*) from pg_ls_logicalsnapdir(), pg_get_logical_snapshot_meta(name) as meta;} -step "s1_get_logical_snapshot_info" { SELECT info.state, info.catchange_count, array_length(info.catchange_xip,1) AS catchange_array_length, info.committed_count, array_length(info.committed_xip,1) AS committed_array_length FROM pg_ls_logicalsnapdir(), pg_get_logical_snapshot_info(name) AS info ORDER BY 2; } +step "s1_get_logical_snapshot_meta" { SELECT COUNT(meta.*) > 1 AS has_meta from pg_ls_logicalsnapdir(), pg_get_logical_snapshot_meta(name) as meta; } +step "s1_get_logical_snapshot_info_catchange" { SELECT count(*) > 0 as has_catchange FROM pg_ls_logicalsnapdir(), pg_get_logical_snapshot_info(name) AS info where info.catchange_count = 2 and array_length(info.catchange_xip,1) = 2 and info.committed_count = 0; } +step "s1_get_logical_snapshot_info_committed" { SELECT count(*) > 0 as has_committed FROM pg_ls_logicalsnapdir(), pg_get_logical_snapshot_info(name) AS info where info.committed_count = 2 and array_length(info.committed_xip,1) = 2 and info.catchange_count = 0; } -permutation "s0_init" "s0_begin" "s0_savepoint" "s0_truncate" "s1_checkpoint" "s1_get_changes" "s0_commit" "s0_begin" "s0_insert" "s1_checkpoint" "s1_get_changes" "s0_commit" "s1_get_changes" "s1_get_logical_snapshot_info" "s1_get_logical_snapshot_meta" +permutation "s0_init" "s0_begin" "s0_savepoint" "s0_truncate" "s1_checkpoint" "s1_get_changes" "s0_commit" "s0_begin" "s0_insert" "s1_checkpoint" "s1_get_changes" "s0_commit" "s1_get_changes" "s1_get_logical_snapshot_info_catchange" "s1_get_logical_snapshot_info_committed" "s1_get_logical_snapshot_meta" -- 2.34.1 --VovpDQTxM1mVjnnL--