Skip to content

Commit a397aa4

Browse files
Fenimorkindmpgpro
authored andcommitted
FIX
1 parent 5dcd5b1 commit a397aa4

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/backend/commands/waitlsn.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,18 @@ WaitLSNSetLatch(void)
142142
void
143143
WaitLSNUtility(const char *lsn, const int delay)
144144
{
145-
XLogRecPtr trg_lsn;
146-
XLogRecPtr cur_lsn;
147-
int latch_events;
148-
int tdelay = delay;
149-
TimestampTz timer = GetCurrentTimestamp();
145+
XLogRecPtr trg_lsn;
146+
XLogRecPtr cur_lsn;
147+
int latch_events;
148+
uint_fast64_t tdelay = delay;
149+
long secs;
150+
int microsecs;
151+
TimestampTz timer = GetCurrentTimestamp();
152+
150153
trg_lsn = DatumGetLSN(DirectFunctionCall1(pg_lsn_in, CStringGetDatum(lsn)));
154+
// tdelay *= 1000;
151155

152-
tdelay *= 1000;
156+
elog(LOG,"ACHTUNG tdelay %u",tdelay);
153157

154158
if (delay > 0)
155159
latch_events = WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH;
@@ -174,9 +178,11 @@ WaitLSNUtility(const char *lsn, const int delay)
174178
/* If Delay time is over */
175179
if (latch_events & WL_TIMEOUT)
176180
{
177-
tdelay -= (GetCurrentTimestamp() - timer);
178-
if (tdelay <= 0)
181+
if (TimestampDifferenceExceeds(timer,GetCurrentTimestamp(),tdelay))
179182
break;
183+
TimestampDifference(timer,GetCurrentTimestamp(),&secs, &microsecs);
184+
tdelay -= (secs*1000 + microsecs/1000);
185+
elog(LOG,"ACHTUNG tdelay %u, %d",tdelay, TimestampDifferenceExceeds(timer,GetCurrentTimestamp(),tdelay));
180186
timer = GetCurrentTimestamp();
181187
}
182188

src/backend/tcop/utility.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ standard_ProcessUtility(Node *parsetree,
913913
"WaitLSN")));
914914
}
915915
else
916-
WaitLSNUtility(stmt->lsn, *stmt->delay);
916+
WaitLSNUtility(stmt->lsn, stmt->delay);
917917
}
918918
break;
919919

src/include/nodes/parsenodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3112,7 +3112,7 @@ typedef struct WaitLSNStmt
31123112
{
31133113
NodeTag type;
31143114
char *lsn; /* Taraget LSN to wait for */
3115-
int *delay; /* Delay to wait for LSN*/
3115+
int delay; /* Delay to wait for LSN*/
31163116
} WaitLSNStmt;
31173117

31183118
#endif /* PARSENODES_H */

0 commit comments

Comments
 (0)