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 1v790R-00FcVr-2A for pgsql-general@arkaria.postgresql.org; Fri, 10 Oct 2025 09:01:43 +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 1v790O-00B9r7-Pk for pgsql-general@arkaria.postgresql.org; Fri, 10 Oct 2025 09:01:41 +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.94.2) (envelope-from ) id 1v790O-00B9qp-Dr for pgsql-general@lists.postgresql.org; Fri, 10 Oct 2025 09:01:41 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v790N-0010ly-1k for pgsql-general@lists.postgresql.org; Fri, 10 Oct 2025 09:01:40 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-46e6674caa5so9527795e9.0 for ; Fri, 10 Oct 2025 02:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1760086897; x=1760691697; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=p9caU7pMMABvxjkRDZUyb00c6lrrMsdBSKDi0K06jx4=; b=jYRVnbwVYdzkP01xwqHudl7Elq1H4RY5T0m8PwBM8IFKlNzImfc37qSigQcXdvACaT kF//Ll6ZudGOqzd0RaDxtmnc/p4pdR4m1POp+03G6VmjaC4LkbIjSxJ8QBKqyGpRe3Er lBnGzw6LpwOL0m51eQrWnUhdJqT1wh7sDBEm5z9wabWR68pk/PctbIMRDgJ/wk6i2rJo /rwS5Q0N0FKsusvR0mGH44BkasdEDW1HvQ9RFSZwVJ/NWDphxz4iuqHvgY9jahigxfH1 LkdKyxZtHC/mxjhorogNAfZc+/+J+nULbgJmVeZlOwBqIab6L3B2UIC1v9LqwuHS/N/3 OBAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760086897; x=1760691697; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=p9caU7pMMABvxjkRDZUyb00c6lrrMsdBSKDi0K06jx4=; b=rLpobIWwAsgCQRm+bSMevDMOSCIvy1rKfT1FIrgdS1UT8hWpTWET3ZmzjpaBoavoe4 uFXRrxKDAmu1z+dN6S1ARYl15NrLdEvr+mQiPzpqATGsoyVFjSYcsCBjjjJhBJuJeiI4 Li8Ph7Fu3t3RAvPSP3KVMcLpY8oCpgi7dYQDTmMRPrK/2T/VROPFzW3GNx8UWyWS3L+t Cla2eFZFPA+ZUnEC9dDbRLn3yPBgCs38WvBKmuuxxbC5hPMJTnvTxYikI/nzqaspsJhX C/BjSBOg7/pvkYWWUogcQaiIVqbTG4u5xCKvUpHEkKU9EHzpf4XmtQrVmSt6opG25R4j Dlxg== X-Forwarded-Encrypted: i=1; AJvYcCUFaatfgCM2pwCyp9ZP/sYM72dZnOX/6apW2lBV6uHY965G2htTUtwfd4Uuoun3kknuBdzJNard2vou629y@lists.postgresql.org X-Gm-Message-State: AOJu0YzYUH8zLQS94ed8PW+NmAeeHpA/DDw1dAN+sJmIwhyQETiS2txA mmdszG1zF8RiYxkwbs7zYNdBDS6DIBUSEFCv0WCZR+j6p6z6bvTxRZB8Aczv1jimnTIUiH6GN+F lizlH X-Gm-Gg: ASbGncvFxr2WBqY+H69U5ralfBAfACCdvloAA/TEA01Cca3xYLM7gNapxPXIqb7Z0/+ RY5HYjLlHY79aiR9MzBRfmHplGJ1vEJat0ak/g8rxz2S/O1k9B4aKrAYvfS67rQ4RXkdlo9bA/F jpWo9uXLp+vBbQctGxdpApIoyav+ZZbsOE0/KRR75YAQd+bafnef3DPVFbmjpMf1Mx4TA6N7YaS KV90eH5qMA4EOY9+93cDnJtguBJtLmLuD5776R43XniV70eBlp5Kg2lnslMSsH8Pk9u7SlFVPK2 8i5bbBtiwEHqPSxqvq2RkXBgpCGdSo1Zi+HhRiT3CH16yI9EUJrgPuJzT/voqE8rlGMU05PeQGm N0u/FH6yhuV3kNsCo++liMcxx4LYDZBy+47BJj3s6SA== X-Google-Smtp-Source: AGHT+IFnbTX0J4BQMHVEkbm/LseA90Av2ZomdGhwY4DE/TGUDYZWtiQHHYRry1SLOCHLPz5EUAMUKg== X-Received: by 2002:a05:600c:4713:b0:46e:5302:7751 with SMTP id 5b1f17b1804b1-46fa9ebe22emr71033415e9.9.1760086897162; Fri, 10 Oct 2025 02:01:37 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([213.208.157.35]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46fab3cc939sm56591725e9.1.2025.10.10.02.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Oct 2025 02:01:36 -0700 (PDT) Message-ID: <8b4a6869b1fca2d0c39777b76439e6f153ba8c76.camel@cybertec.at> Subject: Re: Upgrade & Rollback plan: My customer requests rollback via old-version standby (13 =?UTF-8?Q?=E2=86=94?= 17) =?UTF-8?Q?=E2=80=94?= need community advice From: Laurenz Albe To: "Vu Le (JData - HN)" , pgsql-general@lists.postgresql.org Date: Fri, 10 Oct 2025 11:01:31 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2025-10-10 at 15:26 +0700, Vu Le (JData - HN) wrote: > I'm currently planning a major version upgrade from PostgreSQL 13.x to > 17.x in a production environment. >=20 > My customer has requested the following rollback approach, and I=E2=80=99= d > like to confirm if it=E2=80=99s technically feasible or advisable before > proceeding. >=20 > Scenario: > 1. They have a **Primary=E2=80=93Standby setup** (streaming replication). > 2. Their idea is to **upgrade only the Primary** (to v17) first, while > keeping the **Standby** on v13 (the old version). > - The upgraded Primary will run read/write traffic for about a week > to validate stability. > - If any serious issue occurs, the plan is to **switch over** > (promote the v13 Standby), adjust IPs, and resume operations there =E2=80= =94 > minimizing downtime. > 3. They also asked whether it=E2=80=99s possible for **data generated on = the > v17 Primary** to still be **replicated back to the v13 Standby**, so > that rollback would be fast and without data loss. >=20 > Constraints: > - They **cannot use a Blue/Green or clone-based approach**, because of > **limited storage resources**. > - They also doesn=E2=80=99t want the old data directory to become outdate= d > (they expects it could stay in sync with the upgraded node). > - They only have **UAT and Production environments** (no dedicated Stagin= g). >=20 > Questions: > 1. Is there **any supported or practical method** to replicate data > *backward* (from PostgreSQL 17 to 13) =E2=80=94 even temporarily, for rol= lback > purposes? > 2. If not, what are the **recommended real-world rollback strategies** > for a low-downtime upgrade under these constraints? > 3. Are there open-source tools or logical replication setups (e.g., > pglogical, Bucardo, etc.) that could safely achieve something similar? The only way to achieve something like that is to use logical replication. You'd have to switch from streaming replication to logical replication: - create a publication for all tables on the primary - turn off the application - promote the standby server - create a subscription on the former standby with "copy_data =3D off" Then you can upgrade the former primary with pg_upgrade --link and restart the application. After that, logical replication will keep the v13 machine updated. Note that you cannot run any DDL statements on the database after that, else replication will break. You cannot upgrade the standby server, you'll have to discard the data directory and start with a new pg_basebackup. This is all pretty complicated and should be tested well. But then, it might be a better idea to invest the testing effort into testing the application on PostgreSQL v17, so that you are confident that you won't need to downgrade. That would allow you to use a simpler and less risky form of upgrade. Yours, Laurenz Albe