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 1oFH8Z-00034p-D1 for pgsql-hackers@arkaria.postgresql.org; Sat, 23 Jul 2022 15:33:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oFH8Y-00055U-7a for pgsql-hackers@arkaria.postgresql.org; Sat, 23 Jul 2022 15:33:50 +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 1oFH8X-00052n-Hl for pgsql-hackers@lists.postgresql.org; Sat, 23 Jul 2022 15:33:49 +0000 Received: from mail-vs1-xe2c.google.com ([2607:f8b0:4864:20::e2c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oFH8U-0007dy-VR for pgsql-hackers@lists.postgresql.org; Sat, 23 Jul 2022 15:33:48 +0000 Received: by mail-vs1-xe2c.google.com with SMTP id 125so6825433vsx.7 for ; Sat, 23 Jul 2022 08:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joeconway.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=okrDVllUXi/Smf4w9m/xpP+EjH9UBIhn/fpEm2A3Vvc=; b=O9gCVOwTEp7IC+Eu2D/ZOwdB0wacVPXq2rwd1AnAfD6ES/gQ1tnPJEaZKNtLBbo/Kt 1rz1jvKU22P2qhCXVjNcKT6yR1kw0uqE9uShpLMcqJT6hToRz/LXn2sMntDll3dz9kAb UuBQXQ/pckkbEJTs7CAgG4bCBry3ugMZuS+2gitDLnKJ8tkhnYWoe47Fd+FP8lQYPDJm Mmzo5W6t0En2f4OOWyUWzxvoWAQFWx4Jh8Ti9G+QDepFcQ0rxaAdqyaZ4tNKkTRuQeD2 omTFUflxAER1QWHT9FZ4/nTIkUe0Xheh7Iv9fPiBRxgx9iqS0so1Ch242+/TnYGj/gG4 eyyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=okrDVllUXi/Smf4w9m/xpP+EjH9UBIhn/fpEm2A3Vvc=; b=Xr+Qk3l5SDHudyGzEaqIl68Ym6xFuaP+0SxId/UT/XTp7dKyinmyGR0hl0hTYy6dph R97DLJUITRqjv0B317ijZQ/fzV7ar7VnlcugIxxbR/Cofjg7l4wMoTOLR4wk+G38eIHl aQXnbnXaLqAbzCIKMjyCttcgWkFaAR5s02HYjTBMyEoXx7EHC7eCo29vgTiPBnJF1mT9 yvPvCgopHkVJ4/ayjpjt07ZjwJtNVYxctiJ+VSU1ndf/HjBytHom8U2dCN5MgqIAKlen dqjtTqzDkHj7nUp3ArCzDEjk6WhT5i5qoDUg3jGE4ZdvOakN2LHPvUC5Xf9J1r5XVBSH hr9Q== X-Gm-Message-State: AJIora8WQ2bDVlZcbKne0yP0JDIFXByrh2CC/otmzok+A1+w7qQWfLi+ PTr4prC7v6nuppLWZAiRIPA/HQ== X-Google-Smtp-Source: AGRyM1vqOt1LyjEt46mXf0WuuH16kOl+rlJG8zXcjJU9cpWCnb8InmyV73GrSCGFLrtJL1xxSkVluw== X-Received: by 2002:a67:f517:0:b0:358:3cc6:fc6 with SMTP id u23-20020a67f517000000b003583cc60fc6mr1322369vsn.74.1658590425564; Sat, 23 Jul 2022 08:33:45 -0700 (PDT) Received: from [192.168.4.41] (072-017-018-098.res.spectrum.com. [72.17.18.98]) by smtp.gmail.com with ESMTPSA id o15-20020ab0376f000000b0038342b58f6csm1068235uat.17.2022.07.23.08.33.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 Jul 2022 08:33:44 -0700 (PDT) Message-ID: Date: Sat, 23 Jul 2022 11:33:43 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Support logical replication of DDLs Content-Language: en-US To: Zheng Li , "houzj.fnst@fujitsu.com" Cc: Amit Kapila , Masahiko Sawada , Japin Li , Alvaro Herrera , Dilip Kumar , rajesh singarapu , PostgreSQL Hackers , Peter Smith References: From: Joe Conway In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/22/22 17:18, Zheng Li wrote: > Here is a patch that supports replication of global object commands, > these include ROLE statements, database statements and tablespace statements. > The patch should be applied on top of the v13 DDL replication patch set that > ZJ Hou sent in the previous email. > > Global objects commands are different from other DDL commands in > that: > 1. Global objects commands are allowed to be executed in any databases > 2. Global objects are not schema qualified > 2. Global objects commands are not captured by event triggers > > This patch supports global objects commands replication by WAL > logging the command using the same function for DDL logging - > LogLogicalDDLMessage, towards the end of standard_ProcessUtility. > Because global objects are not schema qualified, we can skip the deparser > invocation and directly log the original command string for replay on > the subscriber. I have not looked at the patch but +1 for the general concept. Seems like you might want to start a separate thread, perhaps after the currently running commitfest is over. > A key problem is global objects can get inconsistent between the > publisher and the subscriber if a command changes the global object > in a database (on the source side) which doesn't configure logical replication. > I think we can work on the following directions in order to avoid such > inconsistency: > > 1. Introduce a publication option for global objects command replication > and document that logical replication of global objects commands is preferred > to be configured on all databases. Otherwise inconsistency can happen > if a command changes the global object in a database which doesn't configure > logical replication. > > 2. Introduce database cluster level logical replication to avoid > such inconsistency, this is especially handy when there is a large > number of databases to configure for logical replication. I would strongly favor #2, although I admittedly have no idea what complexities it adds. -- Joe Conway RDS Open Source Databases Amazon Web Services: https://aws.amazon.com