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 1wWpYm-002ssQ-0u for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jun 2026 06:03:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wWpYl-005DzU-0f for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jun 2026 06:03:35 +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 1wWpYk-005DzM-2D for pgsql-hackers@lists.postgresql.org; Tue, 09 Jun 2026 06:03:34 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wWpYi-00000001nno-0N6P for pgsql-hackers@postgresql.org; Tue, 09 Jun 2026 06:03:33 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-46015dc517aso4099591f8f.2 for ; Mon, 08 Jun 2026 23:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780985010; x=1781589810; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=GJB5jLKtnzx0Uw3mhH2PesM74Ru6QsJEyPDvmei98OA=; b=sDsZmAtCagY9XuGulxecbypx8LK13Sd45IJHXqesFEC9+rZFkivxRaALKpG/GcfVR+ 85ivFFLWiolCjJ+I+MyJQP/n0wvk9EOR6/VJipUYP48L89h4VFN9Zfwg4G2KV3ohbur1 Es61fXn5SJVK54+Gh/khgPod/gV3YkKnsMK4YLNRUZljXX5cE5wiLKnwdg+ufpbkmfeP XX0Oxyehuvg/glqVkMRDlxgnagQjxqY6+IP8gDvQIj4GGgVm7vSgr/neo3uMOFwtUS3E LHDJvJ/SvV46UUBUj2ENO8asPSea1vMc0a3KwuFrLXsu/OscJ8xuVLQ5pasapPTg+qGZ 0D8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780985010; x=1781589810; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GJB5jLKtnzx0Uw3mhH2PesM74Ru6QsJEyPDvmei98OA=; b=WdyojdhPVv3fb3z/1p7omGKw+eV7RyEa+E5oMmjJjhhRZFT7shb7LXMIyMGylVQBx/ 6XwKW2Mea6FWmt/PMbl6bfH/eYMa3CdQBdcGyvl+3OvxfBOQYkumeh/5w4YUYSyXqcBJ 1bRbjiNBkaIjMjuHJONlenehyv8YEM7oXRuQ6LWTqoqNZ2yx+t6VhkSnJDL8gRWIEmmg jRWXL/usDfAUUeXdsD/k9/ThB2wJO7O0UN1AWbYJKiKnro/TDIR0BisMOsh7cEeP0iJ/ wRFeEFzw6ZfqKm7K0vsaur7tCo9vvqnc3IP0XfYzxc0KWirCEBivbyqv7d92xyYsxAmC +vpw== X-Forwarded-Encrypted: i=1; AFNElJ/EUQMNzXPwyDzszeeqCMgQcS6zEQg0mjmfxPDNBRmgL/uO+hI197Sfn/SQmBZ8QFD0ICcAGJZvVvq6EbkZ@postgresql.org X-Gm-Message-State: AOJu0YySMgDramvld+zP4yd894jMQZS7ghjVwqT9XMvsfi3JaWdtFTQi QbGZrBamOd/gQZ0BAtpukLt2H4SKX2zGzT+tiZcVYpEtWehIHnJFqBmb X-Gm-Gg: Acq92OHJrqRdqQINsm6Nx/TcRUIIPIYo9REZ0MVPW7wrMze8sCeDv/uLKXW7Uozx6ju /LrcQRogp7iljf88O5OEqjRfNOLhl4S1fAqsBOBJ++96yyu5cezf51QsAvuGOZayQvdyQTWiogh 09q1Viud/XdE7Rdd5uEH1mVlP8qPOmWXI+EiJG5Pnp5GToANfjtK2BQsob5K6U/s7w/uaeN349j cHr+b6MiFo2hWSALVnYevJhLO9fHYSljVmnCwRpNZAeLDxqW8HnqrdV51Le8NU0DP+3TcxYIX2U UV7zmNfXZv2pPXqLsmii7OPQ2t+H28syiFrfjqQx80lueh1pIfyv8P/9tnSrNcmIUqo84z2/Q1l 8t7QP3baXjhmahNAV3q+ZUxEYmqcPjdt7kXtSjSQt/H9hw2HzIJLAC2DIAfhwXCCeWniAVqw7ea 76NdNEMndwsYj0ChWIUIB1F00DvTlXw54A5dd4rP0nAkB9XwIu7RY1fXx271DVsitZvs/dECc8d PLkzbJ4DHqPvt49kaeGMA== X-Received: by 2002:adf:e006:0:20b0:441:1e8e:d8fd with SMTP id ffacd0b85a97d-46030658bc5mr20913701f8f.29.1780985010437; Mon, 08 Jun 2026 23:03:30 -0700 (PDT) Received: from bdtpg (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f368e9fsm57381070f8f.37.2026.06.08.23.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 23:03:29 -0700 (PDT) Date: Tue, 9 Jun 2026 06:03:28 +0000 From: Bertrand Drouvot To: "Hayato Kuroda (Fujitsu)" Cc: Alexander Lakhin , "xunengzhou@gmail.com" , pgsql-hackers Subject: Re: t/035_standby_logical_decoding.pl might fail on attempt to read wrong timeline Message-ID: References: <7daef094-abf3-4672-bc23-3df4763b16a3@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="KccnfG1O+OuiQe+b" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --KccnfG1O+OuiQe+b Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Mon, Jun 08, 2026 at 08:47:48AM +0000, Bertrand Drouvot wrote: > Attached: > > 0001: To fix this race > > Fix by checking GetWALInsertionTimeLineIfSet() when RecoveryInProgress() > returns true. If InsertTimeLineID is already set (non-zero), the new timeline is > established and we use it directly, avoiding attempts to read from segments that > may have been removed. > > 0002: Adding a test in 035_standby_logical_decoding.pl > > It makes use of a new injection point "promotion-after-wal-segment-cleanup" in > StartupXLOG(), right after CleanupAfterArchiveRecovery() removes old timeline > WAL segments but before SharedRecoveryState is set to RECOVERY_STATE_DONE. > > The test fails without the fix in 0001 so it also somehow proves that the > diagnostic is right. > > 0003: Apply the same timeline fix to read_local_xlog_page_guts() > > Indeed, it could hit the same race as mentioned by Xuneng-San. > > 0004: Add a test for 0003 Re-attaching v1 patches here to have the cfbot focusing on those. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --KccnfG1O+OuiQe+b Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-Fix-race-condition-in-logical-decoding-timeline-s.patch"