Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nSJlU-0004po-0B for pgsql-general@arkaria.postgresql.org; Thu, 10 Mar 2022 14:27:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nSJlR-0001LE-RB for pgsql-general@arkaria.postgresql.org; Thu, 10 Mar 2022 14:27:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nSJlR-0001L1-Ev for pgsql-general@lists.postgresql.org; Thu, 10 Mar 2022 14:27:37 +0000 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nSJlP-00010p-6F for pgsql-general@lists.postgresql.org; Thu, 10 Mar 2022 14:27:36 +0000 Received: by mail-vs1-xe30.google.com with SMTP id u124so6084190vsb.10 for ; Thu, 10 Mar 2022 06:27:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ozcK+ukp84zoyWEK88hfSQpxrPwHu6rtG9E96QODAa4=; b=a0lxr+wSlRENEOWgEiqQ/nZtmrbSF6KbgVwSAdl29CP+72tbrcz864pUO1su34Qjzn nyoVamL+Q7da0l4+N7H1NgulwbosmOg1qpI3fry4ru53O4J6mLX2kLKfIrsk7OguJylC gaX0UosR/H1Vy+tVdA62AVhcvq7SwsJL4Ub+BCDEndDsXWDFqQY3NoLzmv3cf/nXo2ne wgovEugCKFuO4tWBIixS4ibPQQDfOz651v6hpLcrlF7vqatlOOuUYsF0nzBvLdllCz3p RqQ2WPRmpxUXcy8yStf6sARod0cq9sULfDhIWxvFU+MiWMKpRdbkbA2y5Cv27HC7xQ+T 5Xvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ozcK+ukp84zoyWEK88hfSQpxrPwHu6rtG9E96QODAa4=; b=Nr0IEeekI1UtUHgAKFCP+iZQ8BlKtTivL2jdNYhyGobGc6r1glgkVOJFX6kLPupfcU HYdZdbqrJD8/14hv4/qcyhgBJ2WwAxkieUcPAhhGjvUWPyuLyrCtib+7qPyMGq6ZLo7o ZaDO0dCjnL3KWsG6Oz+Wsx5Ah6hGzQ376jhRWu19Q555/eK9QZne3S1BxcEtviGWRAC8 uTMyunq6Mv9AMdi1UOn3cpNYIcYlC4UjPZNT40AzDrWBMf1W91M80VAgxx0gZjYD7nrI xQKfM9jdyNYfNm17PgtqGobKbs5XCqP8s9Eb/Ln0lPiUYLggH82WlvBQrbubfH32dyHW o1ow== X-Gm-Message-State: AOAM532nLMdg3kWcIaPfjFdcn7iQCgVK8/HzX46CKzUUtRK1HACvGdHC xE1ScUThFB9Ou1rvKMUzjrRcSsJhJHbcH1fuhheBkqBFCSY= X-Google-Smtp-Source: ABdhPJyCiN33SnNl8eAJ9M6KsgZK5jOSHsyfqDk0Axzuyfutht6EwOzusQIPBXnDse+c4Zw06g5MxApjI9LghfLxhGE= X-Received: by 2002:a67:e403:0:b0:320:a585:59d9 with SMTP id d3-20020a67e403000000b00320a58559d9mr2459250vsf.68.1646922454188; Thu, 10 Mar 2022 06:27:34 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bharath Rupireddy Date: Thu, 10 Mar 2022 19:57:23 +0530 Message-ID: Subject: Re: primary_conninfo and restore_command ? To: Luca Ferrari Cc: pgsql-general Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 10, 2022 at 7:22 PM Luca Ferrari wrote: > > Hi all, > a friend of mine has shown to me a "strange" configuration of its > physical replication server (13): he has both primary_conninfo and > primary_slot_name, with replication slots active when queried on the > master. So far so good, but in the configuration he has also > restore_command to restore archived WALs from a centralized location. > Does this make sense? > Because if the replica cannot connect to the master, it will not start > at all (so I guess no restore_command will be executed). On the other > hand if the replica can connect to the primary the WALs will be > shipped by means of streaming. > Am I missing something? Yes, restore_command gets executed even in standby mode when walreceiver is unable to receive wal from primary i.e. primary stopped sending WAL, see some comments on it [1]. It looks like restore_command in standby mode isn't mandatory, but is advisable I guess. I hope that clarifies your question. [1] WaitForWALToBecomeAvailable: * * If standby mode is turned off while reading WAL from stream, we move * to XLOG_FROM_ARCHIVE and reset lastSourceFailed, to force fetching * the files (which would be required at end of recovery, e.g., timeline * history file) from archive or pg_wal. We don't need to kill WAL receiver * here because it's already stopped when standby mode is turned off at * the end of recovery. *------- */ case XLOG_FROM_STREAM: /* * Failure while streaming. Most likely, we got here * because streaming replication was terminated, or * promotion was triggered. But we also get here if we * find an invalid record in the WAL streamed from master, * in which case something is seriously wrong. There's * little chance that the problem will just go away, but * PANIC is not good for availability either, especially * in hot standby mode. So, we treat that the same as * disconnection, and retry from archive/pg_wal again. The * WAL in the archive should be identical to what was * streamed, so it's unlikely that it helps, but one can * hope... */ Regards, Bharath Rupireddy.