Re: Support logical replication of DDLs

2023-07-09 Thread Zheng Li
On Tue, Jun 27, 2023 at 6:16 AM vignesh C wrote: > While development, below are some of the challenges we faced: > 1. Almost all the members of the AlterTableType enum will have to be > annotated. > 2. Complex functionalities which require access to catalog tables > cannot be auto generated,

Re: Support logical replication of DDLs

2023-03-29 Thread Zheng Li
On Wed, Mar 29, 2023 at 5:13 AM Amit Kapila wrote: > > On Wed, Mar 29, 2023 at 2:49 AM Zheng Li wrote: > > > > > > I agree that a full fledged DDL deparser and DDL replication is too > > big of a task for one patch. I think we may consider approaching this >

Re: Support logical replication of DDLs

2023-03-28 Thread Zheng Li
On Sun, Mar 26, 2023 at 5:22 PM Tom Lane wrote: > I spent some time looking through this thread to try to get a sense > of the state of things, and I came away quite depressed. The patchset > has ballooned to over 2MB, which is a couple orders of magnitude > larger than anyone could hope to

Re: Support logical replication of global object commands

2023-03-28 Thread Zheng Li
> I think that there are some (possibly) tricky challenges that haven't > been discussed yet to support replicating global objects. > > First, as for publications having global objects (roles, databases, > and tablespaces), but storing them in database specific tables like > pg_publication doesn't

Re: Initial Schema Sync for Logical Replication

2023-03-22 Thread Zheng Li
> > Yes. Do we have any concrete use case where the subscriber is an older > > version, in the first place? > > > > As per my understanding, it is mostly due to the reason that it can > work today. Today, during an off-list discussion with Jonathan on this > point, he pointed me to a similar

Re: Support logical replication of DDLs

2023-03-06 Thread Zheng Li
On Mon, Mar 6, 2023 at 5:17 AM wangw.f...@fujitsu.com wrote: > > For v-75-0003* patch. > 2. In the function deparse_CreateSeqStmt. > It seems that we are not deparsing the "AS data_type" clause (CREATE SEQUENCE > ... AS data_type). I think this causes all data_type to be default (bigint) > after

Re: Support logical replication of global object commands

2023-02-28 Thread Zheng Li
On Fri, Feb 17, 2023 at 4:48 AM Amit Kapila wrote: > > On Fri, Feb 17, 2023 at 10:58 AM Zheng Li wrote: > > > > > > > Actually, I intend something for global objects. But the main thing > > > > > that is worrying me about this is that we don't have a

Re: Support logical replication of DDLs

2023-02-20 Thread Zheng Li
On Mon, Feb 20, 2023 at 3:23 AM Masahiko Sawada wrote: > > On Fri, Feb 17, 2023 at 1:13 PM Zheng Li wrote: > > > > > > I've implemented a prototype to allow replicated objects to have the > > > > same owner from the publisher in > > > > v69-0008

Re: Support logical replication of global object commands

2023-02-16 Thread Zheng Li
> > > Actually, I intend something for global objects. But the main thing > > > that is worrying me about this is that we don't have a clean way to > > > untie global object replication from database-specific object > > > replication. > > > > I think ultimately we need a clean and efficient way to

Re: Support logical replication of DDLs

2023-02-16 Thread Zheng Li
> > I've implemented a prototype to allow replicated objects to have the > > same owner from the publisher in > > v69-0008-Allow-replicated-objects-to-have-the-same-owner-from.patch. > > > > I also think it would be a helpful addition for users.A few points Thanks for supporting this addition. >

Re: Support logical replication of DDLs

2023-02-12 Thread Zheng Li
On Fri, Feb 10, 2023 at 11:31 AM vignesh C wrote: > > On Fri, 10 Feb 2023 at 21:50, vignesh C wrote: > > The attached v68 version patch has the changes for the same. > > I was not sure if we should support ddl replication of > create/alter/drop subscription commands as there might be some data >

Re: Support logical replication of DDLs

2023-01-23 Thread Zheng Li
> > Yes, CREATE/ALTER SERVER commands are also supported by the current > > DDL replication patch. > > > > >But what about data inserted by the publisher on the > > > foreign server? > > > > I thought the data inserted to a foreign table will always be stored > > on the foreign server unless I'm

Re: Support logical replication of DDLs

2023-01-19 Thread Zheng Li
On Thu, Jan 19, 2023 at 2:05 AM Amit Kapila wrote: > > On Thu, Jan 19, 2023 at 8:39 AM Zheng Li wrote: > > > > On Wed, Jan 18, 2023 at 6:27 AM Amit Kapila wrote: > > > > > > On Sat, Jan 7, 2023 at 8:58 PM Zheng Li wrote: > > > > > > > &g

Re: Support logical replication of DDLs

2023-01-18 Thread Zheng Li
On Wed, Jan 18, 2023 at 6:27 AM Amit Kapila wrote: > > On Sat, Jan 7, 2023 at 8:58 PM Zheng Li wrote: > > > > I added documentation and changed user interface design in the > > attached v60 patch set. > > The patch set addressed comments from Peter in [1]. >

Re: pub/sub - specifying optional parameters without values.

2023-01-09 Thread Zheng Li
Hi, This documentation change looks good to me. I verified in testing and in code that the value for boolean parameters in PUB/SUB commands can be omitted. which is equivalent to specifying TRUE. For example, CREATE PUBLICATIOIN mypub for ALL TABLES with (publish_via_partition_root); is

Re: Support logical replication of DDLs

2022-12-28 Thread Zheng Li
On Wed, Dec 28, 2022 at 5:42 PM Zheng Li wrote: > > >- CreatePublication has a long list of command tags; is that good? > >Maybe it'd be better to annotate the list in cmdtaglist.h somehow. > > I've addressed this comment by introducing a new flag ddlreplok in the > PG_C

Re: Testing DDL Deparser

2022-12-11 Thread Zheng Li
Hi, Thanks for working on this and for the feedback! I've added the updated deparser testing module to the DDL replication thread in [1]. We'll add more test cases to the testing module and continue the discussion there. [1]

Re: Support logical replication of DDLs

2022-11-25 Thread Zheng Li
Hello, Thanks for the feedback. > I have been following this patch for a long time. > Recently, I started to try to test it. I found several bugs > here and want to give you feedback. > > 1. CREATE TABLE LIKE > I found that this case may be repication incorrectly. >You can run the

Re: Support logical replication of DDLs

2022-10-27 Thread Zheng Li
> Hi, authors on this thread. > > The patch v32-0001 is very large, so it will take some time to review > the code in detail. Thanks for reviewing! > Meanwhile, here are some general comments about the patch: > > == > > 1. It might be useful to add this thread to the commitfest, if only so >

Re: Support logical replication of global object commands

2022-08-29 Thread Zheng Li
> > I think a publication of ALL OBJECTS sounds intuitive. Does it mean we'll > > publish all DDL commands, all commit and abort operations in every > > database if there is such publication of ALL OBJECTS? > > > > Actually, I intend something for global objects. But the main thing > that is

Re: Support logical replication of global object commands

2022-08-16 Thread Zheng Li
> Can we think of relying to send WAL of such DDLs just based on whether > there is a corresponding publication (ex. publication of ALL OBJECTS)? > I mean avoid database-specific filtering in decoding for such DDL > commands but not sure how much better it is than the current proposal? I think a

Re: Support logical replication of DDLs

2022-08-08 Thread Zheng Li
> In general, I agree with your comment below that we can work on this > after we have some more concrete plans/discussions. I think we can > probably consider this when we have more discussion around the > publication commands for the DDL objects. However, it would be good if > you can add some

Support logical replication of global object commands

2022-08-08 Thread Zheng Li
bZOnUXyguJ-uBNejwD75Kyo%3DOjdQGJ9g%40mail.gmail.com [2]https://www.postgresql.org/message-id/OS0PR01MB5716009FDCCC0B50BCB14A99949D9%40OS0PR01MB5716.jpnprd01.prod.outlook.com With Regards, Zheng Li Amazon RDS/Aurora for PostgreSQL 0005-Support-replication-of-global-object-commands-these-.patch D

Re: Support logical replication of DDLs

2022-07-23 Thread Zheng Li
On Sat, Jul 23, 2022 at 11:33 AM Joe Conway wrote: > > 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

Re: Support logical replication of DDLs

2022-07-22 Thread Zheng Li
Hello, 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

Re: Support logical replication of DDLs

2022-06-22 Thread Zheng Li
> Here are some points in my mind about the two approaches discussed here. > > 1) search_patch vs schema qualify > > Again, I still think it will bring more flexibility and security by schema > qualify the > objects in DDL command as mentioned before[1]. I wonder what security concerns you have?

Re: Support logical replication of DDLs

2022-06-14 Thread Zheng Li
> Thanks for providing this idea. > > I looked at the string that is used for replication: > > """ > {ALTERTABLESTMT :relation {RANGEVAR :schemaname public :relname foo > :inh true :relpersistence p :alias <> :location 12} :cmds ({ALTERTABLECMD > :subtype 0 :name <> :num 0 :newowner <> :def

Re: Support logical replication of DDLs

2022-05-26 Thread Zheng Li
Hi Masahiko, > Thank you for updating the patches! > > I've not looked at these patches in-depth yet but with this approach, > what do you think we can handle the DDL syntax differences between > major versions? DDL syntax or behavior could be changed by future > changes and I think we need to

Re: logical decoding and replication of sequences

2022-05-25 Thread Zheng Li
> But of course, if we expect/require to have a perfect snapshot for that > exact position in the transaction, this won't work. IMO the whole idea > that we can have non-transactional bits in naturally transactional > decoding seems a bit suspicious (at least in hindsight). > > No matter what we

Re: Support logical replication of DDLs

2022-05-23 Thread Zheng Li
> Now, say, the user has added a bar column with "ALTER TABLE foo ADD > COLUMN bar double precision NOT NULL DEFAULT random();" If we compare > with replication of DMLs like (UPDATE ddl_test SET bar = random();), > the replication won't update rows with values (3 and 4) on subscriber > as they

Re: Support logical replication of DDLs

2022-05-10 Thread Zheng Li
> > > I agree that it adds to our maintainability effort, like every time we > > > enhance any DDL or add a new DDL that needs to be replicated, we > > > probably need to change the deparsing code. But OTOH this approach > > > seems to provide better flexibility. So, in the long run, maybe the > >

Re: Support logical replication of DDLs

2022-05-06 Thread Zheng Li
> Attached is a set of two patches as an attempt to evaluate this approach. > > The first patch provides functions to deparse DDL commands. Currently, > it is restricted to just a simple CREATE TABLE statement, the required > code is extracted from one of the patches posted in the thread [1]. > >

Re: Support logical replication of DDLs

2022-05-03 Thread Zheng Li
> > >Another somewhat unrelated problem I see with this work is how to save > > >recursion of the same command between nodes (when the involved nodes > > >replicate DDLs). For DMLs, we can avoid that via replication origins > > >as is being done in the patch proposed [1] but not sure how will we >

Re: Support logical replication of DDLs

2022-04-29 Thread Zheng Li
ar(20)). In > this > case, the DDL command can de decomposed removing the typmod information (ALTER > TABLE ... ALTER COLUMN ... TYPE varchar) and replacing it with a CHECK > constraint. I tested ALTER TABLE ... ALTER COLUMN ... TYPE. It seems to be working fine. Is there a particular case

Re: Support logical replication of DDLs

2022-04-14 Thread Zheng Li
> > But then this could be true for DML as well right? Like after > > replicating the function to the subscriber if we are sending the DML > > done by function then what's the problem in DDL. I mean if there is > > no design issue in implementing this then I don't think there is much > > point

Re: Support logical replication of DDLs

2022-04-14 Thread Zheng Li
> You should forbid it. Unless you can decompose the command into multiple SQL > commands to make it a safe operation for logical replication. > > Let's say you want to add a column with a volatile default. > > ALTER TABLE foo ADD COLUMN bar double precision DEFAULT random(); > > If you replicate

Re: Support logical replication of DDLs

2022-04-12 Thread Zheng Li
Hi, Here is the rebased new branch https://github.com/zli236/postgres/commits/ddl_replication Regards, Zheng

Re: Support logical replication of DDLs

2022-04-11 Thread Zheng Li
> I'm planning to work on the initial DDL replication. I'll open a new thread as > soon as I write a design for it. Just as an example, the pglogical approach is > to use pg_dump behind the scenes to provide the schema [1]. It is a reasonable > approach but an optimal solution should be an API to

Re: Support logical replication of DDLs

2022-04-11 Thread Zheng Li
Hi Amit, > Some initial comments: > === > 1. > +/* > + * Write logical decoding DDL message into XLog. > + */ > +XLogRecPtr > +LogLogicalDDLMessage(const char *prefix, Oid roleoid, const char *message, > + size_t size, bool transactional) > > I don't see anywhere the patch using a

Re: Support logical replication of DDLs

2022-04-11 Thread Zheng Li
Hi, > > Good catch. The reason for having isTopLevel in the condition is > > because I haven't decided if a DDL statement inside a PL should > > be replicated from the user point of view. For example, if I execute a > > plpgsql function or a stored procedure which creates a table under the hood,

Re: Support logical replication of DDLs

2022-03-24 Thread Zheng Li
Hi Dilip, Thanks for the feedback. > > > > The table creation WAL and table insert WAL are available. The tricky > > > > part is how do we break down this command into two parts (a normal > > > > CREATE TABLE followed by insertions) either from the parsetree or the > > > > WALs. I’ll have to dig

Re: Support logical replication of DDLs

2022-03-21 Thread Zheng Li
Hi Japin, > You should use a different user that has different length from your current > one. > For example: > > px@localhost$ make check-world This is fixed in the latest commit: https://github.com/zli236/postgres/commits/ddl_replication Thanks, Zheng

Re: Support logical replication of DDLs

2022-03-18 Thread Zheng Li
x/Codes/postgresql/Debug/src/bin/pg_dump/tmp_check/tmp_test_jgRI .. > Failed 84/7709 subtests > t/003_pg_dump_with_server.pl .. ok > t/010_dump_connstr.pl . ok > > Test Summary Report > --- > t/002_pg_dump.pl (Wstat: 21504 Tests: 7709 Failed: 84) This is fixed in the latest version. I need to remind myself to run make check-world in the future. Regards, Zheng Li

Re: Support logical replication of DDLs

2022-03-17 Thread Zheng Li
Hello Alvaro, > I think this is a pretty interesting and useful feature. > > Did you see some old code I wrote towards this goal? > https://www.postgresql.org/message-id/20150215044814.gl3...@alvh.no-ip.org > The intention was that DDL would produce some JSON blob that accurately > describes the

Re: Reducing power consumption on idle servers

2022-03-08 Thread Zheng Li
o INT_MAX (the max timeout allowed by WaitLatch()) in which case a worker in hibernation only relies on wakeup? I think it would be nice to run experiments to verify that the patch reduces power consumption while varying the value of HIBERNATE_DELAY_SEC. Regards, Zheng Li Amazon RDS/Aurora for Po

Re: Support logical replication of DDLs

2022-02-23 Thread Zheng Li
Hi Aleksander, >That's great! Thanks! >Maybe the first implementation shouldn't be perfect as long as known >limitations are documented and the future improvements are unlikely to >break anything for the users. Committing an MVP and iterating on this is >much simpler in terms of development and

Support logical replication of DDLs

2022-02-21 Thread Zheng Li
the logic to conditionally log the DDL commands or to conditionally decode/ship the logical DDL message. Thoughts? Your feedback is appreciated. Thanks, Zheng Li Amazon RDS/Aurora for PostgreSQL