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 1wkbGZ-000lf6-1w for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Jul 2026 05:37:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wkbGY-00G4US-1Y for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Jul 2026 05:37:42 +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 1wkbGY-00G4UK-0F for pgsql-hackers@lists.postgresql.org; Fri, 17 Jul 2026 05:37:42 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wkbGU-00000000chr-370I for pgsql-hackers@lists.postgresql.org; Fri, 17 Jul 2026 05:37:40 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-c88a4d79ba5so5010427a12.2 for ; Thu, 16 Jul 2026 22:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784266658; x=1784871458; darn=lists.postgresql.org; h=to:cc:date:message-id:subject:mime-version:content-type:from:from :to:cc:subject:date:message-id:reply-to:content-type; bh=vnfaCZgHIj9sht59Jgjx98ZR/zOjsOIyCC6r1o+PW1k=; b=KmFrX5boY8zsR5FEAdwJXadEgzAn8q4/NgiUno1vc6B3I4m2qGJEoI1F+8tZCOXzJX 025fCDxHMOZ3vvH1nXgLyfZWvdXdmUCkflPD1AvvvkQTxv7vQCcTPqXWyWrF5Y7sPTkl 0VINJxIt6j3ZBWMCwSPfALUgR5cMD2owFXPc0QyithlhPNi4xVEcCGZwDICVJDKf2qwu kDjWqcjntRe+K6zGRGvXhuCnljayvcWHOoC2aeooOK9sBBsFNgYUNTOYGM3PwBXBYpGH UH9Mo+iKwAlpdSYAYQFKm4238jzghQgZS5vAXku1V3BslGyLoul2P5lZiUcvQ9DmE45N Ejrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784266658; x=1784871458; h=to:cc: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=vnfaCZgHIj9sht59Jgjx98ZR/zOjsOIyCC6r1o+PW1k=; b=WEeVeBOAaEOPWWtxoZ6O7RYn/NUc8ZP1u53R1xmGY+Ng2OzW0btdL3f7o3RIMD+alT xQe1fOza9QD/SFgvwJiGKNRfQJ5hPKaHYGfTKKLqs14fJjMFU/SV13VN97xT9pqPiFzp DtzFUGAkWSyMEFDS/Aq1iCbbnx5WiMawFNMKnumgOo9ikDcTcdsFUfVYl/gt6Vrf3CmN hZkYMKwTJsVAiOjlXcHCQf/z3xEB2qGwSMWkaipNOo7q8L1IwlYi+QTRSMkIoNmr5jc6 1oCO+3zCNM08jw1onz4CN92C9OAPW1dPEJJWeYHM4l10kaFI1FhxQGnz+AWoqe7FdGgK hf6A== X-Gm-Message-State: AOJu0YwCFmF1bRnw8rdI2CAJFvAxlTla51yYuw3SQS3fadTPOuttfthd BTKmK3VnnhP+iXMVc9gzvEWF33wi4MTfi4533ekrNiHM9YFtalWmVPAZLsAkiw== X-Gm-Gg: AfdE7cmTAkU2YZD7GCYMD0vkfpogvF0k4m/1LiWwqMfbaXGWlEJfH8xJM0OTC2wqeLG Z0aL30DBhWO5Vlj1JWLgXDKZx4bOOaFeh0wW+x6jNEvTTg82OSMaPYrnfH7r0XLPsc35UgfxuFP lKcZMOFe6wZ2OF7gvVjQKop83+s+sX8X4KuNwJM3AIsgov0QkMRi39RM++OaAXrPLV3HCG3VAaB 1RLMWo5DXkm6u3V4RO2FWTSEFFUs/Hv5sRkaCqbr+749Bm4jdHzOTmiS2t3fV+332wF/cj/LbmL +6d82gul1+1bnQt8eB0Ns6dKjX+nqO/6cyu4x6ci35WQmJOyW9dy30jTHitDl+HHGbtOBe3K2g9 hK45ErjGrtD47uajk612W8wCMjIAFBYElCqf7p3pLdfW4sv3RSV97c6N+2nySTpfV0CvvW0KcmT QFCg2RqAOV6gg= X-Received: by 2002:a05:6a21:4a97:b0:3b4:8f18:33a with SMTP id adf61e73a8af0-3c3ad5d7a8dmr1251863637.1.1784266658074; Thu, 16 Jul 2026 22:37:38 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.125]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13ce2cbb6e8sm1521043c88.9.2026.07.16.22.37.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2026 22:37:37 -0700 (PDT) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_05E377D2-E297-4775-8146-9493B808FB53" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: doc: clarify wal_sender_shutdown_timeout behavior for small values Message-Id: Date: Fri, 17 Jul 2026 13:37:02 +0800 Cc: Fujii Masao To: PostgreSQL-development X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_05E377D2-E297-4775-8146-9493B808FB53 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, While reading the doc for wal_sender_shutdown_timeout, I felt that it = does not explicitly describe the behavior of a value of 0. According to = the implementation, when wal_sender_shutdown_timeout is 0, the WAL = sender terminates without waiting for the receiver to catch up by = calling WalSndDoneImmediate(). When the value is very small, such as 1 = millisecond, the timeout expires shortly afterward if the receiver has = not already caught up, so from a user's perspective, the behavior may be = very similar to that of 0. As I understand it, wal_sender_shutdown_timeout is intended to prevent = shutdown from taking unexpectedly long. A value of 0 requests no = waiting, while a value that is too small may provide insufficient time = for the receiver to catch up. Such values should therefore be used with = caution, especially for physical replication. The attached patch clarifies that the timeout is enabled for nonnegative = values, documents the behavior of 0, and cautions users against setting = a value too small for the receiver to catch up. While touching this part of the doc, I also noticed that the preceding = paragraph was missing one level of indentation and that there was no = blank line between paragraphs. I was previously advised that paragraphs = should be separated by a blank line, so the patch fixes these formatting = issues as well. If accepted, this patch is intended for v19. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_05E377D2-E297-4775-8146-9493B808FB53 Content-Disposition: attachment; filename=v1-0001-doc-Clarify-wal_sender_shutdown_timeout-behavior-.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v1-0001-doc-Clarify-wal_sender_shutdown_timeout-behavior-.patch" Content-Transfer-Encoding: quoted-printable =46rom=20178311692a2cab384b80a920f0a8adf7f36078b8=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Fri,=2017=20Jul=202026=2013:24:08=20+0800=0ASubject:=20[PATCH=20= v1]=20doc:=20Clarify=20wal_sender_shutdown_timeout=20behavior=20for=0A=20= small=20values=0A=0ADocument=20that=20nonnegative=20values=20enable=20= the=20timeout=20and=20that=20zero=20causes=0Athe=20WAL=20sender=20to=20= terminate=20without=20waiting=20for=20the=20receiver=20to=20catch=20up.=0A= Also=20caution=20against=20values=20too=20small=20to=20allow=20catch-up,=20= especially=20for=0Aphysical=20replication.=0A=0AWhile=20here,=20fix=20= nearby=20indentation=20and=20add=20blank=20lines=20between=20paragraphs.=0A= =0AAuthor:=20Chao=20Li=20=0A---=0A=20= doc/src/sgml/config.sgml=20|=2029=20++++++++++++++++++-----------=0A=201=20= file=20changed,=2018=20insertions(+),=2011=20deletions(-)=0A=0Adiff=20= --git=20a/doc/src/sgml/config.sgml=20b/doc/src/sgml/config.sgml=0Aindex=20= aa7b1bd75d2..b7c462e0f26=20100644=0A---=20a/doc/src/sgml/config.sgml=0A= +++=20b/doc/src/sgml/config.sgml=0A@@=20-4990,21=20+4990,28=20@@=20= restore_command=20=3D=20'copy=20"C:\\server\\archivedir\\%f"=20"%p"'=20=20= #=20Windows=0A=20=20=20=20=20=20=20=20=20without=20units,=20it=20is=20= taken=20as=20milliseconds.=20=20A=20value=20of=0A=20=20=20=20=20=20=20=20= =20-1=20(the=20default)=20disables=20the=20timeout=20= mechanism.=0A=20=20=20=20=20=20=20=20=0A+=0A=20=20=20=20=20=20=20=20= =0A-=20=20=20=20=20=20=20When=20replication=20is=20in=20use,=20the=20= sending=20server=20normally=20waits=20until=0A-=20=20=20=20=20=20=20all=20= WAL=20data=20has=20been=20transferred=20to=20the=20receiver=20before=20= completing=0A-=20=20=20=20=20=20=20shutdown.=20=20This=20helps=20keep=20= sender=20and=20receiver=20in=20sync=20after=20shutdown,=0A-=20=20=20=20=20= =20=20which=20is=20especially=20important=20for=20physical=20replication=20= switchovers,=0A-=20=20=20=20=20=20=20but=20it=20can=20delay=20shutdown.=0A= +=20=20=20=20=20=20=20=20When=20replication=20is=20in=20use,=20the=20= sending=20server=20normally=20waits=20until=0A+=20=20=20=20=20=20=20=20= all=20WAL=20data=20has=20been=20transferred=20to=20the=20receiver=20= before=20completing=0A+=20=20=20=20=20=20=20=20shutdown.=20=20This=20= helps=20keep=20sender=20and=20receiver=20in=20sync=20after=20shutdown,=0A= +=20=20=20=20=20=20=20=20which=20is=20especially=20important=20for=20= physical=20replication=20switchovers,=0A+=20=20=20=20=20=20=20=20but=20= it=20can=20delay=20shutdown.=0A=20=20=20=20=20=20=20=20=0A+=0A=20=20= =20=20=20=20=20=20=0A-=20=20=20=20=20=20=20=20If=20this=20= parameter=20is=20set,=20the=20server=20stops=20waiting=20and=20completes=0A= -=20=20=20=20=20=20=20=20shutdown=20when=20the=20timeout=20expires.=20=20= This=20can=20shorten=20shutdown=20time,=0A-=20=20=20=20=20=20=20=20for=20= example,=20when=20replication=20is=20slow=20on=20high-latency=20networks=20= or=0A-=20=20=20=20=20=20=20=20when=20a=20logical=20replication=20apply=20= worker=20is=20blocked=20waiting=20for=20locks.=0A-=20=20=20=20=20=20=20=20= However,=20in=20this=20case=20the=20sender=20and=20receiver=20may=20be=20= out=20of=20sync=20after=0A-=20=20=20=20=20=20=20=20shutdown.=0A+=20=20=20= =20=20=20=20=20If=20this=20parameter=20is=20set=20to=20a=20nonnegative=20= value,=20the=20server=20stops=0A+=20=20=20=20=20=20=20=20waiting=20and=20= completes=20shutdown=20when=20the=20timeout=20expires.=20=20This=20can=0A= +=20=20=20=20=20=20=20=20shorten=20shutdown=20time,=20for=20example,=20= when=20replication=20is=20slow=20on=0A+=20=20=20=20=20=20=20=20= high-latency=20networks=20or=20when=20a=20logical=20replication=20apply=20= worker=20is=0A+=20=20=20=20=20=20=20=20blocked=20waiting=20for=20locks.=20= =20However,=20in=20this=20case=20the=20sender=20and=0A+=20=20=20=20=20=20= =20=20receiver=20may=20be=20out=20of=20sync=20after=20shutdown.=20=20In=20= particular,=20a=20value=20of=0A+=20=20=20=20=20=20=20=20= 0=20causes=20the=20WAL=20sender=20to=20terminate=20= without=20waiting=0A+=20=20=20=20=20=20=20=20for=20the=20receiver=20to=20= catch=20up.=20=20Therefore,=200=20or=20a=0A+=20=20=20=20= =20=20=20=20value=20too=20small=20to=20allow=20the=20receiver=20to=20= catch=20up=20should=20be=20used=20with=0A+=20=20=20=20=20=20=20=20= caution,=20especially=20for=20physical=20replication.=0A=20=20=20=20=20=20= =20=20=0A+=0A=20=20=20=20=20=20=20=20=0A=20=20=20=20=20=20=20= =20=20This=20parameter=20can=20be=20set=20in=20= primary_conninfo=20and=0A=20=20=20=20=20=20=20=20=20= in=20the=20CONNECTION=20clause=20of=0A--=20=0A2.50.1=20= (Apple=20Git-155)=0A=0A= --Apple-Mail=_05E377D2-E297-4775-8146-9493B808FB53--