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

bootstrap.c

Blame
    • Tom Lane's avatar
      4a9c30a8
      Fix management of pendingOpsTable in auxiliary processes. · 4a9c30a8
      Tom Lane authored
      mdinit() was misusing IsBootstrapProcessingMode() to decide whether to
      create an fsync pending-operations table in the current process.  This led
      to creating a table not only in the startup and checkpointer processes as
      intended, but also in the bgwriter process, not to mention other auxiliary
      processes such as walwriter and walreceiver.  Creation of the table in the
      bgwriter is fatal, because it absorbs fsync requests that should have gone
      to the checkpointer; instead they just sit in bgwriter local memory and are
      never acted on.  So writes performed by the bgwriter were not being fsync'd
      which could result in data loss after an OS crash.  I think there is no
      live bug with respect to walwriter and walreceiver because those never
      perform any writes of shared buffers; but the potential is there for
      future breakage in those processes too.
      
      To fix, make AuxiliaryProcessMain() export the current process's
      AuxProcType as a global variable, and then make mdinit() test directly for
      the types of aux process that should have a pendingOpsTable.  Having done
      that, we might as well also get rid of the random bool flags such as
      am_walreceiver that some of the aux processes had grown.  (Note that we
      could not have fixed the bug by examining those variables in mdinit(),
      because it's called from BaseInit() which is run by AuxiliaryProcessMain()
      before entering any of the process-type-specific code.)
      
      Back-patch to 9.2, where the problem was introduced by the split-up of
      bgwriter and checkpointer processes.  The bogus pendingOpsTable exists
      in walwriter and walreceiver processes in earlier branches, but absent
      any evidence that it causes actual problems there, I'll leave the older
      branches alone.
      4a9c30a8
      History
      Fix management of pendingOpsTable in auxiliary processes.
      Tom Lane authored
      mdinit() was misusing IsBootstrapProcessingMode() to decide whether to
      create an fsync pending-operations table in the current process.  This led
      to creating a table not only in the startup and checkpointer processes as
      intended, but also in the bgwriter process, not to mention other auxiliary
      processes such as walwriter and walreceiver.  Creation of the table in the
      bgwriter is fatal, because it absorbs fsync requests that should have gone
      to the checkpointer; instead they just sit in bgwriter local memory and are
      never acted on.  So writes performed by the bgwriter were not being fsync'd
      which could result in data loss after an OS crash.  I think there is no
      live bug with respect to walwriter and walreceiver because those never
      perform any writes of shared buffers; but the potential is there for
      future breakage in those processes too.
      
      To fix, make AuxiliaryProcessMain() export the current process's
      AuxProcType as a global variable, and then make mdinit() test directly for
      the types of aux process that should have a pendingOpsTable.  Having done
      that, we might as well also get rid of the random bool flags such as
      am_walreceiver that some of the aux processes had grown.  (Note that we
      could not have fixed the bug by examining those variables in mdinit(),
      because it's called from BaseInit() which is run by AuxiliaryProcessMain()
      before entering any of the process-type-specific code.)
      
      Back-patch to 9.2, where the problem was introduced by the split-up of
      bgwriter and checkpointer processes.  The bogus pendingOpsTable exists
      in walwriter and walreceiver processes in earlier branches, but absent
      any evidence that it causes actual problems there, I'll leave the older
      branches alone.