1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-25 20:23:07 +03:00

Remove flatfiles.c, which is now obsolete.

Recent commits have removed the various uses it was supporting.  It was a
performance bottleneck, according to bug report #4919 by Lauris Ulmanis; seems
it slowed down user creation after a billion users.
This commit is contained in:
Alvaro Herrera
2009-09-01 02:54:52 +00:00
parent 0905e8aeeb
commit a8bb8eb583
14 changed files with 36 additions and 1159 deletions

View File

@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.225 2009/06/11 14:48:55 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.226 2009/09/01 02:54:51 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,7 +49,6 @@
#include "storage/smgr.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/flatfiles.h"
#include "utils/fmgroids.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
@@ -691,19 +690,17 @@ createdb(const CreatedbStmt *stmt)
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT);
/*
* Close pg_database, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_database, but keep lock till commit.
*/
heap_close(pg_database_rel, NoLock);
/*
* Set flag to update flat database file at commit. Note: this also
* forces synchronous commit, which minimizes the window between
* Force synchronous commit, thus minimizing the window between
* creation of the database files and commital of the transaction. If
* we crash before committing, we'll have a DB that's taking up disk
* space but is not in pg_database, which is not good.
*/
database_file_update_needed();
ForceSyncCommit();
}
PG_END_ENSURE_ERROR_CLEANUP(createdb_failure_callback,
PointerGetDatum(&fparms));
@@ -862,19 +859,17 @@ dropdb(const char *dbname, bool missing_ok)
remove_dbtablespaces(db_id);
/*
* Close pg_database, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_database, but keep lock till commit.
*/
heap_close(pgdbrel, NoLock);
/*
* Set flag to update flat database file at commit. Note: this also
* forces synchronous commit, which minimizes the window between removal
* Force synchronous commit, thus minimizing the window between removal
* of the database files and commital of the transaction. If we crash
* before committing, we'll have a DB that's gone on disk but still there
* according to pg_database, which is not good.
*/
database_file_update_needed();
ForceSyncCommit();
}
@@ -957,15 +952,9 @@ RenameDatabase(const char *oldname, const char *newname)
CatalogUpdateIndexes(rel, newtup);
/*
* Close pg_database, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_database, but keep lock till commit.
*/
heap_close(rel, NoLock);
/*
* Set flag to update flat database file at commit.
*/
database_file_update_needed();
}
@@ -1212,17 +1201,15 @@ movedb(const char *dbname, const char *tblspcname)
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT);
/*
* Set flag to update flat database file at commit. Note: this also
* forces synchronous commit, which minimizes the window between
* Force synchronous commit, thus minimizing the window between
* copying the database files and commital of the transaction. If we
* crash before committing, we'll leave an orphaned set of files on
* disk, which is not fatal but not good either.
*/
database_file_update_needed();
ForceSyncCommit();
/*
* Close pg_database, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_database, but keep lock till commit.
*/
heap_close(pgdbrel, NoLock);
}
@@ -1401,11 +1388,6 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
/* Close pg_database, but keep lock till commit */
heap_close(rel, NoLock);
/*
* We don't bother updating the flat file since the existing options for
* ALTER DATABASE don't affect it.
*/
}
@@ -1494,11 +1476,6 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
/* Close pg_database, but keep lock till commit */
heap_close(rel, NoLock);
/*
* We don't bother updating the flat file since ALTER DATABASE SET doesn't
* affect it.
*/
}
@@ -1608,11 +1585,6 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
/* Close pg_database, but keep lock till commit */
heap_close(rel, NoLock);
/*
* We don't bother updating the flat file since ALTER DATABASE OWNER
* doesn't affect it.
*/
}

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.187 2009/06/11 14:48:56 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.188 2009/09/01 02:54:51 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,7 +26,6 @@
#include "storage/lmgr.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/flatfiles.h"
#include "utils/fmgroids.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
@@ -385,15 +384,9 @@ CreateRole(CreateRoleStmt *stmt)
GetUserId(), false);
/*
* Close pg_authid, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_authid, but keep lock till commit.
*/
heap_close(pg_authid_rel, NoLock);
/*
* Set flag to update flat auth file at commit.
*/
auth_file_update_needed();
}
@@ -710,15 +703,9 @@ AlterRole(AlterRoleStmt *stmt)
false);
/*
* Close pg_authid, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_authid, but keep lock till commit.
*/
heap_close(pg_authid_rel, NoLock);
/*
* Set flag to update flat auth file at commit.
*/
auth_file_update_needed();
}
@@ -808,7 +795,6 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
CatalogUpdateIndexes(rel, newtuple);
ReleaseSysCache(oldtuple);
/* needn't keep lock since we won't be updating the flat file */
heap_close(rel, RowExclusiveLock);
}
@@ -970,16 +956,10 @@ DropRole(DropRoleStmt *stmt)
}
/*
* Now we can clean up; but keep locks until commit (to avoid possible
* deadlock failure while updating flat file)
* Now we can clean up; but keep locks until commit.
*/
heap_close(pg_auth_members_rel, NoLock);
heap_close(pg_authid_rel, NoLock);
/*
* Set flag to update flat auth file at commit.
*/
auth_file_update_needed();
}
/*
@@ -1092,15 +1072,9 @@ RenameRole(const char *oldname, const char *newname)
ReleaseSysCache(oldtuple);
/*
* Close pg_authid, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_authid, but keep lock till commit.
*/
heap_close(rel, NoLock);
/*
* Set flag to update flat auth file at commit.
*/
auth_file_update_needed();
}
/*
@@ -1157,15 +1131,9 @@ GrantRole(GrantRoleStmt *stmt)
}
/*
* Close pg_authid, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_authid, but keep lock till commit.
*/
heap_close(pg_authid_rel, NoLock);
/*
* Set flag to update flat auth file at commit.
*/
auth_file_update_needed();
}
/*
@@ -1385,8 +1353,7 @@ AddRoleMems(const char *rolename, Oid roleid,
}
/*
* Close pg_authmem, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_authmem, but keep lock till commit.
*/
heap_close(pg_authmem_rel, NoLock);
}
@@ -1498,8 +1465,7 @@ DelRoleMems(const char *rolename, Oid roleid,
}
/*
* Close pg_authmem, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
* Close pg_authmem, but keep lock till commit.
*/
heap_close(pg_authmem_rel, NoLock);
}

View File

@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.391 2009/08/31 02:23:22 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.392 2009/09/01 02:54:51 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -46,7 +46,6 @@
#include "storage/procarray.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/flatfiles.h"
#include "utils/fmgroids.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
@@ -893,15 +892,11 @@ vac_update_datfrozenxid(void)
heap_close(relation, RowExclusiveLock);
/*
* If we were able to advance datfrozenxid, mark the flat-file copy of
* pg_database for update at commit, and see if we can truncate pg_clog.
* Also force update if the shared XID-wrap-limit info is stale.
* If we were able to advance datfrozenxid, see if we can truncate pg_clog.
* Also do it if the shared XID-wrap-limit info is stale.
*/
if (dirty || !TransactionIdLimitIsValid())
{
database_file_update_needed();
vac_truncate_clog(newFrozenXid);
}
}