RE: Perform streaming logical transactions by background workers and parallel apply

From: "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: "wangw(dot)fnst(at)fujitsu(dot)com" <wangw(dot)fnst(at)fujitsu(dot)com>
Cc: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, "shiy(dot)fnst(at)fujitsu(dot)com" <shiy(dot)fnst(at)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>
Subject: RE: Perform streaming logical transactions by background workers and parallel apply
Date: 2022-08-10 02:11:21
Message-ID: TYAPR01MB5866F35F22C8A8050F2B1C41F5659@TYAPR01MB5866.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Wang,

> 6.a
>
> It seems that the upper line represents the apply background worker, but I think
> last_msg_send_time and last_msg_receipt_time should be null.
> Is it like initialization mistake?

I checked again about the issue.

Attributes worker->last_send_time, worker->last_recv_time, and worker->reply_time
are initialized in logicalrep_worker_launch():

```
...
TIMESTAMP_NOBEGIN(worker->last_send_time);
TIMESTAMP_NOBEGIN(worker->last_recv_time);
worker->reply_lsn = InvalidXLogRecPtr;
TIMESTAMP_NOBEGIN(worker->reply_time);
...
```

And the macro is defined in timestamp.h, and it seems that the values are initialized as PG_INT64_MIN.

```
#define DT_NOBEGIN PG_INT64_MIN
#define DT_NOEND PG_INT64_MAX

#define TIMESTAMP_NOBEGIN(j) \
do {(j) = DT_NOBEGIN;} while (0)
```

However, in pg_stat_get_subscription(), these values are regarded as null if they are zero.

```
if (worker.last_send_time == 0)
nulls[4] = true;
else
values[4] = TimestampTzGetDatum(worker.last_send_time);
if (worker.last_recv_time == 0)
nulls[5] = true;
else
values[5] = TimestampTzGetDatum(worker.last_recv_time);
```

I think above lines are wrong, these values should be compared with PG_INT64_MIN.

Best Regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2022-08-10 02:24:44 Re: optimize lookups in snapshot [sub]xip arrays
Previous Message Thomas Munro 2022-08-10 01:37:16 Re: Windows now has fdatasync()