Allow execution and discard of undo by background workers.
authorAmit Kapila <amit.kapila@enterprisedb.com>
Thu, 13 Jun 2019 10:33:49 +0000 (16:03 +0530)
committerKuntal Ghosh <kuntal.ghosh@enterprisedb.com>
Fri, 19 Jul 2019 08:48:51 +0000 (14:18 +0530)
commit580cf9d2066e5b4f8e5362c63bdc95e469d01c79
tree808e16e55cf421e37db68fd796cc12e082be4c62
parentb0ad139a73df896595f850de733557de71e59b1c
Allow execution and discard of undo by background workers.

Undo launcher is responsible for launching the workers iff there is some
work available in one of the work queues and there are more workers
available.  The worker is launched to handle requests for a particular
database.

The discard worker is responsible for discarding the undo log of
transactions that are committed and all-visible or are rolled-back.  It
also registers the request for aborted transactions in the work queues.
It iterates through all the active logs one-by-one and tries to discard the
transactions that are old enough to matter.

We don't allow any transaction older than 2^31 to have pending undo actions.
Also, we have a hard limit on the number of transactions that can have
pending undo which is proportional to pending_undo_queue_size.

Amit Kapila, Dilip Kumar and Kuntal Ghosh with inputs from Andres Freund,
Robert Haas and Thomas Munro.
34 files changed:
src/backend/access/rmgrdesc/xlogdesc.c
src/backend/access/transam/varsup.c
src/backend/access/transam/xact.c
src/backend/access/transam/xlog.c
src/backend/access/undo/Makefile
src/backend/access/undo/README.UndoProcessing
src/backend/access/undo/discardworker.c [new file with mode: 0644]
src/backend/access/undo/undoaccess.c
src/backend/access/undo/undodiscard.c [new file with mode: 0644]
src/backend/access/undo/undolog.c
src/backend/access/undo/undorequest.c
src/backend/access/undo/undoworker.c [new file with mode: 0644]
src/backend/commands/tablecmds.c
src/backend/postmaster/bgworker.c
src/backend/postmaster/pgstat.c
src/backend/postmaster/postmaster.c
src/backend/storage/ipc/ipci.c
src/backend/storage/lmgr/lwlocknames.txt
src/backend/storage/lmgr/proc.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample
src/include/access/discardworker.h [new file with mode: 0644]
src/include/access/transam.h
src/include/access/undodiscard.h [new file with mode: 0644]
src/include/access/undolog.h
src/include/access/undoworker.h [new file with mode: 0644]
src/include/catalog/pg_control.h
src/include/nodes/primnodes.h
src/include/pgstat.h
src/include/postmaster/postmaster.h
src/include/storage/lwlock.h
src/include/storage/proc.h
src/include/storage/procarray.h
src/test/regress/expected/sysviews.out