Re: Pgoutput not capturing the generated columns

2024-11-03 Thread Ajin Cherian
On Mon, Nov 4, 2024 at 2:20 PM Amit Kapila wrote: > > On Thu, Oct 31, 2024 at 4:26 PM Ajin Cherian wrote: > > > > 5. Verified that publications with different column list are disallowed to > > be subscribed by one subscription > >a. PUB_A(column list = (a,

Re: Pgoutput not capturing the generated columns

2024-10-31 Thread Ajin Cherian
On Thu, Oct 31, 2024 at 9:55 PM Ajin Cherian wrote: > I ran some tests and verified that the patch works with previous versions > of PG12 and PG17 > 1. Verified with publications with generated columns and without generated > columns on patched code and subscriptions on P

Re: Pgoutput not capturing the generated columns

2024-10-31 Thread Ajin Cherian
olumn list, without publish_generated_column) PUB_B(no column list, with publish_generated_column) - FAIL Tests did not show any unexpected behaviour. regards, Ajin Cherian Fujitsu Australia

Re: Conflict Detection and Resolution

2024-09-19 Thread Ajin Cherian
Can we change this to use the new foreach_ptr implementations added: > + foreach(lc, stmtresolvers) > + { > + DefElem*defel = (DefElem *) lfirst(lc); > + ConflictType type; > + char *resolver; > > to use foreach_ptr like: > foreach_ptr(DefElem, defel, stmtresolvers) > { > + ConflictType type; > + char *resolver; > > } > Changed accordingly. regards, Ajin Cherian Fujitsu Australia

Re: Conflict Detection and Resolution

2024-08-27 Thread Ajin Cherian
t; > I am not sure if we need to dump default resolvers. Would like to know > what others think on this. > > 3) > Why in 002_pg_dump.pl we have default resolvers set explicitly? > > In 003_pg_dump.pl, default resolvers are not set explicitly, that is the regexp to check the pg_dum

Re: Introduce XID age and inactive timeout based replication slot invalidation

2024-08-13 Thread Ajin Cherian
alculation of resource limits really required here when the same is already done inside InvalidateObsoleteReplicationSlots() regards, Ajin Cherian Fujitsu Australia

Re: Introduce XID age and inactive timeout based replication slot invalidation

2024-08-12 Thread Ajin Cherian
n. This has been the > approach until v40 patch. > b) Checkpointer and/or other backends add an autovacuum work item via > AutoVacuumRequestWork(), and autovacuum when it gets to it will > invalidate the replication slots. But, what to do for the vacuum > command here? > > Please find the attached v41 patches implementing the idea of vacuum > doing the invalidation. > > Thoughts? > > Thanks to Sawada-san for a detailed off-list discussion. > The patch no longer applies on HEAD, please rebase. regards, Ajin Cherian Fujitsu Australia

Re: Conflict Detection and Resolution

2024-07-01 Thread Ajin Cherian
1) 2024-07-01 02:52:59.427 EDT [20304] CONTEXT: processing remote data for replication origin "pg_16417" during message type "COMMIT" in transaction 763, finished at 0/15E7F68 2024-07-01 02:52:59.427 EDT [20304] WARNING: resource was not closed: TupleDesc 0x7f8c0439e448 (16402,-1)

Re: Proposal: Filter irrelevant change before reassemble transactions during logical decoding

2024-06-04 Thread Ajin Cherian
On Wed, May 22, 2024 at 2:17 PM Ajin Cherian wrote: > > The reason for the crash is that the RelationSyncCache was NULL prior to > reaching a consistent point. > Hi li jie, I see that you created a new thread with an updated version of > this patch [1]. I used that patch and addr

Re: Proposal: Filter irrelevant change before reassemble transactions during logical decoding

2024-05-21 Thread Ajin Cherian
On Tue, Mar 19, 2024 at 1:49 PM Ajin Cherian wrote: > > >> Of course you can, but this will only convert disk space into memory >> space. >> For details, please see the case in Email [1]. >> >> [1] >> https://www.postgresql.org/message-id/CAGfChW51P944

Re: Slow catchup of 2PC (twophase) transactions on replica in LR

2024-04-22 Thread Ajin Cherian
On Thu, Apr 18, 2024 at 4:26 PM Ajin Cherian wrote: > > Attaching the patch for your review and comments. Big thanks to Kuroda-san > for also working on the patch. > > Looking at this a bit more, maybe rolling back all prepared transactions on the subscriber when toggling two_pha

Re: Slow catchup of 2PC (twophase) transactions on replica in LR

2024-04-17 Thread Ajin Cherian
decoded as the pending prepared transactions are prior to the "two_phase_at" LSN. With this patch, now we are able to handle both pending prepared transactions when altering two_phase from true to false as well as false to true. Attaching the patch for your review and comments. Big thanks to K

Re: Slow catchup of 2PC (twophase) transactions on replica in LR

2024-04-16 Thread Ajin Cherian
that me that the > problem takes place. > > > Yes, I was able to reproduce the slow catchup of twophase transactions with pgbench with 20 clients. regards, Ajin Cherian Fujitsu Australia

Re: Slow catchup of 2PC (twophase) transactions on replica in LR

2024-04-05 Thread Ajin Cherian
r. 2. No solution yet. 3. We could mandate that the altering of two_phase state only be done after disabling the subscription, just like how it is handled for failover option. Let me know your thoughts. regards, Ajin Cherian Fujitsu Australia v2-0001-Allow-altering-of-two_phase-option-of-a-SUBSCRIPT.patch Description: Binary data

Re: Slow catchup of 2PC (twophase) transactions on replica in LR

2024-04-03 Thread Ajin Cherian
Kuroda-san for working on the patch. regards, Ajin Cherian Fujitsu Australia v1-0001-Allow-altering-of-two_phase-option-in-subscribers.patch Description: Binary data

Re: Skip collecting decoded changes of already-aborted transactions

2024-03-27 Thread Ajin Cherian
herwise return false. we discards/we discard 2. In function ReorderBufferCheckTXNAbort(): I haven't tested this but I wonder how prepared transactions would be considered, they are neither committed, nor in progress. regards, Ajin Cherian Fujitsu Australia

Re: Introduce XID age and inactive timeout based replication slot invalidation

2024-03-26 Thread Ajin Cherian
Lock held. Maybe do this prior to acquiring the spinlock. regards, Ajin Cherian Fujitsu Australia

Re: Introduce XID age and inactive timeout based replication slot invalidation

2024-03-22 Thread Ajin Cherian
ilover != failover) { MyReplicationSlot->data.failover = failover; } if (MyReplicationSlot->data.inactive_timeout != inactive_timeout) { MyReplicationSlot->data.inactive_timeout = inactive_timeout; } if (lock_acquired) { SpinLockRelease(&MyReplicationSlot->mutex); ReplicationSlotMarkDirty(); ReplicationSlotSave(); } 2. In patch 0005: why change walrcv_alter_slot option? it doesn't seem to be used anywhere, any use case for it? If required, would the intention be to add this as a Create Subscription option? regards, Ajin Cherian Fujitsu Australia

Re: Proposal: Filter irrelevant change before reassemble transactions during logical decoding

2024-03-18 Thread Ajin Cherian
he publication publishes "ALL TABLES"? 5. In function: pgoutput_table_filter() - this code appears to be filtering out not just unpublished tables but also applying row based filters on published tables as well. Is this really within the scope of the feature? regards, Ajin Cherian Fujitsu Australia

Re: Skip collecting decoded changes of already-aborted transactions

2024-03-14 Thread Ajin Cherian
check the + * transaction status so the caller always process this transaction. + */ + if (debug_logical_replication_streaming == DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE) + return false; /process/processes regards, Ajin Cherian Fujitsu Australia

Re: Race condition in FetchTableStates() breaks synchronization of subscription tables

2024-03-11 Thread Ajin Cherian
, it doesn't fit well. regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2024-03-07 Thread Ajin Cherian
Run2: 627.924183 secs There was no degradation in performance seen. Thanks Nisha for helping with the testing. regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2024-03-01 Thread Ajin Cherian
dback=on, standby_slot_names not configured, logical subscriber not failover enabled, physical standby not configured for sync RUN1 (TPS) RUN2 (TPS) AVERAGE (TPS) 8.18839 8.18839 8.18839-- degradation from first config *-0.17%* PATCHED code - (v98-0001) Synchronous_commit=on, hot_standby_feedback=on, standby_slot_names configured to physical standby, logical subscriber failover enabled, physical standby configured for sync RUN1 (TPS) RUN2 (TPS) AVERAGE (TPS) 8.173062 8.068536 8.120799-- degradation from first config* -0.99%* Overall, I do not see any significant performance degradation with the patch and sync-slot enabled with one logical subscriber and one physical standby. Attaching script for my final test configuration for reference. regards, Ajin Cherian Fujitsu Australia <>

Re: Slow catchup of 2PC (twophase) transactions on replica in LR

2024-02-22 Thread Ajin Cherian
ROM test WHERE v = pg_backend_pid(); INSERT INTO test(v) SELECT pg_backend_pid(); PREPARE TRANSACTION $$:mygid$$; COMMIT PREPARED $$:mygid$$; regards, Ajin Cherian Fujitsu Australia

Re: Have pg_basebackup write "dbname" in "primary_conninfo"?

2024-02-20 Thread Ajin Cherian
time the information whether it > is > intentionally specified or not is discarded. Then, > GenerateRecoveryConfig() would > just write down all the connection parameters from PGconn, they cannot > recognize. > > Well, one option is that if a default dbname should be written to the configuration file, then "postgres' is a better option than "replication" or "username" as the default option, at least a db of that name exists. regards, Ajin Cherian Fujitsu Australia

Re: Have pg_basebackup write "dbname" in "primary_conninfo"?

2024-02-20 Thread Ajin Cherian
ithout calling that function. This requires connecting to a database. regards, Ajin Cherian Fujitsu Australia

Re: Have pg_basebackup write "dbname" in "primary_conninfo"?

2024-02-20 Thread Ajin Cherian
blank in the generated primary_conninfo string as well. regards, Ajin Cherian Fujitsu Australia

Re: Improve eviction algorithm in ReorderBuffer

2024-02-14 Thread Ajin Cherian
On Sat, Feb 10, 2024 at 2:23 AM Masahiko Sawada wrote: > On Fri, Feb 9, 2024 at 7:35 PM Ajin Cherian wrote: > > > > > > > > On Tue, Feb 6, 2024 at 5:06 PM Masahiko Sawada > wrote: > >> > >> > >> I've attached the new version patch

Re: Improve eviction algorithm in ReorderBuffer

2024-02-09 Thread Ajin Cherian
is function when not necessary? This check was there in code before the patch. patch 0003: +/* + * The threshold of the number of transactions in the max-heap (rb->txn_heap) + * to switch the state. + */ +#define REORDE_BUFFER_MEM_TRACK_THRESHOLD 1024 Typo: I think you meant REORDER_ and not REORDE_ regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2024-02-04 Thread Ajin Cherian
_syncslot = true so they can receive failover logical slots changes from the primary. regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2024-01-31 Thread Ajin Cherian
a subscription without failover enabled to make sure that the Subscription with failover disabled does not depend on sync on standby, but this fails because we have failover enabled by default. In summary, I don't think these issues are actual bugs but expected behaviour change. regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2024-01-23 Thread Ajin Cherian
n_slot('lsub2_slot', 'pgoutput', false, false, true); ?column? -- init (1 row) Time: 36.125 ms postgres=# SELECT 'init' FROM pg_create_logical_replication_slot('lsub1_slot', 'pgoutput', false, false, false); ?column? -- init (1 row) Time: 53.981 ms regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2023-11-30 Thread Ajin Cherian
of the same name exists, then thereafter no new sync slots are created on standby. Is this expected? I do see that previously created slots are kept up to date, just that no new slots are created after that. regards, Ajin Cherian Fujitsu australia

Re: PATCH: Add REINDEX tag to event triggers

2023-11-27 Thread Ajin Cherian
plicate reindex_event_trigger_collect in indexcmds.c since it is already present in index.c. Add it to index.h and make the function extern so that it can be accessed in both index.c and indexcmds.c regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2023-11-23 Thread Ajin Cherian
c = MyProc; + +before_shmem_exit(slotsync_worker_detach, (Datum) 0); + +LWLockRelease(SlotSyncWorkerLock); +} before_shmem_exit() can error out leaving the lock acquired. Maybe you should release the lock prior to calling before_shmem_exit() because you don't need the lock there. regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2023-11-16 Thread Ajin Cherian
is not very good. Neither does it sound like an error, nor is there clarity on what the underlying problem is or how to correct it. regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2023-11-13 Thread Ajin Cherian
validated locally (either by itself) or by primary_slot > being invalidated, then we should skip the sync. I will fix this in > the next version. Yes, that works. Another bug I see in my testing is that pg_get_slot_invalidation_cause() does not release the LOCK if it finds the slot it is search

Re: Synchronizing slots from primary to standby

2023-11-12 Thread Ajin Cherian
, then the local_slot_update() function is never called to set the invalidation status on the local slot. And for invalidated slots, restart_lsn is always NULL. regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2023-10-30 Thread Ajin Cherian
27; flag by adding another flag "failover_opt_given". Plugins that set this, will be able to change the failover flag of the slot, while plugins that do not support this will not set this and the failover flag of the created slot will remain. What do you think? regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2023-10-23 Thread Ajin Cherian
Context will not allow us to change the slot's failover flag using Alter subscription. Currently alter subscription re-establishes the connection using START REPLICATION and failover is one of the options passed in along with START REPLICATION. I am thinking of moving this change to StartLogicalReplication prior to calling CreateDecodingContext by parsing the command options in StartReplicationCmd without adding it to the LogicalDecodingContext. regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2023-10-15 Thread Ajin Cherian
r (widx = 0; widx < max_slotsync_workers; widx++) > + { > + SlotSyncWorker *worker = &LogicalRepCtx->ss_workers[widx]; > + > + if (worker->hdr.in_use && !worker->dbcount) > + slotsync_worker_stop_internal(worker); > + } > > Is it safe to stop this unguarded by SlotSyncWorkerLock locking? Is > there a window where another dbid decides to reuse this worker at the > same time this process is about to stop it? > == Only the launcher can do this, and there is only one launcher. > ~~~ > > 26. primary_connect > > +/* > + * Connect to primary server for slotsync purpose and return the connection > + * info. Disconnect previous connection if provided in wrconn_prev. > + */ > > /primary server/the primary server/ > == fixed > ~~~ > > 27. > + if (!RecoveryInProgress()) > + return NULL; > + > + if (max_slotsync_workers == 0) > + return NULL; > + > + if (strcmp(synchronize_slot_names, "") == 0) > + return NULL; > + > + /* The primary_slot_name is not set */ > + if (!WalRcv || WalRcv->slotname[0] == '\0') > + { > + ereport(WARNING, > + errmsg("Skipping slots synchronization as primary_slot_name " > +"is not set.")); > + return NULL; > + } > + > + /* The hot_standby_feedback must be ON for slot-sync to work */ > + if (!hot_standby_feedback) > + { > + ereport(WARNING, > + errmsg("Skipping slots synchronization as hot_standby_feedback " > +"is off.")); > + return NULL; > + } > > How come some of these checks giving WARNING that slot synchronization > will be skipped, but others are just silently returning NULL? > == primary_slot_name and hot_standby_feedback are not GUCs exclusive to slot synchronization, they are previously existing - so warning only for them. The others are specific to slot synchronization, so if users set them (which shows that the user intends to use sync-slot), then warning to let the user know that these others also need to be set. > ~~~ > > 28. SaveCurrentSlotSyncConfigs > > +static void > +SaveCurrentSlotSyncConfigs() > +{ > + PrimaryConnInfoPreReload = pstrdup(PrimaryConnInfo); > + PrimarySlotNamePreReload = pstrdup(WalRcv->slotname); > + SyncSlotNamesPreReload = pstrdup(synchronize_slot_names); > +} > > Shouldn't this code also do pfree first? Otherwise these will slowly > leak every time this function is called, right? > == fixed > ~~~ > > 29. SlotSyncConfigsChanged > > +static bool > +SlotSyncConfigsChanged() > +{ > + if (strcmp(PrimaryConnInfoPreReload, PrimaryConnInfo) != 0) > + return true; > + > + if (strcmp(PrimarySlotNamePreReload, WalRcv->slotname) != 0) > + return true; > + > + if (strcmp(SyncSlotNamesPreReload, synchronize_slot_names) != 0) > + return true; > > I felt those can all be combined to have 1 return instead of 3. > == fixed > ~~~ > > 30. > + /* > + * If we have reached this stage, it means original value of > + * hot_standby_feedback was 'true', so consider it changed if 'false' now. > + */ > + if (!hot_standby_feedback) > + return true; > > "If we have reached this stage" seems a bit vague. Can this have some > more explanation? And, maybe also an Assert(hot_standby_feedback); is > helpful in the calling code (before the config is reloaded)? > == rewrote this without that comment. regards, Ajin Cherian Fujitsu Australia

Re: Synchronizing slots from primary to standby

2023-08-15 Thread Ajin Cherian
Then we took > > the average (integer value) of this distance over the span of 10 min > > workload and this is what we got: > > > > I have attached the scripts for schema-setup, running workload and > capturing lag. Please go through Readme for details. > > I did some more tests for 10,20 and 40 slots to calculate the average lsn distance between slots, comparing 1 worker and 3 workers. My results are as follows: 10 slots 1 worker: 5529.75527426 (average lsn distance between primary and standby per slot) 3 worker: 2224.57589134 20 slots 1 worker: 9592.87234043 3 worker: 3194.6293 40 slots 1 worker: 20566.093 3 worker: 7885.80952381 90 slots 1 worker: 36706.8405797 3 worker: 10236.6393162 regards, Ajin Cherian Fujitsu Australia

Re: Support logical replication of DDLs

2023-06-09 Thread Ajin Cherian
objid) > + return true; > > The comment seems wrong/confused – "Only send this ddl if we don't > publish ddl message" (??) > fixed. > == > src/bin/pg_dump/pg_dump.c > > 29. getEventTriggers > > + /* skip internally created event triggers by checking evtisinternal */ > appendPQExpBufferStr(query, > "SELECT e.tableoid, e.oid, evtname, evtenabled, " > "evtevent, evtowner, " > > Uppercase the comment. > fixed. > == > src/include/catalog/pg_event_trigger.h > > 33. > @@ -36,7 +36,7 @@ CATALOG(pg_event_trigger,3466,EventTriggerRelationId) > * called */ > char evtenabled; /* trigger's firing configuration WRT > * session_replication_role */ > - > + bool evtisinternal; /* trigger is system-generated */ > #ifdef CATALOG_VARLEN > text evttags[1]; /* command TAGs this event trigger targets */ > #endif > > ~ > > This change should not remove the blank line that previously existed > before the #ifdef CATALOG_VARLEN. > fixed. > == > src/include/catalog/pg_publication. > > 34. > +/* Publication trigger events */ > +#define PUB_TRIG_DDL_CMD_START "ddl_command_start" > +#define PUB_TRIG_DDL_CMD_END "ddl_command_end" > +#define PUB_TRIG_TBL_REWRITE "table_rewrite" > +#define PUB_TRIG_TBL_INIT_WRITE "table_init_write" > > Elsewhere in PG15 code there are already hardcoded literal strings for > these triggers, so I am wondering if these constants should really be > defined in some common place where everybody can make use of them > instead of having a mixture of string literals and macros for the same > strings. > fixed. > == > src/include/commands/event_trigger.h > > 35. > -extern Oid CreateEventTrigger(CreateEventTrigStmt *stmt); > +extern Oid CreateEventTrigger(CreateEventTrigStmt *stmt, bool isinternal); > extern Oid get_event_trigger_oid(const char *trigname, bool missing_ok); > > IMO a better name is 'is_internal' (Using a snake-case name matches > like the other 'missing_ok') > fixed. > == > src/include/replication/ddlmessage.h > > 36. > + * Copyright (c) 2022, PostgreSQL Global Development Group > > Copyright for the new file should be 2023? > fixed. > == > src/include/tcop/ddldeparse.h > > 37. > * ddldeparse.h > * > * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group > * Portions Copyright (c) 1994, Regents of the University of California > * > * src/include/tcop/ddldeparse.h > > ~ > > I think this is a new file for the feature so why is the copyright > talking about old dates like 1994,1996 etc? > fixed. regards, Ajin Cherian

Re: running logical replication as the subscription owner

2023-05-23 Thread Ajin Cherian
On Mon, May 22, 2023 at 10:36 PM Masahiko Sawada wrote: > > On Wed, May 17, 2023 at 10:10 AM Ajin Cherian wrote: > > > > On Mon, May 15, 2023 at 10:47 PM Masahiko Sawada > > wrote: > > > > > > On Mon, May 15, 2023 at 5:44 PM Ajin Cherian wrote: >

Re: running logical replication as the subscription owner

2023-05-16 Thread Ajin Cherian
On Mon, May 15, 2023 at 10:47 PM Masahiko Sawada wrote: > > On Mon, May 15, 2023 at 5:44 PM Ajin Cherian wrote: > > > > On Fri, May 12, 2023 at 9:55 PM Ajin Cherian wrote: > > > > > > If nobody else is working on this, I can come up with a patch to fix this &

Re: running logical replication as the subscription owner

2023-05-15 Thread Ajin Cherian
On Fri, May 12, 2023 at 9:55 PM Ajin Cherian wrote: > > If nobody else is working on this, I can come up with a patch to fix this > Attaching a patch which attempts to fix this. regards, Ajin Cherian Fujitsu Australia v1-0001-Fix-issue-where-the-copy-command-does-not-adhere-.patch De

Re: running logical replication as the subscription owner

2023-05-12 Thread Ajin Cherian
test should not have access to the table admin_audit. This means the table copy is being invoked as the subscription owner and not the table owner. However, I see subsequent inserts fail on replication with permission denied error, so the apply worker correctly applies the inserts as the table owner. If nobody else is working on this, I can come up with a patch to fix this regards, Ajin Cherian Fujitsu Australia

Re: Support logical replication of DDLs

2023-01-14 Thread Ajin Cherian
*) lfirst(lc1); ^ ddl_deparse.c:8956:31: note: each undeclared identifier is reported only once for each function it appears in ddl_deparse.c:8956:48: error: expected expression before ‘)’ token publication_rel *pub_rel = (publication_rel *) lfirst(lc1); regards, Ajin C

Re: Support logical replication of DDLs

2022-12-12 Thread Ajin Cherian
t; Missing space before "Note" > Fixed. > ~~~ > > 22. LogLogicalDDLMessage > > + /* > + * Ensure we have a valid transaction id. > + */ > + Assert(IsTransactionState()); > + GetCurrentTransactionId(); > > Single line comment should be OK here > Fixed. > ~ > > 23. > > + /* trailing zero is critical; see logicalddlmsg_desc */ > > Uppercase comment > fixed. > ~ > > 24. > > + /* allow origin filtering */ > > Uppercase comment > fixed. > == > > src/backend/replication/logical/proto.c > > 25. logicalrep_read_ddlmessage > > + uint8 flags; > + char *msg; > + > + //TODO double check when do we need to get TransactionId. > + > + flags = pq_getmsgint(in, 1); > + if (flags != 0) > + elog(ERROR, "unrecognized flags %u in ddl message", flags); > + *lsn = pq_getmsgint64(in); > + *prefix = pq_getmsgstring(in); > + *sz = pq_getmsgint(in, 4); > + msg = (char *) pq_getmsgbytes(in, *sz); > + > + return msg; > > 25a. > This code will fail if the associated *write* function has sent a xid. > Maybe additional param is needed to tell it when to read the xid? > removed to not send xid, not required. > ~ > > 25b. > Will be tidier to have a blank line after the elog > fixed. > ~~~ > > 26. logicalrep_write_ddlmessage > > + /* transaction ID (if not valid, we're not streaming) */ > + if (TransactionIdIsValid(xid)) > + pq_sendint32(out, xid); > > Perhaps this "write" function should *always* write the xid even if it > is invalid because then the "read" function will know to always read > it. > changed it to never send xid. > == > > src/backend/replication/logical/reorderbuffer.c > > 27. ReorderBufferQueueDDLMessage > > + Assert(xid != InvalidTransactionId); > > SUGGESTION > Assert(TransactionIdIsValid(xid)); > fixed. > ~~~ > > 28. ReorderBufferSerializeChange > > + data += sizeof(int); > + memcpy(data, change->data.ddlmsg.prefix, > +prefix_size); > + data += prefix_size; > > Unnecessary wrapping of memcpy. > fixed. > ~ > > 29. > > + memcpy(data, &change->data.ddlmsg.cmdtype, sizeof(int)); > + data += sizeof(int); > > Would that be better to write as: > > sizeof(DeparsedCommandType) instead of sizeof(int) > fixed. > ~~~ > > 30. ReorderBufferChangeSize > > + case REORDER_BUFFER_CHANGE_DDLMESSAGE: > + { > + Size prefix_size = strlen(change->data.ddlmsg.prefix) + 1; > + > + sz += prefix_size + change->data.ddlmsg.message_size + > + sizeof(Size) + sizeof(Size) + sizeof(Oid) + sizeof(int); > > sizeof(DeparsedCommandType) instead of sizeof(int) > fixed. Breaking this into two mails, next set of comments in next mail. regards, Ajin Cherian Fujitsu Australia

Re: Support logical replication of DDLs

2022-11-28 Thread Ajin Cherian
Create Publication", maybe in future we'll consider adding it as part of replication slot parameters. regards, Ajin Cherian Fujitsu Australia

Re: Support logical replication of DDLs

2022-11-28 Thread Ajin Cherian
anding ? > > thanks > Raejsh > Currently this feature is only supported using "Create publication". We have not added a slot level parameter to trigger this. regards, Ajin Cherian Fujitsu Australia

Re: Support logical replication of DDLs

2022-11-28 Thread Ajin Cherian
ide, then converts these messages to actual DDL commands and executes them. regards, Ajin Cherian Fujitsu Australia

Re: Failed Assert in pgstat_assoc_relation

2022-11-28 Thread Ajin Cherian
s a relation to a view when you create such a rule like the test case does. So initially the relation had storage, the pgstat_info is linked, then table is converted to a view, but in init, the previous relation is not unlinked but when it tries to link a new relation, the assert fails saying a previous relation is already linked to pgstat_info I have made a small patch with a fix, but I am not sure if this is the right way to fix this. regards, Ajin Cherian Fujitsu Australia pgstat_assoc_fix_for_views.patch Description: Binary data

Re: Support logical replication of DDLs

2022-10-06 Thread Ajin Cherian
for TRANSFORM. > Thanks for the new patch-set. Could you add the changes to patch 1 and patch 2, rather than adding a new patch? Otherwise, we'll have a separate patch for each command and it will take double work to keep it updated for each new command added. thanks, Ajin Cherian Fujitsu Australia

Re: First draft of the PG 15 release notes

2022-05-12 Thread Ajin Cherian
is worth mentioning: Skip empty transactions for logical replication. commit d5a9d86d8ffcadc52ff3729cd00fbd83bc38643c https://github.com/postgres/postgres/commit/d5a9d86d8ffcadc52ff3729cd00fbd83bc38643c regards, Ajin Cherian Fujitsu Australia

Re: Support logical replication of DDLs

2022-05-10 Thread Ajin Cherian
and we shall do that in the next patch unless > this approach is not worth pursuing. > > This POC is prepared by Ajin Cherian, Hou-San, and me. > > Thoughts? > > [1] - > https://www.postgresql.org/message-id/20150215044814.GL3391%40alvh.no-ip.org I have updated Amit&

Re: deparsing utility commands

2022-04-15 Thread Ajin Cherian
e same commit messages as previously present. regards, Ajin Cherian

Re: deparsing utility commands

2022-04-15 Thread Ajin Cherian
ches 3 and 4 seem to be related to the testing of the extension and contrib module ddl_deparse which is not in this patch-set, so I have left those patches out, as I have no way of testing the test cases added as part of these patches. regards, Ajin Cherian Fujitsu Australia 0002-Move-som

Re: deparsing utility commands

2022-04-12 Thread Ajin Cherian
On Wed, Apr 13, 2022 at 2:29 PM Ajin Cherian wrote: > > > This patch-set has not been rebased for some time. I see that there is > interest in this patch from the logical > replication of DDL thread [1]. > Forgot to add the link to the thread. [1] - https://www.postgre

Re: deparsing utility commands

2022-04-12 Thread Ajin Cherian
e is interest in this patch from the logical replication of DDL thread [1]. I will take a stab at rebasing this patch-set, I have already rebased the first patch and will work on the other patches in the coming days. Do review and give me feedback. regards, Ajin Cherian Fujitsu Australia 0001-ddl

Re: Support logical replication of DDLs

2022-04-06 Thread Ajin Cherian
her review. > The patch no longer applies. The patch is a very good attempt, and I would also like to contribute if required. I have a few comments but will hold it till a rebased version is available. regards, Ajin Cherian Fujitsu Australia

Re: Logical replication row filtering and TOAST

2022-04-05 Thread Ajin Cherian
On Tue, Apr 5, 2022 at 8:32 PM Amit Kapila wrote: > > How about something like the attached? > LGTM. regards, Ajin Cherian Fujitsu Australia

Re: logical replication empty transactions

2022-03-18 Thread Ajin Cherian
in one of the existing test > files(say in 001_rep_changes.pl)? added a simple test. > 4. I think we can drop the skip streaming patch as we can't do that for now. Dropped, In addition, I have also added a few more comments explaining why the begin send is delayed in pgoutput_change

Re: logical replication empty transactions

2022-03-16 Thread Ajin Cherian
On Mon, Mar 7, 2022 at 11:44 PM Ajin Cherian wrote: > > Fixed. > > regards, > Ajin Cherian > Fujitsu Australia Rebased the patch and fixed some whitespace errors. regards, Ajin Cherian Fujitsu Australia v25-0001-Skip-empty-transactions-for-logical-replication.patch Descri

Re: Logical replication timeout problem

2022-03-07 Thread Ajin Cherian
paliveIfNecessary(ctx, false); + This reset is called too early, this function might go on to skip changes because of the row filter, so this reset fits better once we know for sure that a change is sent out. You will also need to send keep alive when the change is skipped due to the row filter.

Re: logical replication empty transactions

2022-03-07 Thread Ajin Cherian
On Mon, Mar 7, 2022 at 7:50 PM shiy.f...@fujitsu.com wrote: > > On Fri, Mar 4, 2022 9:41 AM Ajin Cherian wrote: > > > > I have split the patch into two. I have kept the logic of skipping > > streaming changes in the second patch. > > I will work on the second

Re: logical replication empty transactions

2022-03-03 Thread Ajin Cherian
I have split the patch into two. I have kept the logic of skipping streaming changes in the second patch. I will work on the second patch once we can figure out a solution for the COMMIT PREPARED after restart problem. regards, Ajin Cherian v23-0001-Skip-empty-transactions-for-logical

Re: logical replication empty transactions

2022-03-02 Thread Ajin Cherian
ng and resetting our own context */ > old = MemoryContextSwitchTo(data->context); > > > I am not sure if it is suitable to send begin or stream_start here, because > the > row filter is not checked yet. That means, empty transactions caused by row > filter are n

Re: logical replication empty transactions

2022-03-02 Thread Ajin Cherian
worker as it tries to find the non-existent streamed file. We could add logic to silently ignore a spurious "stream prepare" but that might not be ideal. Any thoughts on how to address this? Or else, we will need to avoid skipping streamed transactions as well. regards, Ajin Cherian Fujitsu Australia

Re: logical replication empty transactions

2022-02-28 Thread Ajin Cherian
>output_plugin_private = NULL; > + > + /* If no changes were part of this transaction then drop the commit */ > + if (!sent_begin_txn) > + { > + elog(DEBUG1, "Skipping replication of an empty transaction in stream > commit"); > + return; > + } > > (Same as

Re: logical replication empty transactions

2022-02-25 Thread Ajin Cherian
ts from Peter and Wang in my next patch update. regards, Ajin Cherian Fujitsu Australia v20-0001-Skip-empty-transactions-for-logical-replication.patch Description: Binary data

Re: logical replication empty transactions

2022-02-22 Thread Ajin Cherian
On Thu, Feb 17, 2022 at 9:42 PM Amit Kapila wrote: > > On Mon, Jan 31, 2022 at 6:18 PM Ajin Cherian wrote: > > > > Few comments: > = > 1. Is there any particular why the patch is not skipping empty xacts > for streaming (in-progress) transactions as noted

Re: logical replication empty transactions

2022-02-18 Thread Ajin Cherian
t to break backward compatibility for this small added optimization. Amit, I will work on your comments. regards, Ajin Cherian Fujitsu Australia

Re: Logical replication timeout problem

2022-02-17 Thread Ajin Cherian
e attachment). Hi Wang, Some comments: I see you only track skipped Inserts/Updates and Deletes. What about DDL operations that are skipped, what about truncate. What about changes made to unpublished tables? I wonder if you could create a test script that only did DDL operations and truncates, would this timeout happen? regards, Ajin Cherian Fujitsu Australia

Re: row filtering for logical replication

2022-02-03 Thread Ajin Cherian
0); -- 25% allowed CREATE PUBLICATION pub_1 FOR TABLE test WHERE (key > 100); -- 0% allowed DO $do$ BEGIN FOR i IN 1..101 BY 4000 LOOP Alter table test alter column value1 TYPE varchar(30); INSERT INTO test VALUES(i,'BAH', row_to_json(row(i))); Alter table test ALTER COLUMN value1 TYPE text; UPDATE test SET value = 'FOO' WHERE key = i; COMMIT; END LOOP; END $do$; regards, Ajin Cherian Fujitsu Australia

Re: row filtering for logical replication

2022-02-02 Thread Ajin Cherian
LUES(i,'BAH', row_to_json(row(i))); UPDATE test SET value = 'FOO' WHERE key = i; IF I % 1000 = 0 THEN COMMIT; END IF; END LOOP; END $do$; regards, Ajin Cherian Fujitsu Australia On Tue, Feb 1, 2022 at 12:07 PM Peter Smith wrote: > > On Sat, Jan 29, 2022 at 11:31 A

Re: logical replication empty transactions

2022-01-31 Thread Ajin Cherian
On Sun, Jan 30, 2022 at 7:04 PM osumi.takami...@fujitsu.com wrote: > > On Thursday, January 27, 2022 9:57 PM Ajin Cherian wrote: > Hi, thanks for your patch update. > > > > On Wed, Jan 26, 2022 at 8:33 PM osumi.takami...@fujitsu.com > > wrote: > > > > &

Re: logical replication empty transactions

2022-01-27 Thread Ajin Cherian
On Thu, Jan 27, 2022 at 12:16 AM osumi.takami...@fujitsu.com wrote: > > On Tuesday, January 11, 2022 6:43 PM From: Ajin Cherian > wrote: > > Minor update to rebase the patch so that it applies clean on HEAD. > Hi, let me share some additional comments on v16. &g

Re: logical replication empty transactions

2022-01-27 Thread Ajin Cherian
On Wed, Jan 26, 2022 at 8:33 PM osumi.takami...@fujitsu.com wrote: > > On Tuesday, January 11, 2022 6:43 PM Ajin Cherian wrote: > > Minor update to rebase the patch so that it applies clean on HEAD. > Hi, thanks for you rebase. > > Several comments. >

Re: logical replication empty transactions

2022-01-11 Thread Ajin Cherian
On Wed, Sep 1, 2021 at 8:57 PM Ajin Cherian wrote: > > Thanks for the comments. Addressed them in the attached patch. > > regards, > Ajin Cherian > Fujitsu Australia Minor update to rebase the patch so that it applies clean on HEAD. regards, Ajin Cherian regards, Ajin Cheri

Re: row filtering for logical replication

2021-12-20 Thread Ajin Cherian
t can directly get from the value >from the virtual tuple. Storing the old tuple/new tuple in a slot and re-using the slot avoids the overhead of continuous deforming of tuple at multiple levels in the code. regards, Ajin Cherian [1] - https://www.postgresql.org/message-id/CAFiTN-vwBjy+eR+iodkO5UVN5cPv_xx1=s8ehzgcrjza+az...@mail.gmail.com

Re: row filtering for logical replication

2021-12-19 Thread Ajin Cherian
7;s better to give users more flexibility while warning him on what the consequences are rather than restricting him with constraints. We could explain this in the documentation so that users can better predict the effect of having pubaction specific filters. regards, Ajin Cherian Fujitsu Australia

Re: row filtering for logical replication

2021-12-17 Thread Ajin Cherian
decide if the update was previously published or not? I think it's futile for the publisher side to try and figure out the history of published rows. In fact, if this level of logic is required then it is best implemented on the subscriber side, which then defeats the purpose of a publication filter. regards, Ajin Cherian Fujitsu Australia

Re: row filtering for logical replication

2021-12-01 Thread Ajin Cherian
e can check the transformed where clause and see if the where > clause is the same or not. If you are ok with this approach you could > make similar changes. thanks for your patch, I have used the same logic with minor changes and shared it with Peter for v44. regards, Ajin Cherian Fujitsu Australia

Re: row filtering for logical replication

2021-10-11 Thread Ajin Cherian
On Tue, Oct 12, 2021 at 1:37 AM Dilip Kumar wrote: > > On Wed, Oct 6, 2021 at 2:33 PM Ajin Cherian wrote: > > > > On Sat, Oct 2, 2021 at 5:44 PM Ajin Cherian wrote: > > > > > > I have for now also rebased the patch and merged the first 5 patches > > &g

Re: extensible options syntax for replication parser?

2021-09-26 Thread Ajin Cherian
On Mon, Sep 27, 2021 at 11:20 AM Ajin Cherian wrote: > > On Sat, Sep 25, 2021 at 4:28 AM tushar wrote: > > > > On 9/24/21 10:36 PM, Robert Haas wrote: > > > Here's v9, fixing the issue reported by Fujii Masao. > > > > Please refer this scenario w

Re: extensible options syntax for replication parser?

2021-09-26 Thread Ajin Cherian
and the apply worker is restarted. There are logs which indicate that this has happened. If you could share the logs (on publisher and subscriber) when this happens, I could have a look. regards, Ajin Cherian Fujitsu Australia

Re: row filtering for logical replication

2021-09-21 Thread Ajin Cherian
On Wed, Sep 22, 2021 at 1:50 PM Amit Kapila wrote: > > On Wed, Sep 22, 2021 at 6:42 AM Ajin Cherian wrote: > > > > Why do you think that the second assumption (if there is an old tuple > it will contain all RI key fields.) is broken? It seems to me even > when we

Re: row filtering for logical replication

2021-09-21 Thread Ajin Cherian
is case. There is currently logic in ReorderBufferToastReplace() which already deforms the new tuple to detoast changed toasted fields in the new tuple. I think if we can enhance this logic for our purpose, then we can avoid an extra deform of the new tuple. But I think you had earlier indicated th

Re: row filtering for logical replication

2021-09-20 Thread Ajin Cherian
can apply a filter expression on individual attributes. The current mechanism does it on a tuple. Do let me know if you have any ideas there? Even if it were done, there would still be the overhead of deforming the tuple. I will run some performance tests like Amit suggested and see what the overhead is and try to minimise it. regards, Ajin Cherian Fujitsu Australia

Re: row filtering for logical replication

2021-09-08 Thread Ajin Cherian
PDATE old-row (match) new-row (no match) -> DELETE old-row (no match) new row (match) -> INSERT old-row (match) new row (match) -> UPDATE old-row (no match) new-row (no match) -> (drop change) regards, Ajin Cherian Fujitsu Australia

Re: [BUG]Update Toast data failure in logical replication

2021-09-07 Thread Ajin Cherian
oesn't has any external data. * It's always true in the DELETE case. After: * key_required should be false if caller knows that no replica identity * columns changed value and it doesn't have any external data. * It's always true in the DELETE case. regards, Ajin Cherian Fujitsu Australia

Re: [BUG]Update Toast data failure in logical replication

2021-09-02 Thread Ajin Cherian
y seem to be working fine. No review comments, the patch looks good to me. regards, Ajin Cherian Fujitsu Australia

Re: logical replication empty transactions

2021-09-01 Thread Ajin Cherian
ep alive when skipping transactions in synchronous > replication mode */ > +static bool force_keepalive_syncrep = false; > > => > "force" --> "Force" > > -- > > Otherwise, v14-0001 LGTM. > Thanks for the comments. Addressed them in the attached patch. regards, Ajin Cherian Fujitsu Australia v15-0001-Skip-empty-transactions-for-logical-replication.patch Description: Binary data

Re: Failure of subscription tests with topminnow

2021-08-31 Thread Ajin Cherian
On Tue, Aug 31, 2021 at 3:47 PM Masahiko Sawada wrote: > > On Tue, Aug 31, 2021 at 12:11 PM Amit Kapila wrote: > > > > On Mon, Aug 30, 2021 at 5:48 PM Ajin Cherian wrote: > > > > > > On Mon, Aug 30, 2021 at 7:52 PM Amit Kapila > > > wrote: >

Re: Failure of subscription tests with topminnow

2021-08-30 Thread Ajin Cherian
27;postgres', > "SELECT pid FROM pg_stat_replication WHERE application_name = > 'tap_sub';" > ); > $node_subscriber->safe_psql('postgres', > "ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only > WITH (copy_data = fal

Re: Failure of subscription tests with topminnow

2021-08-27 Thread Ajin Cherian
es as well to make it stable and reduce such random > build farm failures. I have made the changes in 022_twophase_cascade.pl for HEAD as well as patches for older branches. regards, Ajin Cherian Fujitsu Australia HEAD-v2-0001-fix-for-tap-test-failure-seen-in-001_rep_changes.patch Description:

Re: Failure of subscription tests with topminnow

2021-08-26 Thread Ajin Cherian
nd walsender clears its pid on the shmem. > 5. the second walsender writes disconnection log. > 6. the first walsender writes disconneciton log. I agree with this. Attaching a patch on head that modifies this particular script to also consider the state of the walsender. regards, Ajin Cheri

Re: Failure of subscription tests with topminnow

2021-08-25 Thread Ajin Cherian
On Thu, Aug 26, 2021 at 1:54 PM Amit Kapila wrote: > > On Thu, Aug 26, 2021 at 9:21 AM Ajin Cherian wrote: > > > > On Thu, Aug 26, 2021 at 1:06 PM Amit Kapila wrote: > > > > > > > > You have a point but if we see the below logs, it seems the second

Re: Failure of subscription tests with topminnow

2021-08-25 Thread Ajin Cherian
e are seeing this problem? If the pid is cleared in the other order, wouldn't the query [1] return a false? [1] - " SELECT pid != 16336 FROM pg_stat_replication WHERE application_name = 'tap_sub';" regards, Ajin Cherian Fujitsu Australia

  1   2   3   >