From ff283308411fc3f220d9957393c14aa38109f52f Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Fri, 11 Feb 2022 04:44:24 +0000
Subject: [PATCH v2] Document creating an extension in replication setup

This patch adds the steps to create an extension in a typical
postgres replication setup with primary and one or more standbys.
---
 doc/src/sgml/extend.sgml | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml
index e928894726..de25b3a953 100644
--- a/doc/src/sgml/extend.sgml
+++ b/doc/src/sgml/extend.sgml
@@ -1408,6 +1408,42 @@ include $(PGXS)
      any particular database.
     </para>
    </sect2>
+
+   <sect2 id="create-extension-in-replication-setup">
+    <title>Creating An Extension In Physical Replication Setup</title>
+
+    <para>
+     It is important to note few things before creating an extension in a
+     typical postgres physical replication setup with a primary and one or more
+     standbys. Firstly, <link linkend="sql-createextension"><command>CREATE EXTENSION</command></link>
+     commands are replicated to standbys whereas <link linkend="sql-altersystem">ALTER SYSTEM</link>
+     commands or configuration parameters set in <filename>postgresql.conf</filename>
+     file are not. Creating an extension directly on standbys with
+     <link linkend="sql-createextension"><command>CREATE EXTENSION</command></link>
+     command doesn't work as they allow read-only transactions.
+    </para>
+
+    <para>
+     If the extension's shared library doesn't need to be specified in
+     <xref linkend="guc-shared-preload-libraries"/><indexterm><primary>shared_preload_libraries</primary></indexterm>
+     configuration parameter, then create the extension on the primary, the
+     standbys will receive it via physical replication.
+    </para>
+
+    <para>
+     If the extension's shared library needs to be specified in
+     <xref linkend="guc-shared-preload-libraries"/><indexterm><primary>shared_preload_libraries</primary></indexterm>
+     configuration parameter, then set it either via <link linkend="sql-altersystem">ALTER SYSTEM</link>
+     command or <filename>postgresql.conf</filename> file on both primary and
+     standbys, and restart the servers. Create the extension on the primary,
+     the standbys will receive it via physical replication.
+    </para>
+
+    <para>
+     Note that the extension functions which perform writes to the database
+     will not work on standbys as they allow read-only transactions.
+    </para>
+   </sect2>
   </sect1>
 
   <sect1 id="extend-pgxs">
-- 
2.25.1

