On Wed, Nov 1, 2023 at 2:03 PM Amit Kapila <amit.kapil...@gmail.com> wrote: > > On Mon, Mar 27, 2023 at 11:08 AM Bharath Rupireddy > <bharath.rupireddyforpostg...@gmail.com> wrote: > > > > The v9 patch was failing because I was using MyReplicationSlot after > > it got reset by slot release, attached v10 patch fixes it. > > > > + * > + * Note: use LogReplicationSlotAcquire() if needed, to log a message after > + * acquiring the replication slot. > */ > void > ReplicationSlotAcquire(const char *name, bool nowait) > @@ -542,6 +554,9 @@ retry: > > When does it need to be logged? For example, recently, we added one > more slot acquisition/release call in > binary_upgrade_logical_slot_has_caught_up(); it is not clear from the > comments whether we need to LOG it or not. I guess at some place like > atop LogReplicationSlotAcquire() we should document in a bit more > specific way as to when is this expected to be called. >
I agree. Just saying "if needed" in those function comments doesn't help with knowing how to judge when logging is needed or not. ~ Looking back at the thread history it seems the function comment was added after Euler [1] suggested ("... you should add a comment at the top of ReplicationSlotAcquire() and ReplicationSlotRelease() functions saying that LogReplicationSlotAquired() and LogReplicationSlotReleased() functions should be called respectively after it.") But that's not quite compatible with what Alvaro [2] had written long back ("... the only acquisitions that would log messages are those in StartReplication and StartLogicalReplication."). In other words, ReplicationSlotAcquire/ReplicationSlotRelease is called by more places than you care to log from. ~ Adding a better explanatory comment than "if needed" will be good, and maybe that is all that is necessary. I'm not sure. OTOH, if you have to explain that logging is only wanted for a couple of scenarios, then it raises some doubts about the usefulness of having a common function in the first place. I had the same doubts back in March [3] ("I am not sure for the *current* code if the encapsulation is worth the trouble or not."). ====== [1] Euler - https://www.postgresql.org/message-id/c42d5634-ca9b-49a7-85cd-9eff9feb33b4%40app.fastmail.com [2] Alvaro - https://www.postgresql.org/message-id/202204291032.qfvyuqxkjnjw%40alvherre.pgsql [3] Peter - https://www.postgresql.org/message-id/CAHut%2BPu6Knwooc_NckMxszGrAJnytgpMadtoJ-OA-SFWT%2BGFYw%40mail.gmail.com Kind Regards, Peter Smith. Fujitsu Austalia