Re: Commit Timestamp and LSN Inversion issue

From: Jan Wieck <jan(at)wi3ck(dot)info>
To: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Aleksander Alekseev <aleksander(at)timescale(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, "tomas(at)vondra(dot)me" <tomas(at)vondra(dot)me>
Subject: Re: Commit Timestamp and LSN Inversion issue
Date: 2024-11-07 16:09:47
Message-ID: 17a7ce08-f04a-49ab-af5c-233d616d7c3b@wi3ck.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/6/24 21:30, Zhijie Hou (Fujitsu) wrote:
>
> Thanks for the patch! I am reading the patch and noticed few minor things.
>
> 1.
> + /*
> + * This is a local transaction. Make sure that the xact_time
> + * higher than any timestamp we have seen thus far.
> + *
> + * TODO: This is not postmaster restart safe. If the local
> + * system clock is further behind other nodes than it takes
> + * for the postmaster to restart (time between it stops
> + * accepting new transactions and time when it becomes ready
> + * to accept new transactions), local transactions will not
> + * be bumped into the future correctly.
> + */
>
> The TODO section mentions other nodes, but I believe think patch currently do
> not have the handling of timestamps for other nodes. Should we either remove
> this part or add a brief explanation to clarify the relationship with other
> nodes?

That TODO is actually obsolete. I understood from Amit Kapila that the
community does assume that NTP synchronization is good enough. And it
indeed is. Even my servers here at home are using a GPS based NTP server
connected to the LAN and are usually in sync by single-digit
microseconds. I removed it.

>
> 2.
> +/*
> + * Hook function to be called while holding the WAL insert spinlock.
> + * to adjust commit timestamps via Lamport clock if needed.
> + */
>
> The second line seems can be improved:
> "to adjust commit timestamps .." => "It adjusts commit timestamps ..."

How about

/*
* Hook function to be called while holding the WAL insert spinlock.
* It guarantees that commit timestamps are advancing in LSN order.
*/
static void EnsureMonotonicTransactionStopTimestamp(void *data);

Thank you for looking at this and your input. New patch attached.

Best Regards, Jan

Attachment Content-Type Size
pg18-025-logical_commit_clock.diff text/x-patch 8.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2024-11-07 16:10:24 Re: Proposal for Updating CRC32C with AVX-512 Algorithm.
Previous Message Andres Freund 2024-11-07 16:05:14 Re: Proposal for Updating CRC32C with AVX-512 Algorithm.