Re: Make COPY format extendable: Extract COPY TO format implementations

2025-09-20 Thread Masahiko Sawada
On Wed, Aug 13, 2025 at 11:37 PM Sutou Kouhei wrote: > > Hi, > > In > "Re: Make COPY format extendable: Extract COPY TO format implementations" > on Mon, 28 Jul 2025 22:19:36 -0700, > Masahiko Sawada wrote: > > > The fields in 1 are mostly static f

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-19 Thread Masahiko Sawada
ve a test to verify that a logical replication slot can not be > created on a standby whose primary does *not* have effective_wal_level > 'logical'? > I think no, so will add that test. > + > +# Create a logical slot on the standby, which should be succeeded > > gramm

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-19 Thread Masahiko Sawada
functional impact. But maybe we should consider > making this a bit more clear by setting > checkPoint.logicalDecodingEnabled based on wal_level in > BootStrapXLOG(). Whether we change the code or not, I think we should > add a comment to explain this code. I agree that calling IsLogicalDecodingEnabled() in BootStrapXLOG() could be quite confusing. I think we can directly set false there and add some comments for those who try to change the default wal_level value. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-18 Thread Masahiko Sawada
On Wed, Sep 10, 2025 at 11:32 PM Amit Kapila wrote: > > On Sat, Sep 6, 2025 at 3:46 AM Masahiko Sawada wrote: > > > > I've attached the updated patch that incorporated all comments I got so far. > > > > * > + /* > + * While all processes are

Re: Proposal: Conflict log history table for Logical Replication

2025-09-18 Thread Masahiko Sawada
lots and whole replication will stop. I think this table > will be created with the same privileges as the owner of a > subscription which can be either a superuser or a user with the > privileges of the pg_create_subscription role, so we can rely on such > users. We might want to

Re: Parallel heap vacuum

2025-09-18 Thread Masahiko Sawada
On Wed, Sep 17, 2025 at 5:24 PM Tomas Vondra wrote: > > > > On 9/18/25 01:18, Masahiko Sawada wrote: > > For your information, while the implementation itself is relatively > > straightforward, we're still facing one unresolved issue; the system > > doesn&#x

Re: Make COPY format extendable: Extract COPY TO format implementations

2025-09-18 Thread Masahiko Sawada
On Tue, Sep 9, 2025 at 7:41 PM Sutou Kouhei wrote: > > Hi, > > In > "Re: Make COPY format extendable: Extract COPY TO format implementations" > on Tue, 9 Sep 2025 13:15:43 -0700, > Masahiko Sawada wrote: > > >> I don't object your approach bu

CopyMultiInsertInfo.bufferedBytes is not increased in binary format cases

2025-09-18 Thread Masahiko Sawada
in binary format cases, bufferedBytes is not increased as we don't use line_buf. So we always buffer 1000 tuples regardless of tuple size. Is it intentional behavior? I could not find any related discussion on the original discussion threads. Regards, -- Masahiko Sawada Amazon Web

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-17 Thread Masahiko Sawada
On Tue, Sep 16, 2025 at 1:30 AM Amit Kapila wrote: > > On Mon, Sep 15, 2025 at 10:15 PM Masahiko Sawada > wrote: > > > > On Sun, Sep 14, 2025 at 7:55 PM Amit Kapila wrote: > > > > > > On Fri, Sep 12, 2025 at 11:18 PM Masahiko Sawada > > >

Re: Parallel heap vacuum

2025-09-17 Thread Masahiko Sawada
On Wed, Sep 17, 2025 at 4:25 AM Tomas Vondra wrote: > > On 9/8/25 17:40, Melanie Plageman wrote: > > On Wed, Aug 27, 2025 at 2:30 PM Masahiko Sawada > > wrote: > >> > >> On Tue, Aug 26, 2025 at 8:55 AM Melanie Plageman > >> wrote: >

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-17 Thread Masahiko Sawada
On Thu, Sep 11, 2025 at 9:08 PM Amit Kapila wrote: > > On Thu, Sep 11, 2025 at 11:16 PM Masahiko Sawada > wrote: > > > > On Wed, Sep 10, 2025 at 11:32 PM Amit Kapila > > wrote: > > > > > > On Sat, Sep 6, 2025 at 3:46 AM Masahiko Sawada > >

Re: psql: tab-completion support for COPY ... TO/FROM STDIN, STDOUT, and PROGRAM

2025-09-17 Thread Masahiko Sawada
does it complete the query with files names even after 'PROGRAM'? --- +static char * +_complete_from_files(const char *text, int state) { I think the comments of complete_from_files() should be moved to this new function. For instance, the comments starts with: * This function wraps rl_filename_completion_function() to strip quotes from * the input before searching for matches and to quote any matches for which * the consuming command will require it. But complete_from_files() function no longer calls rl_filename_completion_function(). --- - /* Complete COPY FROM */ - else if (Matches("COPY|\\copy", MatchAny, "FROM", MatchAny)) + /* Complete COPY FROM [PROGRAM] */ + else if (Matches("COPY|\\copy", MatchAny, "FROM", MatchAnyExcept("PROGRAM")) || +Matches("COPY|\\copy", MatchAny, "FROM", "PROGRAM", MatchAny)) I see this kind of conversion many places in the patch; convert one condition with MatchAny into two conditions with MatchAnyExcept("PROGRAM") and '"PROGRAM", MatchAny'. How about simplifying it using MatchAnyN. For example, else if (Matches("COPY|\\copy", MatchAny, "FROM", MatchAny, MatchAnyN)) Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Conflict detection for update_deleted in logical replication

2025-09-17 Thread Masahiko Sawada
e retention timeout correctly. Because these are corner cases, I > believe we should avoid over-engineering a solution and simply restart > the worker, as Amit suggested. +1 While it's ideal if workers could initialize their oldest_nonremovable_xid values on-the-fly, I believe we can begin with the simple solution given that stopping and resuming retaining of conflict info would not happen so often. In fact, frequent stops and restarts would typically be a sign that users might be not configuring the options properly for their systems. IIUC if the workers are able to do that, we can support to activate retain_conflict_info even for enabled subscriptions. I think we can leave it for future improvements if necessary. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-17 Thread Masahiko Sawada
On Wed, Sep 17, 2025 at 4:19 AM Amit Kapila wrote: > > On Tue, Sep 16, 2025 at 11:49 PM Masahiko Sawada > wrote: > > > > On Tue, Sep 16, 2025 at 1:30 AM Amit Kapila wrote: > > > > > > When user is dropping a temporary slot, we should disable the > >

Re: encode/decode support for base64url

2025-09-17 Thread Masahiko Sawada
On Wed, Sep 17, 2025 at 5:57 AM Florents Tselai wrote: > > > > On Wed, Sep 17, 2025 at 12:56 AM Masahiko Sawada > wrote: >> >> On Wed, Aug 6, 2025 at 12:43 PM Florents Tselai >> wrote: >> > >> > >> > >> > On Wed, Aug 6, 2

Re: POC: Parallel processing of indexes in autovacuum

2025-09-16 Thread Masahiko Sawada
On Mon, Sep 15, 2025 at 11:50 AM Alexander Korotkov wrote: > > Hi! > > On Tue, Aug 19, 2025 at 12:04 AM Masahiko Sawada > wrote: > > > > On Mon, Aug 18, 2025 at 1:31 AM Daniil Davydov <3daniss...@gmail.com> wrote: > > > > > > > > > O

Re: [PATCH] Add tests for Bitmapset

2025-09-16 Thread Masahiko Sawada
the API clearly. Thank you for updating the patch. It seems cfbot caught a regression test error[1] in a 32-bit build. Regards, [1] https://cirrus-ci.com/task/5290864655728640 -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: encode/decode support for base64url

2025-09-16 Thread Masahiko Sawada
, s - 1))); +errmsg("invalid symbol \"%.*s\" found while decoding %s sequence", + pg_mblen(s - 1), s - 1, + url ? "base64url" : "base64"))); The above change makes the error message mention the encoding name properly. On the other hand, in pg_base64_decode_internal() there are two places where we report invalid data and always mention 'based64' in the error message: ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unexpected \"=\" while decoding base64 sequence"))); and ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid base64 end sequence"), errhint("Input data is missing padding, is truncated, or is otherwise corrupted."))); Do we need to have a similar change for these messages? Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-15 Thread Masahiko Sawada
On Mon, Sep 8, 2025 at 11:22 PM Amit Kapila wrote: > > On Mon, Sep 8, 2025 at 11:22 PM Masahiko Sawada wrote: > > > > On Fri, Sep 5, 2025 at 9:12 PM Amit Kapila wrote: > > > > > > On Sat, Sep 6, 2025 at 3:58 AM Masahiko Sawada > > > wrote: > &g

Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue

2025-09-15 Thread Masahiko Sawada
that > and thanks very much for all the explanation! > > I'll keep on hold the development of new patch versions for this thread > and focus on review and test the patch from Rishu at [1] to see if we > can make progress using the WAL approach. While the WAL-based approac

Re: Make COPY format extendable: Extract COPY TO format implementations

2025-09-15 Thread Masahiko Sawada
On Thu, Sep 11, 2025 at 5:07 PM Sutou Kouhei wrote: > > Hi, > > In > "Re: Make COPY format extendable: Extract COPY TO format implementations" > on Thu, 11 Sep 2025 13:41:26 -0700, > Masahiko Sawada wrote: > > > I think we can use a local variable o

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-15 Thread Masahiko Sawada
On Sun, Sep 14, 2025 at 7:55 PM Amit Kapila wrote: > > On Fri, Sep 12, 2025 at 11:18 PM Masahiko Sawada > wrote: > > > > On Thu, Sep 11, 2025 at 9:08 PM Amit Kapila wrote: > > > > > > > > For the shutdown sequence, can't we think of resetting

Re: PostgreSQL 18 GA press release draft

2025-09-12 Thread Masahiko Sawada
statement and a draft quote. > > As per above, I'll need remaining feedback no later than 2025-09-14 0:00 > UTC - after this, it's frozen for the translation process to begin. > I found a typo; s/gen_rand_uuid()/gen_random_uuid()/ Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Proposal: Out-of-Order NOTIFY via GUC to Improve LISTEN/NOTIFY Throughput

2025-09-12 Thread Masahiko Sawada
longer need to have a pair of page number and offset number as an entry queue's position since AsyncQueueEntry is now a fixed size. > BTW, what do you think about creating a separate thread for the patch? > The current thread's subject seems a bit irrelevant. +1 Regards,

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-11 Thread Masahiko Sawada
On Thu, Sep 11, 2025 at 10:46 AM Masahiko Sawada wrote: > > On Wed, Sep 10, 2025 at 11:32 PM Amit Kapila wrote: > > > > On Sat, Sep 6, 2025 at 3:46 AM Masahiko Sawada > > wrote: > > > > > > I've attached the updated patch tha

Re: Add memory_limit_hits to pg_stat_replication_slots

2025-09-11 Thread Masahiko Sawada
calDecodingContext *ctx) repSlotStat.stream_bytes = rb->streamBytes; repSlotStat.total_txns = rb->totalTxns; repSlotStat.total_bytes = rb->totalBytes; + repSlotStat.memory_limit_hits = rb->memory_limit_hits; Since other statistics counter names are camel cases I think it's better to follow that for the new counter. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Make COPY format extendable: Extract COPY TO format implementations

2025-09-11 Thread Masahiko Sawada
On Wed, Sep 10, 2025 at 10:46 PM Sutou Kouhei wrote: > > Hi, > > In > "Re: Make COPY format extendable: Extract COPY TO format implementations" > on Wed, 10 Sep 2025 00:36:38 -0700, > Masahiko Sawada wrote: > > > How about another idea like

Re: [PATCH] Add tests for Bitmapset

2025-09-10 Thread Masahiko Sawada
I agree that adding more tests to bitmapset.c is a good idea, I'm concerned about the minimal improvement in test coverage despite the addition of new test cases (only three lines of code are newly covered). Apart from adding some randomness to the tests we've discussed, given that we're implementing a dedicated test module for bitmapset.c, I would expect to see a more increase in test coverage. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Proposal: Out-of-Order NOTIFY via GUC to Improve LISTEN/NOTIFY Throughput

2025-09-10 Thread Masahiko Sawada
if a > transaction that it reads > has indeed committed, but it is possible that the portion of the > transaction log has > been truncated by vacuum. With your patch, since the backends get the notification by reading WAL records do we need to prevent WAL records that potentially have unconsumed notification from being removed by the checkpointer? Or we can save unconsumed notifications in WAL records to somewhere during the checkpoint as we do for 2PC transactions. Also, could you add this patch to the next commit fest[1] if not yet? Regards, [1] https://commitfest.postgresql.org/56/ -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Clear logical slot's 'synced' flag on promotion of standby

2025-09-09 Thread Masahiko Sawada
e * 'synced' column as true after promotion as it may provide useful * information about the slot origin. */ ShutDownSlotSync(); Does the patch address the above concerns? Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Make COPY format extendable: Extract COPY TO format implementations

2025-09-09 Thread Masahiko Sawada
On Mon, Sep 8, 2025 at 7:50 PM Sutou Kouhei wrote: > > Hi, > > In > "Re: Make COPY format extendable: Extract COPY TO format implementations" > on Mon, 8 Sep 2025 14:08:16 -0700, > Masahiko Sawada wrote: > > >> > The fields in 1 are m

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-09 Thread Masahiko Sawada
On Mon, Sep 8, 2025 at 11:34 PM Amit Kapila wrote: > > On Mon, Sep 8, 2025 at 11:14 PM Masahiko Sawada wrote: > > > > On Fri, Sep 5, 2025 at 8:50 PM Amit Kapila wrote: > > > > > > On Thu, Sep 4, 2025 at 1:24 AM Masahiko Sawada

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-08 Thread Masahiko Sawada
On Fri, Sep 5, 2025 at 9:12 PM Amit Kapila wrote: > > On Sat, Sep 6, 2025 at 3:58 AM Masahiko Sawada wrote: > > > > On Tue, Sep 2, 2025 at 5:12 AM Shlok Kyal wrote: > > > > > > > > > I tested the behaviour with HEAD and with Patch. And I confirmed t

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-08 Thread Masahiko Sawada
On Fri, Sep 5, 2025 at 8:50 PM Amit Kapila wrote: > > On Thu, Sep 4, 2025 at 1:24 AM Masahiko Sawada wrote: > > > > On Tue, Sep 2, 2025 at 4:35 AM Amit Kapila wrote: > > > > > > On Fri, Aug 29, 2025 at 9:38 AM Masahiko Sawada > > > wrote: &g

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-05 Thread Masahiko Sawada
On Fri, Sep 5, 2025 at 3:15 PM Masahiko Sawada wrote: > > On Thu, Sep 4, 2025 at 11:15 AM Masahiko Sawada wrote: > > > > od On Tue, Sep 2, 2025 at 8:11 PM Hayato Kuroda (Fujitsu) > > wrote: > > > > > > Dear Sawada-san, > &

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-05 Thread Masahiko Sawada
HEAD, after we restart the primary server with 'wal_level = > replica', the slot sync worker can restart and connect to the primary > but with patch it cannot start after restart due to the check in > ValidateSlotSyncParams. But the slotsync worker is launched again once logical decoding is enabled, no? I'm not sure that we want to launch the slotsync worker also when we know logical decoding is not enabled. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-05 Thread Masahiko Sawada
On Thu, Sep 4, 2025 at 11:15 AM Masahiko Sawada wrote: > > od On Tue, Sep 2, 2025 at 8:11 PM Hayato Kuroda (Fujitsu) > wrote: > > > > Dear Sawada-san, > > > > Here are my comments. > > > > 01. > > ``` > > checkPoint.logicalDecoding

Re: Logical Replication of sequences

2025-09-04 Thread Masahiko Sawada
lar to the case where we launch an apply worker even for a subscription corresponding to empty publications. It would be quite a rare case in practice where publications have only sequences. I guess that it would rather simplify the patch if we can cut the part of doing the sync during the command (i.

Re: Logical Replication of sequences

2025-09-04 Thread Masahiko Sawada
gt; > } > > > > search_pos++; > > } > > ``` > > > > It looks like that if the entry in sequences_to_copy is skipped, it won't be > > referred anymore. I feel this

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-04 Thread Masahiko Sawada
would stop at the loop in > start_logical_decoding_status_change(). > 10. detached from the startup process. It would wait all processes handled the > signal, but the backend won't do. Good find! I'll fix the problem by adding CHECK_FOR_INTERRUPTS() as you suggested. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-09-04 Thread Masahiko Sawada
On Tue, Sep 2, 2025 at 4:35 AM Amit Kapila wrote: > > On Fri, Aug 29, 2025 at 9:38 AM Masahiko Sawada wrote: > > > > I've attached the updated patch. > > > > Few comments: Thank you for the comments! > = > 1. > + * When XLogL

Re: Use LW_SHARED in WakeupWalSummarizer() for WALSummarizerLock lock

2025-08-29 Thread Masahiko Sawada
On Mon, Aug 25, 2025 at 5:48 PM Masahiko Sawada wrote: > > On Mon, Aug 25, 2025 at 5:08 PM Nathan Bossart > wrote: > > > > On Mon, Aug 25, 2025 at 03:38:13PM -0700, Masahiko Sawada wrote: > > > While reading walsummarizer.c code, I noticed that in > > &g

Re: doc patch: missing tags in protocol.sgml

2025-08-29 Thread Masahiko Sawada
[1] https://www.postgresql.org/docs/17/protocol-logical-replication.html#PROTOCOL-LOGICAL-REPLICATION-PARAMS -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-29 Thread Masahiko Sawada
es a logical slot. I think that it's prudent to mention the minimum requirement to enable logical decoding in the hint. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-29 Thread Masahiko Sawada
heck whether a process can start logical decoding, but doesn't cover already running logical decoding processes. The slot invalidation mechanism is responsible for that. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-28 Thread Masahiko Sawada
On Thu, Aug 28, 2025 at 4:29 AM shveta malik wrote: > > On Wed, Aug 27, 2025 at 12:12 PM Masahiko Sawada > wrote: > > > > On Tue, Aug 26, 2025 at 2:32 AM shveta malik wrote: > > > > > > On Tue, Aug 26, 2025 at 12:54 AM Masahiko Sawada > > >

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-28 Thread Masahiko Sawada
> > DETAIL: User was using a logical replication slot that must be > > > invalidated. > > > ``` > > > > > > Can we stop the sync worker before updating the status? IIUC this is one > > > of the > > > solution. > > > > I think it would lead to another race condition; the slotsync worker > > can start again before updating the status. > > Hmm, okay. > > Another small comment: this data structure is not used in other files, no > need to set extern. > > ``` > extern LogicalDecodingCtlData *LogicalDecodingCtl; > ``` Removed. I've attached the updated patch. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com v12-0001-Enable-logical-decoding-dynamically-based-on-log.patch Description: Binary data

Re: doc patch: missing tags in protocol.sgml

2025-08-28 Thread Masahiko Sawada
. > Also, the first "streaming" can have a link to the pgoutput's manual. > Attached patch fixes like that. Looks good to me. I'm going to push the patch, barring any objections. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Report reorder buffer size

2025-08-27 Thread Masahiko Sawada
On Tue, Aug 26, 2025 at 2:45 AM Ashutosh Bapat wrote: > > Hi Masahiko, > Thanks for your inputs. > > On Tue, Aug 26, 2025 at 2:17 AM Masahiko Sawada wrote: > > > On Wed, Aug 13, 2025 at 5:40 AM Ashutosh Bapat > > wrote: > > > > Thank you for starting t

Re: Support getrandom() for pg_strong_random() source

2025-08-27 Thread Masahiko Sawada
On Tue, Aug 26, 2025 at 12:42 AM Daniel Gustafsson wrote: > > > On 26 Aug 2025, at 00:38, Jacob Champion > > wrote: > > > > On Mon, Aug 25, 2025 at 3:22 PM Masahiko Sawada > > wrote: > >> > >> For instance, we could > >> intro

Re: Parallel heap vacuum

2025-08-27 Thread Masahiko Sawada
On Tue, Aug 26, 2025 at 8:55 AM Melanie Plageman wrote: > > On Wed, Jul 23, 2025 at 12:06 PM Andres Freund wrote: > > > > On 2025-07-22 11:44:29 -0700, Masahiko Sawada wrote: > > > Do you think it makes sense to implement the above idea that we launch > > &

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-27 Thread Masahiko Sawada
logical slot on the primary server. > CONTEXT: WAL redo at 0/03B8 for XLOG/LOGICAL_DECODING_STATUS_CHANGE: > false > ERROR: canceling statement due to conflict with recovery > DETAIL: User was using a logical replication slot that must be invalidated. > ``` > > Can we stop the sync worker before updating the status? IIUC this is one of > the > solution. I think it would lead to another race condition; the slotsync worker can start again before updating the status. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-26 Thread Masahiko Sawada
On Tue, Aug 26, 2025 at 2:32 AM shveta malik wrote: > > On Tue, Aug 26, 2025 at 12:54 AM Masahiko Sawada > wrote: > > > > I've attached the updated patch that incorporated the comments and is > > rebased to the current HEAD. > > > > Thanks for the

Re: Use LW_SHARED in WakeupWalSummarizer() for WALSummarizerLock lock

2025-08-25 Thread Masahiko Sawada
On Mon, Aug 25, 2025 at 5:08 PM Nathan Bossart wrote: > > On Mon, Aug 25, 2025 at 03:38:13PM -0700, Masahiko Sawada wrote: > > While reading walsummarizer.c code, I noticed that in > > WakeupWalSummarizer() we acquire the WALSummarizerLock lock in > > LW_EXCLUSIVE m

Re: Parallel heap vacuum

2025-08-25 Thread Masahiko Sawada
clined toward the latter solution, though I have yet to implement it. I welcome any feedback on these approaches. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Use LW_SHARED in WakeupWalSummarizer() for WALSummarizerLock lock

2025-08-25 Thread Masahiko Sawada
rds, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com v1-0001-Use-LW_SHARED-in-WakeupWalSummarizer-for-WALSumma.patch Description: Binary data

Re: Support getrandom() for pg_strong_random() source

2025-08-25 Thread Masahiko Sawada
On Mon, Aug 25, 2025 at 1:07 PM Jacob Champion wrote: > > On Mon, Aug 25, 2025 at 11:30 AM Masahiko Sawada > wrote: > > > Gathering a couple of considerations from upthread: > > > - FIPS behavior > > > > Do you mean random numbers generated by getra

Re: Report reorder buffer size

2025-08-25 Thread Masahiko Sawada
the effectiveness of the filters they set. > If we are going > to report so much statistics about the contents of the reorder buffer, > is it better to have a separate view pg_stat_reorder_buffer for the > same? Given logical decoding can be used also by regular backend processes,

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-25 Thread Masahiko Sawada
can allow use of "sync_replication_slots" > = on when wal_level >= replica as standby will be dependent on > effective_wal_level on primary. Thoughts? > I also see that with patch, the use of pg_sync_replication_slots() > works with wal_level = replica. Good point. I ag

Re: Support getrandom() for pg_strong_random() source

2025-08-25 Thread Masahiko Sawada
On Mon, Aug 18, 2025 at 8:38 AM Jacob Champion wrote: > > On Thu, Aug 14, 2025 at 3:16 PM Masahiko Sawada wrote: > > > > On Fri, Aug 8, 2025 at 3:37 PM Jacob Champion > > wrote: > > > > > So, my next question: is getrandom() always preferable to /dev/ur

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-22 Thread Masahiko Sawada
On Thu, Aug 21, 2025 at 8:11 PM shveta malik wrote: > > On Thu, Aug 21, 2025 at 10:34 PM Masahiko Sawada > wrote: > > > > On Wed, Aug 20, 2025 at 3:11 AM shveta malik wrote: > > > > > > Please find a few comments: > > > > T

Re: memory leak in logical WAL sender with pgoutput's cachectx

2025-08-21 Thread Masahiko Sawada
aintain such a list when in practice it may be > required only very few times. Yeah, something like clock-sweep could work too. I think we need to carefully select the cache management algorithm. While it's a well known fact that maintaining LRU ordering is expensive, I'm really not sure the clock-sweep is a suitable algorithm for logical replication's cache use cases. Also, we might want to avoid iterating all caches to find caches to evict. Regards, [1] https://www.postgresql.org/message-id/20161219.201505.11562604.horiguchi.kyotaro%40lab.ntt.co.jp -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue

2025-08-21 Thread Masahiko Sawada
xid, age(datfrozenxid) from pg_database" datname | datfrozenxid | age ---+--+- postgres | 1759 | 11 template0 | 1759 | 11 template1 | 1759 | 11 (3 rows) 7. On the first psql session: -- Session 1 =# commit; COMMIT ERROR: could not access status of transaction 756 DETAIL: Could not open file "pg_xact/": No such file or directory. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Logical Replication of sequences

2025-08-21 Thread Masahiko Sawada
On Wed, Aug 20, 2025 at 9:04 PM Amit Kapila wrote: > > On Wed, Aug 20, 2025 at 11:00 PM Masahiko Sawada > wrote: > > > > On Tue, Aug 19, 2025 at 9:14 PM Amit Kapila wrote: > > > > > > If so, I don't think we can do much with the design > > >

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-21 Thread Masahiko Sawada
On Thu, Aug 21, 2025 at 3:50 AM Shlok Kyal wrote: > > On Fri, 15 Aug 2025 at 04:38, Masahiko Sawada wrote: > > > > On Tue, Aug 12, 2025 at 1:26 AM Shlok Kyal wrote: > > > > > > > > > Hi Sawada-san, > > > > > > I have reviewed the pa

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-21 Thread Masahiko Sawada
t. > > 6) > > +test_wal_level($primary, "replica|replica", > + "effective_wal_level got decreased to 'replica' on primary"); > +test_wal_level($standby3, "logical|replica", > + "effective_wal_level got decreased to 'replica' on standby"); > +test_wal_level($cascade, "replica|replica", > + "effective_wal_level got decreased to 'logical' on standby"); > + > > Last one should also say: decreased to 'replica' (instead of logical) Fixed. I've attached the updated patch. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com v8-0001-Enable-logical-decoding-dynamically-based-on-logi.patch Description: Binary data

Re: Logical Replication of sequences

2025-08-20 Thread Masahiko Sawada
On Tue, Aug 19, 2025 at 9:14 PM Amit Kapila wrote: > > On Tue, Aug 19, 2025 at 11:33 PM Masahiko Sawada > wrote: > > > > On Tue, Aug 19, 2025 at 1:44 AM vignesh C wrote: > > > > > > > > > Case 2: Sequence value Conflict While Applyi

Re: memory leak in logical WAL sender with pgoutput's cachectx

2025-08-19 Thread Masahiko Sawada
exceeds a predetermined size. While this approach would minimize the overhead of freeing invalidated entries, it would incur some additional cost for maintaining the list. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Conflict detection for update_deleted in logical replication

2025-08-19 Thread Masahiko Sawada
On Sun, Aug 17, 2025 at 10:06 PM Amit Kapila wrote: > > On Sat, Aug 16, 2025 at 5:15 AM Masahiko Sawada wrote: > > > > Regarding the subscription-level option vs. GUC, I don't disagree with > > the current approach. > > > > For the record, while I ag

Re: Add CHECK_FOR_INTERRUPTS in pg_buffercache_pages while scanning the buffers

2025-08-19 Thread Masahiko Sawada
On Mon, Aug 18, 2025 at 11:59 AM SATYANARAYANA NARLAPURAM wrote: > > > > On Fri, Aug 15, 2025 at 12:04 PM Masahiko Sawada > wrote: >> >> On Fri, Aug 15, 2025 at 2:33 AM SATYANARAYANA NARLAPURAM >> wrote: >> > >> > Hi Masahiko, >&g

Re: Logical Replication of sequences

2025-08-19 Thread Masahiko Sawada
On Tue, Aug 19, 2025 at 1:44 AM vignesh C wrote: > > On Tue, 19 Aug 2025 at 06:47, Masahiko Sawada wrote: > > > > On Mon, Aug 18, 2025 at 4:21 PM Masahiko Sawada > > wrote: > > > > > > For example, if a sequence is dropped > > > on the publis

Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue

2025-08-19 Thread Masahiko Sawada
ue entries aren't ordered by XID, and it's possible for a notification with an older XID to be positioned at the queue's head. If vacuum freeze then truncates the corresponding clogs, listeners attempting to retrieve this notification would fail to obtain the transaction status. To add

Re: Logical Replication of sequences

2025-08-18 Thread Masahiko Sawada
On Mon, Aug 18, 2025 at 4:21 PM Masahiko Sawada wrote: > > For example, if a sequence is dropped > on the publisher, the subscriber would encounter synchronization > failures unless the DROP SEQUENCE is properly applied. This example is wrong. It seems DROP SEQUENCE works but w

Re: Logical Replication of sequences

2025-08-18 Thread Masahiko Sawada
On Mon, Aug 18, 2025 at 2:13 AM vignesh C wrote: > > On Sat, 16 Aug 2025 at 14:15, Masahiko Sawada wrote: > > > > As I understand it, the logical replication of sequences implemented > > by these patches shares the same user interface as table replication > > (ut

Re: POC: Parallel processing of indexes in autovacuum

2025-08-18 Thread Masahiko Sawada
On Mon, Aug 18, 2025 at 1:31 AM Daniil Davydov <3daniss...@gmail.com> wrote: > > > On Fri, Aug 15, 2025 at 3:41 AM Masahiko Sawada wrote: > > > > > 2. when an autovacuum worker (not parallel vacuum worker) who uses > > parallel vacuum gets SIGHUP,

Re: Logical Replication of sequences

2025-08-16 Thread Masahiko Sawada
check has been removed from > >LogicalRepSyncSequences() and added to copy_sequences() for the > >SetSequence() call. > > > >However, IIUC, the same check is also needed in > >LogicalRepSyncSequences(). Currently, the sequencesync worker can fail > >in the above

Re: Fix typos in comments in worker.c and execReplication.c

2025-08-16 Thread Masahiko Sawada
introduced these typos. > Please take a look at the attached patch. Thank you for the patch! I've just pushed it. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Conflict detection for update_deleted in logical replication

2025-08-15 Thread Masahiko Sawada
not merge these two parameters? For example, setting max_conflict_retention_duration=-1 means to disable retaining dead tuples behavior and =0 means that dead tuples are retained until they are no longer needed for detection purposes. --- + /* +* Only the leader apply worker manages

Re: Add CHECK_FOR_INTERRUPTS in pg_buffercache_pages while scanning the buffers

2025-08-15 Thread Masahiko Sawada
On Fri, Aug 15, 2025 at 2:33 AM SATYANARAYANA NARLAPURAM wrote: > > Hi Masahiko, > > On Thu, Aug 14, 2025 at 4:57 PM Masahiko Sawada wrote: >> >> On Fri, Aug 8, 2025 at 2:59 PM Masahiko Sawada wrote: >> > >> > On Thu, Jul 31, 2025 at 4:

Re: Fix for typo in UUIDv7 timestamp extraction

2025-08-15 Thread Masahiko Sawada
On Fri, Aug 15, 2025 at 11:44 AM Masahiko Sawada wrote: > > On Thu, Aug 14, 2025 at 5:10 AM Erik Nordström wrote: > > > > > > > > On Wed, Aug 13, 2025 at 11:52 AM Andrey Borodin > > wrote: > >> > >> Hi Erik! > >> > >> &g

Re: Fix for typo in UUIDv7 timestamp extraction

2025-08-15 Thread Masahiko Sawada
; > calculation is still correct. >> >> Wow, that's a very good level of proofreading! Yes, you are correct, it's >> must be US_PER_MS. >> >> > >> > Anyway, attaching a patch to fix this typo. >> >> LGTM. > > > Ok, maybe a

Re: memory leak in logical WAL sender with pgoutput's cachectx

2025-08-15 Thread Masahiko Sawada
es need to be replicated to the subscriber? It seems to me that if tables are present in short periods of time, we can use temp tables instead unless these changes need to be replicated to the subscribers. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: memory leak in logical WAL sender with pgoutput's cachectx

2025-08-15 Thread Masahiko Sawada
relation whose change is being sent but does for other relations. It seems to me too aggressive to release caches compared to the current behavior. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: memory leak in logical WAL sender with pgoutput's cachectx

2025-08-15 Thread Masahiko Sawada
once the entry is no longer in use. This approach is > inspired from the relcache invalidation. I am slightly not sure if it's worth > the effort, but just share this idea with a POC patch for reference, which has > been modified based on Kuroda-San's version. IIUC the pat

Re: Add CHECK_FOR_INTERRUPTS in pg_buffercache_pages while scanning the buffers

2025-08-14 Thread Masahiko Sawada
On Fri, Aug 8, 2025 at 2:59 PM Masahiko Sawada wrote: > > On Thu, Jul 31, 2025 at 4:31 PM SATYANARAYANA NARLAPURAM > wrote: > > > > Please find attached patch that adds CHECK_FOR_INTERRUPTS while scanning > > the buffers in pg_buffercache_pages. I checked other funct

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-14 Thread Masahiko Sawada
are invalidated on the standby. > With patch this behaviour can be indirectly controlled by a temporary > slot. Is it fine? Thoughts? Your understanding is correct. I've discussed whether we need a way to keep auto-increased 'logical' WAL level on the primary when standbys have logical slots. You mentioned temporary logical slots cases but I think the same is true for the case where users accidentally drop the last logical slot. My understanding is that it's fine that logical decoding availability on standbys is controlled by primary's logical slots (including temp slots) presence. This essentially is the same behavior as the current one and users who are concerned about indirectly invalidating the logical slots on standbys can set wal_level to 'logical' on the primary. It's a separate discussion (and patch) whether we need to provide a way for users to keep auto-increased 'logical' WAL level on the primary. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Support getrandom() for pg_strong_random() source

2025-08-14 Thread Masahiko Sawada
On Fri, Aug 8, 2025 at 3:37 PM Jacob Champion wrote: > > On Fri, Aug 8, 2025 at 3:25 PM Masahiko Sawada wrote: > > On the other hand, I found a blog post[3] (10 years-old post) that on > > Solaris the output of getentropy() should not be used where randomness > > is n

Re: Support getrandom() for pg_strong_random() source

2025-08-14 Thread Masahiko Sawada
er than other methods. For larger bytes (such 1024), openssl had the best performance. This fact is very attractive to me in terms of using it for UUID generation. Regards, [1] https://dotat.at/@/2024-10-01-getentropy.html -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com bench.c Description: Binary data

Re: POC: Parallel processing of indexes in autovacuum

2025-08-14 Thread Masahiko Sawada
On Thu, Aug 7, 2025 at 4:38 PM Masahiko Sawada wrote: > > On Mon, Jul 21, 2025 at 11:45 PM Daniil Davydov <3daniss...@gmail.com> wrote: > > > > Hi, > > > > On Mon, Jul 21, 2025 at 11:40 PM Sami Imseih wrote: > > > > > > I have only revie

Re: Dropping publication breaks logical replication

2025-08-13 Thread Masahiko Sawada
nge. I'm not sure if there are any users who aware of this behavior and depend on it, but it seems to me that for users who update to a new minor version having this change, the problem will simply change from that replication stops due to missing publications to that replication can continue but they will almost silently lose some changes (users often don't see warnings in server logs). I guess dealing with the latter problem would be more difficult. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Support getrandom() for pg_strong_random() source

2025-08-08 Thread Masahiko Sawada
-src/blob/main/lib/libc/gen/getentropy.c [3] https://blogs.oracle.com/solaris/post/solaris-new-system-calls-getentropy2-and-getrandom2 -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: Add CHECK_FOR_INTERRUPTS in pg_buffercache_pages while scanning the buffers

2025-08-08 Thread Masahiko Sawada
. Thank you for the patch! I think the patch is reasonable and it looks good to me. I'll push it to master early next week, barring objections. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: Parallel processing of indexes in autovacuum

2025-08-07 Thread Masahiko Sawada
adjust_free_parallel_workers() but av_freeParallelWorkers remains 0, and the autovacuum worker increments it by 5 as its autovacuum_max_parallel_workers value is still 5. I think that we can have the autovacuum_max_parallel_workers value on shmem, and only the launcher process can modify its value if the GUC is changed. Autovacuum workers simply increase or decrease the av_freeParallelWorkers within the range of 0 and the autovacuum_max_parallel_workers value on shmem. When changing autovacuum_max_parallel_workers and av_freeParallelWorkers values on shmem, the launcher process calculates the number of workers reserved at that time and calculate the new av_freeParallelWorkers value by subtracting the new autovacuum_max_parallel_workers by the number of reserved workers. --- +AutoVacuumReserveParallelWorkers(int nworkers) +{ + int can_launch; How about renaming it to 'nreserved' or something? can_launch looks like it's a boolean variable to indicate whether the process can launch workers. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-07 Thread Masahiko Sawada
he system. > > The comment is not completely true, shall we amend the comment to say > something like: > > This function is called after a logical slot is dropped, but it only > disables logical decoding on primary if it was the last remaining > logical slot and wal_level < logical. Otherwise, it performs no > action. Thank you for the suggestion. I modified the comment based on the suggestion > > 10) > When we try to create or drop a logical slot on standby, and if > delay_status_change is false, shall we immediately exit? Currently it > does a lot of checks including CheckLogicalSlotExists() which can be > completely avoided. I think it is worth having a quick > 'RecoveryInProgress() && !delay_status_change' check in the beginning. Yeah, we can simplify the start_logical_decoding_status_change() logic more. I've attached the updated patch. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com v7-0001-Enable-logical-decoding-dynamically-based-on-logi.patch Description: Binary data

Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

2025-08-05 Thread Masahiko Sawada
On Tue, Aug 5, 2025 at 3:11 AM shveta malik wrote: > > On Tue, Aug 5, 2025 at 5:14 AM Masahiko Sawada wrote: > > > > On Mon, Aug 4, 2025 at 3:38 AM shveta malik wrote: > > > > > > On Sat, Aug 2, 2025 at 4:53 AM Masahiko Sawada > > > wrote: &g

Re: Convert varatt.h macros to static inline functions

2025-08-05 Thread Masahiko Sawada
On Tue, Aug 5, 2025 at 3:07 PM Masahiko Sawada wrote: > > On Tue, Aug 5, 2025 at 2:39 PM Tom Lane wrote: > > > > Masahiko Sawada writes: > > > On Tue, Aug 5, 2025 at 1:59 PM Tom Lane wrote: > > >> Maybe there's some strange cross-distro differen

Re: Convert varatt.h macros to static inline functions

2025-08-05 Thread Masahiko Sawada
On Tue, Aug 5, 2025 at 2:39 PM Tom Lane wrote: > > Masahiko Sawada writes: > > On Tue, Aug 5, 2025 at 1:59 PM Tom Lane wrote: > >> Maybe there's some strange cross-distro difference here, but > >> what I'm wondering is if there's a difference i

Re: Convert varatt.h macros to static inline functions

2025-08-05 Thread Masahiko Sawada
On Tue, Aug 5, 2025 at 1:59 PM Tom Lane wrote: > > Masahiko Sawada writes: > > On Tue, Aug 5, 2025 at 11:34 AM Tom Lane wrote: > >> Interesting. I did not see such warnings with gcc 14.3.1, 15.1.1, > >> nor older gcc versions. Must be something peculiar to 1

Re: Convert varatt.h macros to static inline functions

2025-08-05 Thread Masahiko Sawada
On Tue, Aug 5, 2025 at 11:34 AM Tom Lane wrote: > > Masahiko Sawada writes: > > I got the following compiler warning: > > > % make -C src/backend/storage/large_object > > inv_api.c: In function ‘inv_write’: > > inv_api.c:565:29: warning: ‘workbuf’ may b

Re: Add backup_type to pg_stat_progress_basebackup

2025-08-05 Thread Masahiko Sawada
On Mon, Aug 4, 2025 at 1:57 AM Yugo Nagata wrote: > > On Fri, 1 Aug 2025 16:12:15 -0700 > Masahiko Sawada wrote: > > > The patch seems reasonably simple and looks good to me. I've updated > > the comment in bbsink_progress_new() and attached the modified versi

  1   2   3   4   5   6   7   8   9   10   >