mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Add code to prevent transaction ID wraparound by enforcing a safe limit
in GetNewTransactionId(). Since the limit value has to be computed before we run any real transactions, this requires adding code to database startup to scan pg_database and determine the oldest datfrozenxid. This can conveniently be combined with the first stage of an attack on the problem that the 'flat file' copies of pg_shadow and pg_group are not properly updated during WAL recovery. The code I've added to startup resides in a new file src/backend/utils/init/flatfiles.c, and it is responsible for rewriting the flat files as well as initializing the XID wraparound limit value. This will eventually allow us to get rid of GetRawDatabaseInfo too, but we'll need an initdb so we can add a trigger to pg_database.
This commit is contained in:
33
src/include/utils/flatfiles.h
Normal file
33
src/include/utils/flatfiles.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* flatfiles.h
|
||||
* Routines for maintaining "flat file" images of the shared catalogs.
|
||||
*
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/utils/flatfiles.h,v 1.1 2005/02/20 02:22:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef FLATFILES_H
|
||||
#define FLATFILES_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
extern void database_file_update_needed(void);
|
||||
extern void group_file_update_needed(void);
|
||||
extern void user_file_update_needed(void);
|
||||
|
||||
extern char *database_getflatfilename(void);
|
||||
extern char *group_getflatfilename(void);
|
||||
extern char *user_getflatfilename(void);
|
||||
|
||||
extern void BuildFlatFiles(bool database_only);
|
||||
|
||||
extern void AtEOXact_UpdateFlatFiles(bool isCommit);
|
||||
extern void AtEOSubXact_UpdateFlatFiles(bool isCommit,
|
||||
SubTransactionId mySubid,
|
||||
SubTransactionId parentSubid);
|
||||
|
||||
extern Datum flatfile_update_trigger(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* FLATFILES_H */
|
Reference in New Issue
Block a user