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.98.2) (envelope-from ) id 1xQxZh-00000000YRU-0eA3 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Nov 2026 01:56:33 +0000 Received: from localhost ([127.0.0.1]:53652 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xQxZf-000000084HI-3KC2 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Nov 2026 01:56:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:34534) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xQxZf-000000084Gl-2Atm for pgsql-hackers@lists.postgresql.org; Wed, 11 Nov 2026 01:56:31 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xQxZd-00000000NUX-0Otr for pgsql-hackers@postgresql.org; Wed, 11 Nov 2026 01:56:31 +0000 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-3ad41b47541so1676359a91.1 for ; Tue, 10 Nov 2026 17:56:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794362187; x=1794966987; darn=postgresql.org; h=to:date:message-id:subject:mime-version:content-type:from:from:to :cc:subject:date:message-id:reply-to:content-type; bh=IXKPbauPlEuFQMfeUH120DsL3ZkrzKID35GNEcTukYk=; b=oKJv3qjO4IX4hR0kOfNH3uQ2jTz7+g+jDFpvgxx4T9lU6sWFJ/XuIAd3nhQLYkRt+N JUUnBgNsduAipkegM2VTVhPjOS3WgBBiPc/WheSeBiYeXsvT5FkIG0SfJ/gWL5cg1zhy l958RIvGQIhLg2L0DxdQKcOmfVRbclWiotn8+OZKlnyb7IghHz1nFBQ6cwBy6TwomnXj Kn6WO6fyyW6+k+P8erL4wmhd1I1X6Y0SLGx6UzQErcQ57U7jYXouE53arJdZqxHiuzbv r6Bc2CtpvD66mKcmlyQNhmN30tMT3JPLALeCVyG+OyaARsTfr3w4NJmknOY7XHuqlYkS cHFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794362187; x=1794966987; h=to:date:message-id:subject:mime-version:content-type:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=IXKPbauPlEuFQMfeUH120DsL3ZkrzKID35GNEcTukYk=; b=gZle9FjVwIAyLgQvvJI5w9RcDUmIcWz1XmPjdL8fZnN4vmQxnB+QiFazJ7Ye7iUbmX CjKvbuxRDvuW/i9YhK5ZiSrXj0mqKpo5LAXn22j7ZoIwkyGdqHz2GEtvoQckgXlILccN g6lXPDV7a8ph4x2H4YAHayNYX9AHI2wdXln/VgszLA4clSQR6EsIw7elLw85lNe5sCQe ySEpRq7Dzys+MZjX5CEZaQWAJVqz4eUiSupPD760fuOCcmw5nPDohZZXl5cFZx9hGstq CHlrjRyFnAV687mFThhaGcFa6TNiNykOFJjqua8PskFBzlrO7QvTciVIdVT4fsEbO/Rs 4MHQ== X-Gm-Message-State: APuU4Z8oC13S4DOw757aqVy4O8vvzHC6Ni9vpeuLtoHerFzEn2InOFnZ pZ0HXxAudWAl17PsGVGqu3Gmz2fMbppsjdAj8BjUnlbq20z1S5PRhufmZX3HyrQV X-Gm-Gg: AYBFou1NlFm2ALPs+6AjDtidfW2nzoupBU4E6OwWwlPsiDFHmUDTK5psMPUjglIMlfE LhdM0TlsowhHO3Lh1vivi9MQP9goDnnEmimaWAvzme7OjQieqTKpzCfufULN+lODEGqlo0S4bJ+ 7Fa7wwG/mjWNW0B1oAfwTz4Tngs74d8rMmJWMQl7KKw7QxJgc34a1j6sCryOFFR9QVyLaBTVHhN snmFURVS31PRGnyFHyxI+JGOCQae2D6Nl7aasVC0uDAHsWee1/i2XXgC5B2Rr9ePub3oSGEh/NT Xt0kf2VeITEoNSyEBKaW8benzCPjhDay46KAl09Jm2qv+ZBb2xIe9Ed68lXgC0+MPtSPDj51oJ4 1SKdUXhGjNdVfqFUFFF8nshdffJt+/IdhdDFaGNz4rWfxl6gP5/ejWw/IPVCtoUEZnwkwYYOfv/ 5h81NxsSXhmcbbpSMkDCcR3N7PLVWLb6OKnbW/jsS0LBw/II79aEZoWpsGXykeha4ky/k/nBcUo XM50DXi3/0QYMj0gjAo4aohK8D+Aqx5ABLggU7xsDJpdcN9Hu9EU+6XDeabLZyg+B3a1KU2zYaA 5I8UVTOvWZFFiTSY7UTnOst5dPPHtJ1CmsXA+IQ= X-Received: by 2002:a17:90b:5410:b0:3ab:2737:3395 with SMTP id 98e67ed59e1d1-3b182ee3ca5mr870177a91.42.1794362186898; Tue, 10 Nov 2026 17:56:26 -0800 (PST) Received: from smtpclient.apple ([185.135.79.161]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b17db5cc73sm1924518a91.10.2026.11.10.17.56.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2026 17:56:26 -0800 (PST) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_F50CEEC1-D1D4-4C69-BCCC-AD2D6B0DF713" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: pg_basebackup: check timeline history file write failures in ReceiveXlogStream() Message-Id: <530B55ED-C7F7-441C-BBC0-6F3F9901E414@gmail.com> Date: Wed, 11 Nov 2026 09:55:52 +0800 To: PostgreSQL-development X-Mailer: Apple Mail (2.3864.700.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_F50CEEC1-D1D4-4C69-BCCC-AD2D6B0DF713 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, While reviewing patch [1], I spotted that ReceiveXlogStream() calls = writeTimeLineHistoryFile() without checking its result. = writeTimeLineHistoryFile() can fail for several reasons and returns = false to indicate a failure. This could cause pg_basebackup and = pg_receivewal to continue streaming even if the timeline history file = was not successfully written. This seems a very old problem, dating back to 9.3. Attached is a trivial patch that checks the return value of = writeTimeLineHistoryFile() and returns false on failure. [1] https://postgr.es/m/f1743511-5fab-482e-94ec-1198ce18723e@riseup.net Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_F50CEEC1-D1D4-4C69-BCCC-AD2D6B0DF713 Content-Disposition: attachment; filename=v1-0001-Check-timeline-history-file-write-failures-in-Rec.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v1-0001-Check-timeline-history-file-write-failures-in-Rec.patch" Content-Transfer-Encoding: quoted-printable =46rom=20b0b9d029176f786aa020badef1fc1e056248d572=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Wed,=2011=20Nov=202026=2009:35:46=20+0800=0ASubject:=20[PATCH=20= v1]=20Check=20timeline=20history=20file=20write=20failures=20in=0A=20= ReceiveXlogStream()=0A=0AwriteTimeLineHistoryFile()=20logs=20an=20error=20= and=20returns=20false=20on=20failure,=0Abut=20its=20caller=20ignored=20= the=20return=20value=20and=20continued=20streaming.=20This=0Acould=20let=20= pg_receivewal=20or=20pg_basebackup=20report=20success=20despite=20a=0A= failure=20to=20save=20the=20timeline=20history=20file.=0A=0ACheck=20the=20= return=20value=20and=20stop=20streaming=20on=20failure,=20clearing=20the=0A= query=20result=20before=20returning.=0A=0AAuthor:=20Chao=20Li=20= =0A---=0A=20src/bin/pg_basebackup/receivelog.c=20|=2014=20= +++++++++++---=0A=201=20file=20changed,=2011=20insertions(+),=203=20= deletions(-)=0A=0Adiff=20--git=20a/src/bin/pg_basebackup/receivelog.c=20= b/src/bin/pg_basebackup/receivelog.c=0Aindex=2077a2b4458b3..2c51c3a474e=20= 100644=0A---=20a/src/bin/pg_basebackup/receivelog.c=0A+++=20= b/src/bin/pg_basebackup/receivelog.c=0A@@=20-557,9=20+557,17=20@@=20= ReceiveXlogStream(PGconn=20*conn,=20StreamCtl=20*stream)=0A=20=09=09=09}=0A= =20=0A=20=09=09=09/*=20Write=20the=20history=20file=20to=20disk=20*/=0A-=09= =09=09writeTimeLineHistoryFile(stream,=0A-=09=09=09=09=09=09=09=09=09=20= PQgetvalue(res,=200,=200),=0A-=09=09=09=09=09=09=09=09=09=20= PQgetvalue(res,=200,=201));=0A+=09=09=09if=20= (!writeTimeLineHistoryFile(stream,=0A+=09=09=09=09=09=09=09=09=09=09=20=20= PQgetvalue(res,=200,=200),=0A+=09=09=09=09=09=09=09=09=09=09=20=20= PQgetvalue(res,=200,=201)))=0A+=09=09=09{=0A+=09=09=09=09/*=0A+=09=09=09=09= =20*=20Error=20message=20has=20been=20written=20by=0A+=09=09=09=09=20*=20= writeTimeLineHistoryFile()=0A+=09=09=09=09=20*/=0A+=09=09=09=09= PQclear(res);=0A+=09=09=09=09return=20false;=0A+=09=09=09}=0A=20=0A=20=09= =09=09PQclear(res);=0A=20=09=09}=0A--=20=0A2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_F50CEEC1-D1D4-4C69-BCCC-AD2D6B0DF713--