Skip to content

Commit f9900fa

Browse files
fix(replication): correct Postgres epoch constant (946684800000 instead of 946080000000) (#4002)
1 parent 135c7e9 commit f9900fa

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

internal-packages/replication/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export class LogicalReplicationClient {
363363
} else if (buffer[0] === 0x6b) {
364364
// Primary keepalive message
365365
const timestamp = Math.floor(
366-
buffer.readUInt32BE(9) * 4294967.296 + buffer.readUInt32BE(13) / 1000 + 946080000000
366+
buffer.readUInt32BE(9) * 4294967.296 + buffer.readUInt32BE(13) / 1000 + 946684800000
367367
);
368368
const shouldRespond = !!buffer.readInt8(17);
369369
this.events.emit("heartbeat", { lsn, timestamp, shouldRespond });
@@ -658,7 +658,7 @@ export class LogicalReplicationClient {
658658
const slice = lsn.split("/");
659659
let [upperWAL, lowerWAL]: [number, number] = [parseInt(slice[0], 16), parseInt(slice[1], 16)];
660660
// Timestamp as microseconds since midnight 2000-01-01
661-
const now = Date.now() - 946080000000;
661+
const now = Date.now() - 946684800000;
662662
const upperTimestamp = Math.floor(now / 4294967.296);
663663
const lowerTimestamp = Math.floor(now - upperTimestamp * 4294967.296);
664664
if (lowerWAL === 4294967295) {

0 commit comments

Comments
 (0)