From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Ibrar Ahmed <ibrar(dot)ahmad(at)gmail(dot)com>, Amit Khandekar <amitdkhan(dot)pg(at)gmail(dot)com>, fabriziomello(at)gmail(dot)com, tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>, Rahila Syed <rahila(dot)syed(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Minimal logical decoding on standbys |
Date: | 2023-03-01 00:48:44 |
Message-ID: | 2d314c22b9e03415aa1c7d8fd1f698dae60effa7.camel@j-davis.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, 2023-02-27 at 09:40 +0100, Drouvot, Bertrand wrote:
> Please find attached V51 tiny rebase due to a6cd1fc692 (for 0001) and
> 8a8661828a (for 0005).
[ Jumping into this thread late, so I apologize if these comments have
already been covered. ]
Regarding v51-0004:
* Why is the CV sleep not being canceled?
* Comments on WalSndWaitForWal need to be updated to explain the
difference between the flush (primary) and the replay (standby) cases.
Overall, it seems like what you really want for the sleep/wakeup logic
in WalSndWaitForLSN is something like this:
condVar = RecoveryInProgress() ? replayCV : flushCV;
waitEvent = RecoveryInProgress() ?
WAIT_EVENT_WAL_SENDER_WAIT_REPLAY :
WAIT_EVENT_WAL_SENDER_WAIT_FLUSH;
ConditionVariablePrepareToSleep(condVar);
for(;;)
{
...
sleeptime = WalSndComputeSleepTime(GetCurrentTimestamp());
socketEvents = WL_SOCKET_READABLE;
if (pq_is_send_pending())
socketEvents = WL_SOCKET_WRITABLE;
ConditionVariableTimedSleepOrEvents(
condVar, sleeptime, socketEvents, waitEvent);
}
ConditionVariableCancelSleep();
But the problem is that ConditionVariableTimedSleepOrEvents() doesn't
exist, and I think that's what Andres was suggesting here[1].
WalSndWait() only waits for a timeout or a socket event, but not a CV;
ConditionVariableTimedSleep() only waits for a timeout or a CV, but not
a socket event.
I'm also missing how WalSndWait() works currently. It calls
ModifyWaitEvent() with NULL for the latch, so how does WalSndWakeup()
wake it up?
Assuming I'm wrong, and WalSndWait() does use the latch, then I guess
it could be extended by having two different latches in the WalSnd
structure, and waking them up separately and waiting on the right one.
Not sure if that's a good idea though.
[1]
https://www.postgresql.org/message-id/20230106034036.2m4qnn7ep7b5ipet@awork3.anarazel.de
--
Jeff Davis
PostgreSQL Contributor Team - AWS
From | Date | Subject | |
---|---|---|---|
Next Message | Kirk Wolak | 2023-03-01 00:59:48 | Proposal: %T Prompt parameter for psql for current time (like Oracle has) |
Previous Message | Kirk Wolak | 2023-03-01 00:47:15 | Re: Proposal: %T Prompt parameter for psql for current time (like Oracle has) |