On Monday, September 25, 2023 7:01 PM Kuroda, Hayato/黒田 隼人 <kuroda.hay...@fujitsu.com> wrote: > To: 'Bharath Rupireddy' <bharath.rupireddyforpostg...@gmail.com> > Cc: Amit Kapila <amit.kapil...@gmail.com>; Dilip Kumar > > > > 5. In continuation to the above comment: > > > > Why can't this logic be something like - if there's any WAL record > > seen after a slot's confirmed flush LSN is of type generated by WAL > > resource manager having the rm_decode function defined, then the slot > > can't be upgraded. > > Thank you for giving new approach! We have never seen the approach before, > but at least XLOG and HEAP2 rmgr have a decode function. So that > XLOG_CHECKPOINT_SHUTDOWN, XLOG_CHECKPOINT_ONLINE, and > XLOG_HEAP2_PRUNE cannot be ignored the approach, seems not appropriate. > If you have another approach, I'm very happy if you post.
Another idea around decoding is to check if there is any decoding output for the WAL records. Like we can create a temp slot and use test_decoding to decode the WAL from the confirmed_flush_lsn among existing logical replication slots. And if there is any output from the output plugin, then we consider WAL has not been consumed yet. But this means we need to ignore some of the WALs like XLOG_XACT_INVALIDATIONS which won't be decoded into the output. Also, this approach could be costly as it needs to do the extra decoding and output, and we need to assume that "all the WAL records including custom records will be decoded and output if they need to be consumed" . So it may not be better, but just share it for reference. Best Regards, Hou zj