Hi,

having just spoken with Harald Armin Massa of 2ndQuadrant, he encouraged me to 
ask my question here. This is about publisher/subscriber replication and was 
originally posted in german to pgsql-de-allgem...@lists.postgresql.org.

According to documentation, the field pg_stats_subscription.latest_end_time 
contains the "Time of last write-ahead log location reported to origin WAL 
sender" [1].
The view is built from the internal function pg_stat_get_subscription() [2, 
line 1097], defined in launcher.c, where we can see that the field is populated 
from a struct LogicalRepWorker. Write access to the relevant struct happens in 
worker.c from UpdateWorkerStats() but only if reply=true [3, line 1109], which 
in turn only happens whenever LogicalRepApplyLoop() deals with a message 
beginning with 'k' [3, line 1227]. This message is constructed by the publisher 
in walsender.c in WalSndKeepalive() [4, line 3435], where the corresponding 
value is always GetCurrentTimestamp().

As far as I understand, the WAL replication process has the publisher send 
messages with WAL slices (type 'w') and keepalive messages (type 'k'), to which 
the subscriber answers with a heartbeat. Other message types are not relevant 
here. If the documentation is correct, shouldn't latest_end_time use the 
creation time of the publisher's most recent WAL slice? On the other hand, 
wouldn't "time of last communication from WAL sender" be a more appropriate 
description of the actual behaviour? And in that case, why only consider 
'k'-messages instead of 'w'-messages that contain data?

Either way, I'm confused as to the meaning of 
pg_stats_subscription.latest_end_time. The documentation as is also lead to 
discussions in the office, because "reported to ... sender" is ambiguous as to 
who reports: It might mean some kind of feedback from the subscriber.


Please enlighten me, and please excuse the footer, which I can't turn off.

[1] 
https://www.postgresql.org/docs/12/monitoring-stats.html#PG-STAT-SUBSCRIPTION
[2] 
https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/replication/logical/launcher.c;h=186057bd9327383b7dfdc2d2dda878290caa7967;hb=5060275aa8a1ead56e0a41308d7a43049a6cbe43
[3] 
https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/replication/logical/worker.c;h=790a28fc77e47c7024b8605448311aaa4325fb5b;hb=5060275aa8a1ead56e0a41308d7a43049a6cbe43
[4] 
https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/replication/walsender.c;h=89fbb6fd92788fca66eeb93aaabed7f63dd940c2;hb=5060275aa8a1ead56e0a41308d7a43049a6cbe43


Im Auftrag
Simon Schneider

Stadt Köln - Die Oberbürgermeisterin
Berufsfeuerwehr, Amt für Feuerschutz, Rettungsdienst und Bevölkerungsschutz
Boltensternstr. 10
50735 Köln

Telefon: 0221/9748-9092
Telefax: 0221/9748-9004
E-Mail: simon.schnei...@stadt-koeln.de
Internet: https://www.stadt-koeln.de


________________________________
________________________________

Monatlich aktuelle Informationen Ihrer Stadtverwaltung in unserem Newsletter! 
Newsletter 
Anmeldung<https://www.stadt-koeln.de/service/onlinedienste/newsletter-anmeldung?para=allgemein>

________________________________
________________________________

[https://styleguide.bundesregierung.de/resource/blob/72496/1760346/6d7f611945ca42908c50804510c5335b/breg-vorschaubild-01-unterstuetzt-842x595px-jpg-srgb-v01-data.png]<https://www.bundesregierung.de/breg-de/themen/corona-warn-app>
[https://www.stadt-koeln.de/images/footer_wahlhelferaufruf2020.jpg]<http://www.wahlhelfer.koeln/>



Reply via email to