RE: Perform streaming logical transactions by background workers and parallel apply - Mailing list pgsql-hackers

From kuroda.hayato@fujitsu.com
Subject RE: Perform streaming logical transactions by background workers and parallel apply
Date
Msg-id TYAPR01MB5866F35F22C8A8050F2B1C41F5659@TYAPR01MB5866.jpnprd01.prod.outlook.com
Whole thread Raw
In response to RE: Perform streaming logical transactions by background workers and parallel apply  ("kuroda.hayato@fujitsu.com" <kuroda.hayato@fujitsu.com>)
List 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


pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Windows now has fdatasync()
Next
From: Masahiko Sawada
Date:
Subject: Re: optimize lookups in snapshot [sub]xip arrays