Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

clog.c

Blame
    • Heikki Linnakangas's avatar
      98f58a30
      Fix Hot-Standby initialization of clog and subtrans. · 98f58a30
      Heikki Linnakangas authored
      These bugs can cause data loss on standbys started with hot_standby=on at
      the moment they start to accept read only queries, by marking committed
      transactions as uncommited. The likelihood of such corruptions is small
      unless the primary has a high transaction rate.
      
      5a031a55 fixed bugs in HS's startup logic
      by maintaining less state until at least STANDBY_SNAPSHOT_PENDING state
      was reached, missing the fact that both clog and subtrans are written to
      before that. This only failed to fail in common cases because the usage
      of ExtendCLOG in procarray.c was superflous since clog extensions are
      actually WAL logged.
      
      f44eedc3/I then tried to fix the missing
      extensions of pg_subtrans due to the former commit's changes - which are
      not WAL logged - by performing the extensions when switching to a state
      > STANDBY_INITIALIZED and not performing xid assignments before that -
      again missing the fact that ExtendCLOG is unneccessary - but screwed up
      twice: Once because latestObservedXid wasn't updated anymore in that
      state due to the earlier commit and once by having an off-by-one error in
      the loop performing extensions. This means that whenever a
      CLOG_XACTS_PER_PAGE (32768 with default settings) boundary was crossed
      between the start of the checkpoint recovery started from and the first
      xl_running_xact record old transactions commit bits in pg_clog could be
      overwritten if they started and committed in that window.
      
      Fix this mess by not performing ExtendCLOG() in HS at all anymore since
      it's unneeded and evidently dangerous and by performing subtrans
      extensions even before reaching STANDBY_SNAPSHOT_PENDING.
      
      Analysis and patch by Andres Freund. Reported by Christophe Pettus.
      Backpatch down to 9.0, like the previous commit that caused this.
      98f58a30
      History
      Fix Hot-Standby initialization of clog and subtrans.
      Heikki Linnakangas authored
      These bugs can cause data loss on standbys started with hot_standby=on at
      the moment they start to accept read only queries, by marking committed
      transactions as uncommited. The likelihood of such corruptions is small
      unless the primary has a high transaction rate.
      
      5a031a55 fixed bugs in HS's startup logic
      by maintaining less state until at least STANDBY_SNAPSHOT_PENDING state
      was reached, missing the fact that both clog and subtrans are written to
      before that. This only failed to fail in common cases because the usage
      of ExtendCLOG in procarray.c was superflous since clog extensions are
      actually WAL logged.
      
      f44eedc3/I then tried to fix the missing
      extensions of pg_subtrans due to the former commit's changes - which are
      not WAL logged - by performing the extensions when switching to a state
      > STANDBY_INITIALIZED and not performing xid assignments before that -
      again missing the fact that ExtendCLOG is unneccessary - but screwed up
      twice: Once because latestObservedXid wasn't updated anymore in that
      state due to the earlier commit and once by having an off-by-one error in
      the loop performing extensions. This means that whenever a
      CLOG_XACTS_PER_PAGE (32768 with default settings) boundary was crossed
      between the start of the checkpoint recovery started from and the first
      xl_running_xact record old transactions commit bits in pg_clog could be
      overwritten if they started and committed in that window.
      
      Fix this mess by not performing ExtendCLOG() in HS at all anymore since
      it's unneeded and evidently dangerous and by performing subtrans
      extensions even before reaching STANDBY_SNAPSHOT_PENDING.
      
      Analysis and patch by Andres Freund. Reported by Christophe Pettus.
      Backpatch down to 9.0, like the previous commit that caused this.