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 1uvhwS-0007qS-K5 for pgsql-general@arkaria.postgresql.org; Mon, 08 Sep 2025 19:54:21 +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 1uvhwQ-007NoA-RZ for pgsql-general@arkaria.postgresql.org; Mon, 08 Sep 2025 19:54:19 +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 1uvhwQ-007No0-G4 for pgsql-general@lists.postgresql.org; Mon, 08 Sep 2025 19:54:18 +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.96) (envelope-from ) id 1uvhwP-001DNt-15 for pgsql-general@lists.postgresql.org; Mon, 08 Sep 2025 19:54:18 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3e07ffffb87so2255691f8f.2 for ; Mon, 08 Sep 2025 12:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1757361256; x=1757966056; 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=AixhRmPYIJ34aGO37+vHUMWkMj55HBuHwoxRioWWAgY=; b=FbXNvz/5E3p4lKWMMY9hoVHpVigS7Hy3pCekMLlnxykjBqzxLAo0Q8jm3KbS4LMCXc o5ZIjBpcZF8K99fd/ZFQHSWTRhMDfeNJIB2RJmgivSYXDUUQ6ak3TlhR3Cmb+AzG8sjR EwmjLsKLGWUij9A7qfQF/Y3Hl4FKKpQh4bA2eFZ1wivTFsyr0R0SWmwJ/xgewCO95gsc qPzfwyvQvXup/i9obhDhy1vsvSBqa+SW6/Y4A/guwqUKNC40LANCbj173xW85AbzcQ/y 74rBf+2cQgGN+ASr8NoZO1vXNWiMuFhauxIGRVg2OM1b1i9Xdn2ydNfAR5d9ZrTX31kL QI/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757361256; x=1757966056; 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=AixhRmPYIJ34aGO37+vHUMWkMj55HBuHwoxRioWWAgY=; b=RvxICTophWta0UbaBJy3aWEUgFtXn08RN2503JmoIaLtQRwdX148LDd1kGhV7Udc+7 6IGmXyH1oFP69eBDXLBsaOOqwjZoeB1gIxdtsvyN93ory00+Pn2qe1FIEKxM8NwH0HaH M5C6IKePOEZHE+v+uf9tockec8g4JvszZpOcWNUz3dVeyjSfB0tQYpqcHT1dtPmCq20t Aum4qePaAfKlOggnwOxqR0e/It3apV4uWI9zKyGMyMGgQ8/zQLEEsbnrar43kXV6sXMc Ng4k17E5BMAfYbV6B10m7EA3+U8TgWbEThAzDsRiZ9I9t8NAVia3YNEeNbtL+Ejd12fn 3ICA== X-Forwarded-Encrypted: i=1; AJvYcCXKoCdGpcNpCRUNosPG53P4dfw+f7idSqeXfHodm+8T1A/ly9kF4XOMKpz7z56zqn3FpZkQ4Kp7ODF6AWFB@lists.postgresql.org X-Gm-Message-State: AOJu0YwGvA6ck67WWQWdV0uo66chR1zCHye4v6Bx4JJ92oiS/AbGQqYq iY5ytQYIfX488vB7S9eikLZNJEI36cYXgiqRn708NmQhKUPQsGddrt0FzGqCjirP/p4= X-Gm-Gg: ASbGncvigJ9xAM2z7QTmsvOTAMwjTATA6vSo830mdpZUB982PwvFL/Vx4U8czIXFLVm hBaEwQW04Powf2abrwzx3cQvkHxpimYewZ+EYJ/yGg34UL1JineTr8nGMyj6Y7sBgGYBSpT/aTP nDIKVAg5YwB7l5EGrJLC5id2Qj4YXNc25AdbOrSOotPLgh62D5LBJGiAt6IG4ZQEDluJQnegSHi DDj7CP8izNrMudqeH66haP26r8S7DDqSHkwnuPUZOVz8zZ/Knt6kAgB9d5STlDmxyqGPD96sadX YOq9+TGYablyzOwEQOeE63OJIRdXLm4OgB8B3BTSS9/cO+sEt3c1jOdHE3Cnm+Gm96JiKPDR6Lg ky5qt5mqMw+mjwiK6TiBe63C8YQv+BNoBHqi1ib4mcqvtIZRJ3LM24qPQlulfIog= X-Google-Smtp-Source: AGHT+IG8++Ntt4GTeVa+6IlKIVbRbfSE0KiWLLg8YIngiHe40S3HKyGtq+wORl2cGPAOh32pNSZ9rg== X-Received: by 2002:a05:6000:2f87:b0:3d9:2fa8:1009 with SMTP id ffacd0b85a97d-3e64c3acf34mr7075951f8f.45.1757361255629; Mon, 08 Sep 2025 12:54:15 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:255:30a:2403:9037:2d08:c2c]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e21e4c0e6fsm16188632f8f.17.2025.09.08.12.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 12:54:15 -0700 (PDT) Message-ID: Subject: Re: Fast switchover From: Laurenz Albe To: legrand legrand , "pgsql-general@lists.postgresql.org" Date: Mon, 08 Sep 2025 21:54:14 +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 Mon, 2025-09-08 at 15:03 +0000, legrand legrand wrote: > For some projects we need a fast manual=C2=A0switchover to address Near Z= ero downtime maintenance > (not speaking here about automated failover like those provided by HA too= ls, but just planned, controlled operations) >=20 > Database Physical replication switchover itself: > - initial replication (before switchover) should be synchronous or replic= ation LAG should be controlled to prevent data loss. > - Switchover duration seems not "compressible" under a few seconds (becau= se of primary shutdown, promotion, new standby catch up, ...) > - Application retry strategy (after disconnection) should be tuned using = proper retry delay. Pooler or specific driver may help. There is no need for synchronous replication; you cannot lose data with a s= witchover, if you do it right: - run a CHACKPOINT on the primary (to speed up the shutdown) - when the checkpoint is done, perform a clean shutdown - when the primary is down, promote the standby The primary will transmit *all* data to the standby before it shuts down. > May logical replication ( bi-directional, with one instance RW and the ot= her RO) be a better solution ? I'd say no. > what could we expect (in term of downtime in both worlds) ? Usually seconds, so plan for ten minutes. Yours, Laurenz Albe