At Wed, 30 Mar 2022 21:07:40 +0200, Pierre Forstmann <pierre.forstmann@gmail.com> wrote in > I can reproduce your issue with your base_recovery.sh with PG 13.6 on Alma > Linux 8.5. > > If I modify your script to display transaction numbers before and after > DROP DATABASE with: > > echo -e $rt `date` "drop the database test ..." $wt > # Drop DB > psql -c 'select txid_current();' > psql -c 'DROP DATABASE test' > psql -c 'select txid_current();'
This is not a bug, rather a limitation of recovery_target_time.
The script specifies recovery target by time. The target time time is compared with timestamps embedded in some kinds of WAL record, mainly COMMIT.
The reason why it works is that the query creates COMMIT records. Otherwise no timestamp seen since the backup point and before the DROP record. Thus recovery has no means to stop by the target time before the DROP.
The WAL for the bad case looks like this (abbreviated and thinned out):