]> granicus.if.org Git - postgresql/commit
Allow read only connections during recovery, known as Hot Standby.
authorSimon Riggs <simon@2ndQuadrant.com>
Sat, 19 Dec 2009 01:32:45 +0000 (01:32 +0000)
committerSimon Riggs <simon@2ndQuadrant.com>
Sat, 19 Dec 2009 01:32:45 +0000 (01:32 +0000)
commitefc16ea520679d713d98a2c7bf1453c4ff7b91ec
tree6a39d2af0704a36281dc7df3ec10823eb3e6de75
parent78a09145e0f8322e625bbc7d69fcb865ce4f3034
Allow read only connections during recovery, known as Hot Standby.

Enabled by recovery_connections = on (default) and forcing archive recovery using a recovery.conf. Recovery processing now emulates the original transactions as they are replayed, providing full locking and MVCC behaviour for read only queries. Recovery must enter consistent state before connections are allowed, so there is a delay, typically short, before connections succeed. Replay of recovering transactions can conflict and in some cases deadlock with queries during recovery; these result in query cancellation after max_standby_delay seconds have expired. Infrastructure changes have minor effects on normal running, though introduce four new types of WAL record.

New test mode "make standbycheck" allows regression tests of static command behaviour on a standby server while in recovery. Typical and extreme dynamic behaviours have been checked via code inspection and manual testing. Few port specific behaviours have been utilised, though primary testing has been on Linux only so far.

This commit is the basic patch. Additional changes will follow in this release to enhance some aspects of behaviour, notably improved handling of conflicts, deadlock detection and query cancellation. Changes to VACUUM FULL are also required.

Simon Riggs, with significant and lengthy review by Heikki Linnakangas, including streamlined redesign of snapshot creation and two-phase commit.

Important contributions from Florian Pflug, Mark Kirkwood, Merlin Moncure, Greg Stark, Gianni Ciolli, Gabriele Bartolini, Hannu Krosing, Robert Haas, Tatsuo Ishii, Hiroyuki Yamada plus support and feedback from many other community members.
87 files changed:
doc/src/sgml/backup.sgml
doc/src/sgml/config.sgml
doc/src/sgml/func.sgml
doc/src/sgml/ref/checkpoint.sgml
src/backend/access/gin/ginxlog.c
src/backend/access/gist/gistxlog.c
src/backend/access/heap/heapam.c
src/backend/access/heap/pruneheap.c
src/backend/access/index/genam.c
src/backend/access/index/indexam.c
src/backend/access/nbtree/README
src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtpage.c
src/backend/access/nbtree/nbtree.c
src/backend/access/nbtree/nbtxlog.c
src/backend/access/transam/README
src/backend/access/transam/clog.c
src/backend/access/transam/multixact.c
src/backend/access/transam/recovery.conf.sample
src/backend/access/transam/rmgr.c
src/backend/access/transam/subtrans.c
src/backend/access/transam/twophase.c
src/backend/access/transam/twophase_rmgr.c
src/backend/access/transam/xact.c
src/backend/access/transam/xlog.c
src/backend/commands/dbcommands.c
src/backend/commands/lockcmds.c
src/backend/commands/sequence.c
src/backend/commands/tablespace.c
src/backend/commands/vacuum.c
src/backend/commands/vacuumlazy.c
src/backend/postmaster/postmaster.c
src/backend/storage/ipc/Makefile
src/backend/storage/ipc/procarray.c
src/backend/storage/ipc/sinvaladt.c
src/backend/storage/ipc/standby.c [new file with mode: 0644]
src/backend/storage/lmgr/README
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/proc.c
src/backend/tcop/postgres.c
src/backend/tcop/utility.c
src/backend/utils/adt/txid.c
src/backend/utils/adt/xid.c
src/backend/utils/cache/inval.c
src/backend/utils/error/elog.c
src/backend/utils/init/postinit.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample
src/backend/utils/time/snapmgr.c
src/backend/utils/time/tqual.c
src/bin/pg_controldata/pg_controldata.c
src/include/access/heapam.h
src/include/access/htup.h
src/include/access/nbtree.h
src/include/access/relscan.h
src/include/access/rmgr.h
src/include/access/subtrans.h
src/include/access/transam.h
src/include/access/twophase.h
src/include/access/twophase_rmgr.h
src/include/access/xact.h
src/include/access/xlog.h
src/include/access/xlog_internal.h
src/include/catalog/pg_control.h
src/include/catalog/pg_proc.h
src/include/miscadmin.h
src/include/storage/lock.h
src/include/storage/proc.h
src/include/storage/procarray.h
src/include/storage/sinval.h
src/include/storage/sinvaladt.h
src/include/storage/standby.h [new file with mode: 0644]
src/include/utils/builtins.h
src/include/utils/snapshot.h
src/test/regress/GNUmakefile
src/test/regress/expected/hs_standby_allowed.out [new file with mode: 0644]
src/test/regress/expected/hs_standby_check.out [new file with mode: 0644]
src/test/regress/expected/hs_standby_disallowed.out [new file with mode: 0644]
src/test/regress/expected/hs_standby_functions.out [new file with mode: 0644]
src/test/regress/pg_regress.c
src/test/regress/sql/hs_primary_extremes.sql [new file with mode: 0644]
src/test/regress/sql/hs_primary_setup.sql [new file with mode: 0644]
src/test/regress/sql/hs_standby_allowed.sql [new file with mode: 0644]
src/test/regress/sql/hs_standby_check.sql [new file with mode: 0644]
src/test/regress/sql/hs_standby_disallowed.sql [new file with mode: 0644]
src/test/regress/sql/hs_standby_functions.sql [new file with mode: 0644]
src/test/regress/standby_schedule [new file with mode: 0644]