Re: Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM

2024-05-15 Thread Bharath Rupireddy
s one like another acronym is being added. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM

2024-05-15 Thread Bharath Rupireddy
On Mon, Apr 29, 2024 at 11:36 AM Bharath Rupireddy wrote: > > Please see the attached v20 patch set. It looks like with the use of the new multi insert table access method (TAM) for COPY (v20-0005), pgbench regressed about 35% [1]. The reason is that the memory-based flushing decision t

Re: Show WAL write and fsync stats in pg_stat_io

2024-05-13 Thread Bharath Rupireddy
ery purpose of one-stop view pg_stat_io for all kinds of I/O. PS: see my response above about adding both WAL write I/O and read I/O stats to pg_stat_wal. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: First draft of PG 17 release notes

2024-05-13 Thread Bharath Rupireddy
WAL isn't something used in production and debug_io_direct is a developer option. > I could reword and merge it into this item, if > you think I should: > > Improve performance of heavily-contended WAL writes (Bharath > Rupireddy) I think both the commits are for different purp

Re: Use WALReadFromBuffers in more places

2024-05-13 Thread Bharath Rupireddy
ted the idea of collecting WAL read stats for both walsenders and the backends reading WAL. If that's done, we can extend it for WAL read from WAL buffers. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: First draft of PG 17 release notes

2024-05-10 Thread Bharath Rupireddy
gt; I welcome feedback. For some reason it was an easier job than usual. Thanks a lot for this work Bruce! It looks like commit https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=91f2cae7a4e664e9c0472b364c7db29d755ab151 is missing from daft release notes. Just curious to know

Re: Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM

2024-04-29 Thread Bharath Rupireddy
On Thu, Apr 25, 2024 at 10:11 PM Jeff Davis wrote: > > On Wed, 2024-04-24 at 18:19 +0530, Bharath Rupireddy wrote: > > I added a flush callback named TableModifyBufferFlushCallback; when > > provided by callers invoked after tuples are flushed to disk from the > > buffers

Re: New committers: Melanie Plageman, Richard Guo

2024-04-26 Thread Bharath Rupireddy
ss and few reverts! Congratulations to both of you! -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: Add missing ConditionVariableCancelSleep() in slot.c

2024-04-25 Thread Bharath Rupireddy
BTW, I like the emoji "¯\_(ツ)_/¯" in the code comments :). > Alternatively, maybe we need to not prepare-to-sleep in > InvalidatePossiblyObsoleteSlot() if we have already prepared to sleep in > a previous iteration through the loop (and of course, don't cancel the > sleep until

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

2024-04-24 Thread Bharath Rupireddy
we could end up > invalidating the temporary slots even if they are shown as active, > which could confuse users. Do we want to somehow deal with it? Yes. As long as the temporary slot is lying unused holding up resources for more than the specified replication_slot_inactive_timeout, it i

Re: Improve WALRead() to suck data directly from WAL buffers when possible

2024-04-24 Thread Bharath Rupireddy
hat should be v18 work, particularly v27-0002: > https://www.postgresql.org/message-id/CALj2ACWCibnX2jcnRreBHFesFeQ6vbKiFstML=w-jvtvukd...@mail.gmail.com Thanks. I started a new thread https://www.postgresql.org/message-id/CALj2ACVfF2Uj9NoFy-5m98HNtjHpuD17EDE9twVeJng-jTAe7A%40mail.gmail.com. -- Bh

Use WALReadFromBuffers in more places

2024-04-24 Thread Bharath Rupireddy
will register this for the next commit fest. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com v1-0001-Use-WALReadFromBuffers-in-more-places.patch Description: Binary data v1-0002-Add-test-module-to-demonstrate-reading-from

Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM

2024-04-24 Thread Bharath Rupireddy
7 BogoMIPS:5999.99 Caches (sum of all): L1d: 256 KiB (8 instances) L1i: 256 KiB (8 instances) L2: 8 MiB (8 instances) L3:35.8 MiB (1 instance) NUMA: NUMA node(s): 1 NUM

Remove unnecessary segment number calculation after wal_removed invalidation of replication slots

2024-04-13 Thread Bharath Rupireddy
egNo); + Assert(RedoRecPtr_saved == RedoRecPtr); -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com v1-0001-Remove-unnecessary-seg-no-calculation-after-check.patch Description: Binary data

Add missing ConditionVariableCancelSleep() in slot.c

2024-04-13 Thread Bharath Rupireddy
in {1..100}; do make check PROVE_TESTS="t/001_rep_changes.pl"; if [ $? -ne 0 ]; then echo "The command failed on iteration $i"; break; fi; done -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com v1-0001-Add-missi

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

2024-04-12 Thread Bharath Rupireddy
On Sat, Apr 6, 2024 at 5:10 PM Bharath Rupireddy wrote: > > Please see the attached v38 patch. Hi, thanks everyone for reviewing the design and patches so far. Here I'm with the v39 patches implementing inactive timeout based (0001) and XID age based (0002) invalidation mechanisms. I'm q

Re: Improve WALRead() to suck data directly from WAL buffers when possible

2024-04-07 Thread Bharath Rupireddy
On Thu, Mar 21, 2024 at 11:33 PM Bharath Rupireddy wrote: > > Please find the v26 patches after rebasing. Commit f3ff7bf83b added a check in WALReadFromBuffers to ensure the requested WAL is not past the WAL that's copied to WAL buffers. So, I've dropped v26-0001 patch. I've attach

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

2024-04-06 Thread Bharath Rupireddy
ing the new functions like > SaveGivenReplicationSlot() and MarkGivenReplicationSlotDirty(), if we > do the required work in the caller? Hm. Removed them now. Please see the attached v38 patch. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Servi

Re: promotion related handling in pg_sync_replication_slots()

2024-04-06 Thread Bharath Rupireddy
nc worker as part of the standby promotion which might leave the slots in an inconsistent state. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: LogwrtResult contended spinlock

2024-04-06 Thread Bharath Rupireddy
ed to what's discussed in "Why is parula failing?" https://www.postgresql.org/message-id/4009739.1710878318%40sss.pgh.pa.us. It seems like parula is behaving unexpectedly because of the compiler and other stuff. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-04-06 Thread Bharath Rupireddy
ot;invalidating obsolete replication slot \"lsub1_sync_slot\"", > $standby1_logstart), > 'check that syned slot has not been invalidated on the standby'); > > Would that make sense to trigger a checkpoint on the standby before this test? > I mean I think that without a checkpoint on the standby we should not see the > invalidation in the log anyway. Done. Please find the attached v37 patch for further review. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com v37-0001-Add-inactive_timeout-based-replication-slot-inva.patch Description: Binary data

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

2024-04-04 Thread Bharath Rupireddy
he inactive timeout invalidation at slot level as opposed to InvalidateObsoleteReplicationSlots which does loop over all the slots, 2) InvalidatePossiblyObsoleteSlot does release the lock in some cases, has a lot of unneeded code for inactive timeout invalidation check, 3) we want some control over savin

Re: LogwrtResult contended spinlock

2024-04-04 Thread Bharath Rupireddy
; For 0002, did you consider having pg_atomic_monotonic_advance_u64() > return the currval? +1 for returning currval here. Except for the above comments, the patches look good to me. I've also run the test loop for any assertion failure - for i in {1..100}; do make check PROVE_TESTS="t/027_stream_r

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

2024-04-04 Thread Bharath Rupireddy
r startups/crash recovery. I've added a check to exit if the StandbyMode isn't set. Please find the attached v35 patch. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com From 03a08bd5ab3a305d199d9427491be37d1a1fd61b Mon Sep 17 00:00:

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

2024-04-03 Thread Bharath Rupireddy
tached? Thanks for the changes. v34-0001 LGTM. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-04-03 Thread Bharath Rupireddy
otSync, the inactive timeout invalidation mechanism can kick in immediately. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: LogwrtResult contended spinlock

2024-04-03 Thread Bharath Rupireddy
gress.pl"; if [ $? -ne 0 ]; then echo "The command failed on iteration $i"; break; fi; done ./configure --prefix=$PWD/pg17/ --enable-debug --enable-tap-tests --enable-cassert CC=/usr/bin/clang-14 > install.log && make -j 8 install > install.log 2>&1 & -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-04-03 Thread Bharath Rupireddy
ication_slot_inactivity_timeout, I'm fine with it. > 2) Commit msg: > a) > "It is often easy for developers to set a timeout of say 1 > or 2 or 3 days at slot level, after which the inactive slots get > dropped." > > Shall we say invalidated rather than dropped? Right. D

Re: New Table Access Methods for Multi and Single Inserts

2024-04-03 Thread Bharath Rupireddy
On Wed, Apr 3, 2024 at 2:32 PM Bharath Rupireddy wrote: > > I too prefer the latter so that the caller doesn't have to have two > paths. The new API can just transparently fallback to single inserts. > I've implemented that in the attached v17 patch. I also tested the > defaul

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

2024-04-03 Thread Bharath Rupireddy
synchronize_one_slot: @@ -584,6 +585,11 @@ synchronize_one_slot(RemoteSlot *remote_slot, Oid remote_dbid) * overwriting 'invalidated' flag to remote_slot's value. See * InvalidatePossiblyObsoleteSlot() where it invalidates slot directly * if the slot is not acquired by other processes. + * + * XXX: If it ever turns out that slot acquire/release is costly for + * cases when none of the slot property is changed then we can do a + * pre-check to ensure that at least one of the slot property is + * changed before acquiring the slot. */ ReplicationSlotAcquire(remote_slot->name, true); Please find the attached v32-0001 patch with the above review comments addressed. I'm working on review comments for 0002. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com v32-0001-Allow-synced-slots-to-have-their-own-inactive_si.patch Description: Binary data

Re: New Table Access Methods for Multi and Single Inserts

2024-04-03 Thread Bharath Rupireddy
On Wed, Apr 3, 2024 at 1:10 AM Jeff Davis wrote: > > On Sun, 2024-03-31 at 21:18 +0530, Bharath Rupireddy wrote: > > if (table_modify_buffer_insert() is defined) > >table_modify_buffer_insert(...); > > else > > { > > myState->bistate = GetBulk

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

2024-04-02 Thread Bharath Rupireddy
m to be called as *active* slots) - synced slots inactive_since is set to current timestamp after the standby gets promoted to help inactive_since interpret correctly just like any other slot. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon

Re: Synchronizing slots from primary to standby

2024-04-02 Thread Bharath Rupireddy
+if (DecodingContextReady(ctx) && found_consistent_snapshot) +*found_consistent_snapshot = true; Can the found_consistent_snapshot be checked first to help avoid the function call DecodingContextReady() for pg_replication_slot_advance callers? -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: Synchronizing slots from primary to standby

2024-04-02 Thread Bharath Rupireddy
s are + * generated. + */ +if (slot->data.database != MyDatabaseId && !fast_forward) ereport(ERROR, It's not clear from the comment that we need it for a slotsync worker to advance the slots from different databases. Can this be put into the comment? Also, speci

Re: Synchronizing slots from primary to standby

2024-04-02 Thread Bharath Rupireddy
the + * logical changes unless we are in fast-forward mode where no changes are + * generated. + */ +if (slot->data.database != MyDatabaseId && !fast_forward) May I know if we need this change for this fix? -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: [HACKERS] make async slave to wait for lsn to be replayed

2024-04-02 Thread Bharath Rupireddy
achieving read-after-write-consistency on streaming standbys in their application right now without a function like this? -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-04-02 Thread Bharath Rupireddy
on the standby for synced slots. This leads us to define actually what a slot being active means. Is syncing the data from the remote slot considered as the slot being active? On the other hand, it may not sound great if we don't invalidate synced slots due to inactive timeout even though they hold r

Re: Synchronizing slots from primary to standby

2024-04-01 Thread Bharath Rupireddy
use it for each sync worker cycle? Is there any problem with it? What do you think? -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: Synchronizing slots from primary to standby

2024-04-01 Thread Bharath Rupireddy
ving this problem reproduced consistently in a TAP test. Perhaps, we can think of adding this later after the fix is shipped. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: Synchronizing slots from primary to standby

2024-03-31 Thread Bharath Rupireddy
-d postgres -p 5433 -c "SELECT pg_is_in_recovery();" ./psql -d postgres -p 5433 -c "select * from pg_logical_slot_get_changes('lrep_sync_slot', NULL, NULL);" -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-03-31 Thread Bharath Rupireddy
9:08:26.978016+00 (1 row) Time: 21.144 ms postgres=# SELECT pg_get_current_timestamp(10); pg_get_current_timestamp --- 2024-03-30 19:08:29.142248+00 (1 row) Time: 2.269 ms postgres=# SELECT pg_get_current_timestamp(1); pg_get_current_timestamp -----

Re: [HACKERS] make async slave to wait for lsn to be replayed

2024-03-31 Thread Bharath Rupireddy
o reach this LSN. Right, but why pg_wal_replay_wait blocks without a timeout? It must return an error saying it can't reach the target LSN, no? Did you forget to attach the new patch? -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: New Table Access Methods for Multi and Single Inserts

2024-03-31 Thread Bharath Rupireddy
On Wed, Mar 27, 2024 at 1:42 PM Jeff Davis wrote: > > On Wed, 2024-03-27 at 01:19 +0530, Bharath Rupireddy wrote: > > > > Similarly, with this new AM, the onus lies on the table AM > > implementers to provide an implementation for these new AMs even if > > they j

Re: [HACKERS] make async slave to wait for lsn to be replayed

2024-03-30 Thread Bharath Rupireddy
rhaps reducing waittime to 1msec or so? 12. Why should we let every user run pg_wal_replay_wait procedure? Can't we revoke execute from the public in system_functions.sql so that one can decide who to run this function? Per comment #11, one can easily cause a lot of activity by running this function on

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

2024-03-30 Thread Bharath Rupireddy
better to > use > an Assert here and in the caller too? Done. > CR11 === > > +++ b/src/test/recovery/t/050_invalidate_slots.pl > > why not using 019_replslot_limit.pl? I understand that 019_replslot_limit covers wal_removed related invalidations. But, I don't want to kludge it wi

Re: Add new error_action COPY ON_ERROR "log"

2024-03-30 Thread Bharath Rupireddy
ameter". I don't mind adding one for LOG_VERBOSITY though. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com v14-0001-Add-new-COPY-option-LOG_VERBOSITY.patch Description: Binary data

Re: Add new error_action COPY ON_ERROR "log"

2024-03-28 Thread Bharath Rupireddy
FROM stdin WITH ( QUOTE ); ERROR: relation "t1" does not exist postgres=# COPY t1 FROM stdin WITH ( DEFAULT ); ERROR: relation "t1" does not exist postgres=# COPY t1 FROM stdin WITH ( ENCODING ); ERROR: relation "t1" does not exist -- Bharath Rupireddy PostgreS

Re: Add new error_action COPY ON_ERROR "log"

2024-03-27 Thread Bharath Rupireddy
0f1fe9f5a8e5727e46ea Author: Tom Lane Date: Thu Nov 10 18:20:49 2022 -0500 Support writing "CREATE/ALTER TABLE ... SET STORAGE DEFAULT". -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com From 26941c91ec7c2cfe92b

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

2024-03-27 Thread Bharath Rupireddy
On Wed, Mar 27, 2024 at 6:54 PM Bertrand Drouvot wrote: > > Hi, > > On Wed, Mar 27, 2024 at 05:55:05PM +0530, Bharath Rupireddy wrote: > > On Wed, Mar 27, 2024 at 3:42 PM Bertrand Drouvot > > Please see the attached v28 patch. > > Thanks! > > 1 === sorr

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

2024-03-27 Thread Bharath Rupireddy
nce we are referring to the sync cycle here, I feel it will be > good to give a link to that page. > +zero until the next slot sync cycle (see > + > for > +slot synchronization details). WFM. Please see the attached v28 patch. -- Bharath Rupireddy Postgr

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

2024-03-27 Thread Bharath Rupireddy
ed v27 patch which also has Bertrand's comment on deduplicating the TAP function. I've now moved it to Cluster.pm. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com From b4f113ef1d3467383913d0f04cc672372133420d Mon Sep 17 00:00:

Re: pgsql: Track last_inactive_time in pg_replication_slots.

2024-03-27 Thread Bharath Rupireddy
ool but I think there is no harm in giving a way to avoid > problems at the server end due to such slots. Right. I can personally connect to this problem of leftover slots where manual intervention was needed to drop all such slots which is time-consuming and painful sometimes. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-03-26 Thread Bharath Rupireddy
On Wed, Mar 27, 2024 at 10:08 AM Bharath Rupireddy wrote: > > Please find the attached v25-0001 (made this 0001 patch now as > inactive_since patch is committed) patch with the above changes. Fixed an issue in synchronize_slots where DatumGetLSN is being used in place of DatumGetTi

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

2024-03-26 Thread Bharath Rupireddy
On Wed, Mar 27, 2024 at 10:24 AM shveta malik wrote: > > On Wed, Mar 27, 2024 at 10:22 AM Amit Kapila wrote: > > > > On Wed, Mar 27, 2024 at 10:08 AM Bharath Rupireddy > > wrote: > > > > > > On Tue, Mar 26, 2024 at 11:22 PM Bert

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

2024-03-26 Thread Bharath Rupireddy
y gets promoted while others are yet-to-be-synced. > 4) > 040_standby_failover_slots_sync.pl: > > +# Capture the inactive_since of the slot from the standby the logical > failover > +# slots are synced/created on the standby. > > The comment is unclear, something seems mi

Re: New Table Access Methods for Multi and Single Inserts

2024-03-26 Thread Bharath Rupireddy
On Tue, Mar 26, 2024 at 9:07 PM Jeff Davis wrote: > > On Tue, 2024-03-26 at 01:28 +0530, Bharath Rupireddy wrote: > > I'm thinking > > of dropping the COPY FROM patch using the new multi insert API for > > the > > following reasons: ... > > I agree with a

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

2024-03-26 Thread Bharath Rupireddy
On Tue, Mar 26, 2024 at 4:35 PM Bharath Rupireddy wrote: > > If we just sync inactive_since value for synced slots while in > recovery from the primary, so be it. Why do we need to update it to > the current time when the slot is being created? We don't expose slot > creation time

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

2024-03-26 Thread Bharath Rupireddy
lots while in recovery from the primary, so be it. Why do we need to update it to the current time when the slot is being created? We don't expose slot creation time, no? Aren't we fine if we just sync the value from primary and document that fact? After the promotion, we can reset it to the current tim

Re: Add new error_action COPY ON_ERROR "log"

2024-03-26 Thread Bharath Rupireddy
On Tue, Mar 26, 2024 at 1:46 PM Masahiko Sawada wrote: > > Thank you for updating the patch! Looks good to me. > > Please find the attached patch. I've made some changes for the > documentation and the commit message. I'll push it, barring any > objections. Thanks. v12 patch

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

2024-03-26 Thread Bharath Rupireddy
; > shutdown --> shutdown of slot sync worker (as it was not clear if it > is instance shutdown or something else) Changed it to "shutdown of slot sync machinery" to be consistent with the comments. > 2) > 'The time since the slot has became inactive'. > > has bec

Re: Add new error_action COPY ON_ERROR "log"

2024-03-26 Thread Bharath Rupireddy
urrent message seems not > to be clear to me and consistent with other NOTICE messages. Also, the > last summary line would not be written if the user cancelled, and > someone other than person who used ON_ERROR 'ignore' might check the > server logs later. Agree. I

Re: pgsql: Track last_inactive_time in pg_replication_slots.

2024-03-25 Thread Bharath Rupireddy
I posted the v21 patch implementing the above idea in the other thread - https://www.postgresql.org/message-id/CALj2ACXRFx9g7A9RFJZF7eBe%3Dzxk7%3DapMRFuCgJJKYB7O%3Dvgwg%40mail.gmail.com. For ease, I'm also attaching the patch in here. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com v21-0001-Fix-review-comments-for-slot-s-last_inactive_tim.patch Description: Binary data

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

2024-03-25 Thread Bharath Rupireddy
). > The plus point of maintaining last_inactive_time for synced slots > could be, this can provide data to the user on when last time the sync > was attempted on that particular slot by background slot sync worker > or SQl function. Thoughts? Please find the attached v21 patch implement

Re: Add new error_action COPY ON_ERROR "log"

2024-03-25 Thread Bharath Rupireddy
limit_printout_length() function > but I think it's better to rename it for consistency with other > exposed COPY command functions. Only this function is snake-case. How > about CopyLimitPrintoutLength() or similar? WFM. Although its implementation is not related to COPY code, COPY is th

Re: pgsql: Track last_inactive_time in pg_replication_slots.

2024-03-25 Thread Bharath Rupireddy
e related discussions, I'm inclined to agree > that inactive_since provides the clearest description for the column. I think we all have some agreement on inactive_since. So, I'm attaching the patch for that change. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazo

Re: New Table Access Methods for Multi and Single Inserts

2024-03-25 Thread Bharath Rupireddy
c. aren't taken care of as I'm now only focusing on CTAS, CMV, RMV optimizations. Please see the attached v14 patches. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com From 2de89705c6b2d03020988db0cc8857a0bf19b38e Mon Sep 17 00:

Re: speed up a logical replica setup

2024-03-25 Thread Bharath Rupireddy
On Mon, Mar 25, 2024 at 5:25 PM Peter Eisentraut wrote: > > I have committed your version v33. Looks like BF animals aren't happy, please check - https://buildfarm.postgresql.org/cgi-bin/show_failures.pl. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amaz

Re: Add new error_action COPY ON_ERROR "log"

2024-03-25 Thread Bharath Rupireddy
tes not-null constraint DETAIL: Failing row contains (2, {2}, 2, null). CONTEXT: COPY check_ign_err3, line 2: "2 {2} 2 \N" -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com From bf0c1a166025c6ed

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

2024-03-25 Thread Bharath Rupireddy
t; promoted). > > So, I think that last_inactive_time does not make sense if the slot never had > the chance to be active. Right. Done that way i.e. not setting the last_inactive_time for slots both while releasing the slot and restoring from the disk. Also, I've added a TAP funct

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

2024-03-25 Thread Bharath Rupireddy
te_physical_replication_slot. SELECT current_timestamp FROM pg_create_physical_replication_slot('foo'); > Apart from this, I have made minor changes in the comments. See and > let me know what you think of attached. LGTM. I've merged the diff into v19 patch. Please find the attached v19 patch.

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

2024-03-24 Thread Bharath Rupireddy
ed earlier review comments from Amit, Ajin Cherian. Note that I've added new invalidation mechanism tests in a separate TAP test file just because I don't want to clutter or bloat any of the existing files and spread tests for physical slots and logical slots into separate existing TAP files. -- Bharath

Re: [HACKERS] make async slave to wait for lsn to be replayed

2024-03-23 Thread Bharath Rupireddy
e achieving) the read-after-write consistency on standbys unless there's a way for the application to tell the wait LSN. Thoughts? [1] https://www.postgresql.org/message-id/CALj2ACUfS7LH1PaWmSZ5KwH4BpQxO9izeMw4qC3a1DAwi6nfbQ%40mail.gmail.com -- Bharath Rupireddy PostgreSQL Contributors Team RDS

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

2024-03-23 Thread Bharath Rupireddy
t_limit would be a better > place, because I see the timeout as another kind of limit. Hm. Done that way. Please see the attached v17 patch. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com From a1210ae2dd86afdfdfea9b95861ffed9

Re: Switching XLog source from archive to streaming when primary available

2024-03-23 Thread Bharath Rupireddy
On Mon, Mar 18, 2024 at 11:38 AM Michael Paquier wrote: > > On Sun, Mar 17, 2024 at 11:37:58AM +0530, Bharath Rupireddy wrote: > > Rebase needed after 071e3ad59d6fd2d6d1277b2bd9579397d10ded28 due to a > > conflict in meson.build. Please see the attached v23 patch. > > I've

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

2024-03-23 Thread Bharath Rupireddy
t last_inactive_time for those as well > and later allow them to be invalidated based on timeout parameter. WFM. Done that way. Please see the attached v16 patch. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com From ce85a4

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

2024-03-22 Thread Bharath Rupireddy
ot;? Yeah, I can see that. So, I changed it to last_inactive_time. I agree with treating last_inactive_time as a separate property of the slot having its own use in addition to helping implement inactive_timeout based invalidation. I think it can go separately. I tried to address the review comment

Re: Support a wildcard in backtrace_functions

2024-03-22 Thread Bharath Rupireddy
leading to crashes eventually. This makes a strong case for marking log_backtrace a developer only function. 6. In continuation to comment #5, does anyone need backtrace for elevels like debugX and LOG etc.? What's the use of the backtrace in such cases? -- Bharath Rupireddy PostgreSQL Contributors T

Re: Improve WALRead() to suck data directly from WAL buffers when possible

2024-03-21 Thread Bharath Rupireddy
On Tue, Feb 20, 2024 at 11:40 AM Bharath Rupireddy wrote: > > Ran pgperltidy on the new TAP test file added. Please see the attached > v25 patch set. Please find the v26 patches after rebasing. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web

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

2024-03-21 Thread Bharath Rupireddy
> > I don't think we need to change the comment or success message in this test. Yes. There the intention of the test case is to verify logical slots are reported as non conflicting. So, I changed them. Please find the v14-0001 patch for now. I'll post the other patches soon.

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

2024-03-21 Thread Bharath Rupireddy
create_logical_replication_slot. AFAICS, setting it to the current timestamp in ReplicationSlotRelease suffices unless I'm missing something. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-03-21 Thread Bharath Rupireddy
ueries (which are the failover > and sync positions). Hm, yeah, I can change that in the next version of the patches. Thanks. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: New Table Access Methods for Multi and Single Inserts

2024-03-21 Thread Bharath Rupireddy
On Thu, Mar 21, 2024 at 9:44 AM Bharath Rupireddy wrote: > > Yes, usingVirtualTupleTableSlot helps improve the performance a lot. > Below are results from my testing. Note that CMV, RMV, CTAS stand for > CREATE MATERIALIZED VIEW, REFRESH MATERIALIZED VIEW, CREATE TABLE AS &g

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

2024-03-20 Thread Bharath Rupireddy
On Thu, Mar 21, 2024 at 8:47 AM Amit Kapila wrote: > > On Wed, Mar 20, 2024 at 1:51 PM Bertrand Drouvot > wrote: > > > > On Wed, Mar 20, 2024 at 12:48:55AM +0530, Bharath Rupireddy wrote: > > > > > > 2. last_inactive_at and inactive_timeout are now tracked

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

2024-03-20 Thread Bharath Rupireddy
vely, and implement pg_alter_replication_slot(). FWIW, adding the new SQL API pg_alter_replication_slot() isn't that hard. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: New Table Access Methods for Multi and Single Inserts

2024-03-20 Thread Bharath Rupireddy
* as long as the virtual tuple needs to be valid or is materialized. Note * also that a virtual tuple does not have any "system columns". -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-03-20 Thread Bharath Rupireddy
the publisher to know the inactive_timeout value for a subscription. Moreover, we are allowing the inactive_timeout to be set via CREATE/ALTER SUBSCRIPTION command, I believe there's nothing wrong if it's also part of the pg_subscription catalog. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-03-19 Thread Bharath Rupireddy
quot; to say "invalidation_cause" > in > InvalidatePossiblyObsoleteSlot()? That's inline with our understanding about conflict vs invalidation, and keeps the function generic. Will change. > 5 === > > + * rows_removed and wal_level_insufficient are only two reasons > &

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

2024-03-17 Thread Bharath Rupireddy
0, InvalidOid, InvalidTransactionId)) { ComputeXidHorizonsResult horizons; /* * Some slots have been invalidated; update the XID horizons * as a side-effect. */ ComputeXidHorizons(); } } -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

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

2024-03-17 Thread Bharath Rupireddy
t}, but this kind of GUC for setting slot level parameters is going to be the first of its kind, so I'd prefer the above approach. Thoughts? -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Simplify backtrace_functions GUC code

2024-03-17 Thread Bharath Rupireddy
in the attached patch. With this, backtrace_function_list variable and assign_backtrace_functions() will go away. Thoughts? [1] https://www.postgresql.org/message-id/CALj2ACXG1wzrb8%2B5HPNd8Qjr1h8GYkW-ijWhMYr2Y8_DzOB-%3Dg%40mail.gmail.com -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open

Re: Switching XLog source from archive to streaming when primary available

2024-03-17 Thread Bharath Rupireddy
Thanks. I'd like to spend some time testing this, but from a glance, the > code appears to be in decent shape. Rebase needed after 071e3ad59d6fd2d6d1277b2bd9579397d10ded28 due to a conflict in meson.build. Please see the attached v23 patch. -- Bharath Rupireddy PostgreSQL Contributors Team RDS O

Re: [HACKERS] make async slave to wait for lsn to be replayed

2024-03-16 Thread Bharath Rupireddy
the SQL standard for explicit txn commands (I stand for correction about the SQL standard though). -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Re: [HACKERS] make async slave to wait for lsn to be replayed

2024-03-16 Thread Bharath Rupireddy
. In continuation to comment #6, why not use Conditional Variables instead of proc latches to sleep and wait for all the waiters in WaitLSNSetLatches? -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com

Add TAP tests for backtrace functionality (was Re: Add test module for verifying backtrace functionality)

2024-03-15 Thread Bharath Rupireddy
On Tue, Feb 20, 2024 at 11:30 AM Bharath Rupireddy wrote: > > On Tue, Feb 13, 2024 at 2:11 AM Bharath Rupireddy > wrote: > > > > Hi, > > > > Postgres has a good amount of code for dealing with backtraces - two > > GUCs backtrace_functions and backtrace_o

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

2024-03-15 Thread Bharath Rupireddy
h sense > since > it's done after the primary database initialization and startup. It is now turned into a test verifying 'conflicting boolean' is null for the physical slot. Isn't that okay? > 6 === > > 'Logical slots are reported as non conflicting'); > > What about? >

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

2024-03-15 Thread Bharath Rupireddy
re ensuring the slot on the standby isn't invalidated. In general, one needs to use the 'conflicting' column from pg_replication_slots when the intention is to look for reasons for conflicts, otherwise use the 'invalidation_reason' column for invalidations. Please see the attached v10 patch set aft

Be strict when request to flush past end of WAL in WaitXLogInsertionsToFinish

2024-03-15 Thread Bharath Rupireddy
dUpto) { ereport(LOG, (errmsg("request to flush past end of generated WAL; request %X/%X, current position %X/%X", LSN_FORMAT_ARGS(upto), LSN_FORMAT_ARGS(reservedUpto; upto = reservedUpto; } -- Bharath Rupireddy Postgr

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

2024-03-14 Thread Bharath Rupireddy
tu' primary_slot_name='sb_repl_slot' restore_command='cp /home/ubuntu/postgres/pg17/bin/archived_wal/%f %p' hot_standby_feedback = on" | tee -a sbdata/postgresql.conf touch sbdata/standby.signal ./pg_ctl -D sbdata -l logfilesbdata start ./psql -d postgres -p 5433 -c "SELECT pg_is_in_recover

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

2024-03-14 Thread Bharath Rupireddy
On Thu, Mar 14, 2024 at 12:24 PM Amit Kapila wrote: > > On Wed, Mar 13, 2024 at 9:24 PM Bharath Rupireddy > > > > Yes, there will be some sort of duplicity if we emit conflict_reason > > as a text field. However, I still think the better way is to turn > > conflict_r

Re: LogwrtResult contended spinlock

2024-03-14 Thread Bharath Rupireddy
On Mon, Mar 4, 2024 at 9:15 PM Bharath Rupireddy wrote: > > > 0003: > > > > * We need to maintain the invariant that Copy >= Write >= Flush. I > > believe that's always satisfied, because the > > XLogWaitInsertionsToFinish() is always called before XLogW

  1   2   3   4   5   6   7   8   9   10   >