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 1vvmPa-001kC2-34 for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Feb 2026 01:12:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vvmPZ-00GzxK-31 for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Feb 2026 01:12:57 +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 1vvmPZ-00Gzx3-24 for pgsql-hackers@lists.postgresql.org; Fri, 27 Feb 2026 01:12:57 +0000 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vvmPW-00000001Odu-3FBy for pgsql-hackers@postgresql.org; Fri, 27 Feb 2026 01:12:56 +0000 Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-679f23befd6so659180eaf.1 for ; Thu, 26 Feb 2026 17:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772154775; cv=none; d=google.com; s=arc-20240605; b=J/67D3j3U3RQLeayzPBBDViX/aFj7MDKNJSU9oGi6OvX13Lk5CCEDnnDhSgQORoW2O tQe1oupWmaGvEGPWTTszBwD/15mIeNmj49b5pvUrQviHwdqo4Tn8ZNyFqhwNcF/KFB7s 9iresXJypCyWXQ8Y+PzjDAHrhZmfnr1v/eQmPH+VgswLxJ8Jh/OhEdJ8ld4puTY2Eonj SWAYdCiC/4hvdJV+knWB14831NQOq2Ukm06ozal89KRq2QKSIfKXO70MvDGMVQstSbdz y76zvIUT5iqDjhH9sjtbE94lf5wcfeVYjPpp3FxNZmz9UrvXI3vhq+PYUHiQyu2BNJY+ 9+bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ZW6VubYYFT1z+m4YyTA+SYkE7jlrLlsjrQs3RhPFlpY=; fh=1EQO5bNNez8k474Z+/UGdWj+l/NM7T6y+o/+FUOG6RY=; b=fDVw6JzgPtKi0dno1h9ae8pvgLABNdrsNi4KKXE+Y+JCo/i62rHUfkXmGSDnoIj3jw f0P/eJN6SQIIoh2n0DJNIw/QahibudMgXyY/jAvAIqpiuT9ohr6UYQGfg199XcAstglE bgCy+j8hd8BDFBpToZN3evnC74WljRFFOnRSDXYCoUqpYLspfHspGn402HXvPS5/iQlg VzWKBfwP8sJ+bskqhs2LpioW7I3RvQKG4HQXwmtpGOgBcHglI4przoyBWD7/uEI9bRMc 7F8SUK00JKADurwcx84PPVsXZoUdt1VflntCj61hsImvotyAoVKhJuwBa/IYqc1kfhI0 WSRw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772154775; x=1772759575; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ZW6VubYYFT1z+m4YyTA+SYkE7jlrLlsjrQs3RhPFlpY=; b=loDhfF0pvK/nd2YS7OurO/wVtIpEU/QvlMBVskum4pvx6leiV8nYB7PJy+Y5xzJg+S ytf3GhYh92PllcqwGmV8cuaB1o75ydVbT3t/HCnIrRvQsLWy14dGxsBB6pa8VgkR7qOq LV1491e8l/6vjKE+vRMRs/IkuUUSSr6qHE8Daufw60o02dWByESbUxuEIWxut18MEFzO ZMtmXBug2utO6E0NdVnHnpXIWA1oU4CbcDDcmXs0KmsoIa82JHOi16GRjaAo7LYeVNkY 4bUYJmWwylzdcbng8ykSBtV6WxSKxNufh+v+JxvFDcCw3eAT0yuniQuN8+SHRCab6HsJ GfMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772154775; x=1772759575; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZW6VubYYFT1z+m4YyTA+SYkE7jlrLlsjrQs3RhPFlpY=; b=qNmxeZhezhoyDmVgZKaaGDRiHin9bam+V01DT1mUfFyhSz+SAg2sll10tA84GuknNl WJ87ziFicy6Dawpz/G9tb6V+cA0PTECo1CrVr8OnrEccC69a2cNSIVQBFoUZo7/eBtmV Hd1g84qsRhifHYCc6nAL6t0RN/8jbBdwyo3eB/hIQsK6HvS5tRW08+Su2RgsXoL5MCcE iqTy9fK8wfwQAS40IWp4sH0mEITjleJWxJvzaIVMR8VZEPyCcrmjJqubSBjJsnoj1xvB /YoZlgyYFbLAo/R9eX/6Aoc/bcU+SPOrJ+gv9e257jZNexUlE234zAva+oiyseUaS1Co kq2A== X-Gm-Message-State: AOJu0YwQ6vb3jwqQselok4PTPoA4AKpYrEfjqveYZJib8Bm4FZsKWT0N i3uah9zubJc4GS5Yf/4PatKFCQLXiMRpS+hXNroKdhZImrENkn4I53OhXW9q+3J5V1MPXnG9ZUF zlq6mum+veDhht94d+cov5ULeC9QUt/JSNmTA2iU= X-Gm-Gg: ATEYQzxYmBXXAaX0pGCd0J7eRt+pRu5UiWeiOjEgq8JV2q/4Kn3xz6OanxolZg3FEtc +ZwkVFPKuX0PNL70aKEtbIsQTbBsX4PNMErz3vLSvZdtwayu2meNYs3b4UfaXjeJhfkWKhc+4Th 2/alDwmkvw0GfwyLOk0O1fkboTApYbaoF1KnQTh/iuZ+hfwJxvTni5IfNZkkJE3UjS5quqbfb2+ ebtX1vfD+xI6eVuc0AVd3BscXf5sY1dN8Wi99bSj7sr6CPvGrOGG5x3zkJ+P2bu7G9qRRtfvRED LAguvOZM7YpTilsFLT1Q5TpW/LHKEZfZ6qCiMMHsuQ== X-Received: by 2002:a05:6820:618:b0:65f:6628:94fc with SMTP id 006d021491bc7-679faf4ce02mr827181eaf.63.1772154775235; Thu, 26 Feb 2026 17:12:55 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Fujii Masao Date: Fri, 27 Feb 2026 10:12:43 +0900 X-Gm-Features: AaiRm52YNNLgxJ6wazI2WzuPHUFnpu53345Mjt0NNhqAlJXtdWQIowh88Oj17hA Message-ID: Subject: Re: Improve checks for GUC recovery_target_xid To: David Steele Cc: Pg Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Feb 20, 2026 at 2:42=E2=80=AFPM David Steele = wrote: > > Hackers, > > Currently check_recovery_target_xid() converts invalid values to 0. So, > for example, the following configuration added to postgresql.conf > followed by a startup: > > recovery_target_xid =3D 'bogus' > recovery_target_xid =3D '1.1' > recovery_target_xid =3D '0' > > ... does not generate an error but recovery does not complete. There are > many values that can prevent recovery from completing but we should at > least catch obvious misconfiguration by the user. +1 > The origin of the problem is that we do not perform a range check in the > GUC value passed-in for recovery_target_xid. This commit improves the > situation by using adding end checking to strtou64() and by providing > stricter range checks. Some test cases are added for the cases of an > incorrect or a lower-bound timeline value, checking the sanity of the > reports based on the contents of the server logs. > > Also add a comment that truncation of the input value is expected since > users will generally be using the output from pg_current_xact_id() (or > similar) to set recovery_target_xid (just as our tests do). > > This patch was promised in [1] -- here at last! Thanks for the patch! + GUC_check_errdetail("\"%s\" without epoch must greater than or equal to %= u.", "must greater" shiould be "must be greater"? "without epoch" seems not necessary to me. + /* + * This cast will remove the epoch, if any + */ + xid =3D (TransactionId) strtou64(*newval, &endp, 0); Would it be better to use strtouint32_strict() instead of strtou64()? That would allow us to detect invalid XID values larger than 2^32 and report an error, similar to what pg_resetwal -x does. Regards, --=20 Fujii Masao