Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
6f1ca7e4
Commit
6f1ca7e4
authored
May 05, 2005
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bogus hashtable setup. (This code has quite a few other problems
too, but that one is in my way at the moment.)
parent
c2e729fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
33 deletions
+13
-33
src/backend/utils/init/checkfiles.c
src/backend/utils/init/checkfiles.c
+13
-33
No files found.
src/backend/utils/init/checkfiles.c
View file @
6f1ca7e4
/*-------------------------------------------------------------------------
*
* checkfiles.c
*
support to clean up stale relation files on
crash recovery
*
check for stale relation files during
crash recovery
*
* If a backend crashes while in a transaction that has created or
* deleted a relfilenode, a stale file can be left over in the data
...
...
@@ -14,24 +14,24 @@
* files, and use the 'dirty' flag to determine if we should run this on
* a clean startup.
*
* $PostgreSQL: pgsql/src/backend/utils/init/checkfiles.c,v 1.
1 2005/05/02 18:26:53 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/init/checkfiles.c,v 1.
2 2005/05/05 22:18:27 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/heapam.h"
#include "access/relscan.h"
#include "access/skey.h"
#include "catalog/catalog.h"
#include "catalog/pg_tablespace.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "utils/flatfiles.h"
#include "miscadmin.h"
#include "catalog/pg_tablespace.h"
#include "catalog/catalog.h"
#include "access/skey.h"
#include "utils/fmgroids.h"
#include "access/relscan.h"
#include "access/heapam.h"
#include "utils/resowner.h"
static
void
CheckStaleRelFilesFrom
(
Oid
tablespaceoid
,
Oid
dboid
);
static
void
CheckStaleRelFilesFromTablespace
(
Oid
tablespaceoid
);
...
...
@@ -52,11 +52,6 @@ AllocateDirChecked(char *path)
/*
* Scan through all tablespaces for relations left over
* by aborted transactions.
*
* For example, if a transaction issues
* BEGIN; CREATE TABLE foobar ();
* and then the backend crashes, the file is left in the
* tablespace until CheckStaleRelFiles deletes it.
*/
void
CheckStaleRelFiles
(
void
)
...
...
@@ -125,31 +120,18 @@ CheckStaleRelFilesFrom(Oid tablespaceoid, Oid dboid)
struct
dirent
*
de
;
HASHCTL
hashctl
;
HTAB
*
relfilenodeHash
;
MemoryContext
mcxt
;
RelFileNode
rnode
;
char
*
path
;
/*
* We create a private memory context so that we can easily deallocate the
* hash table and its contents
*/
mcxt
=
AllocSetContextCreate
(
TopMemoryContext
,
"CheckStaleRelFiles"
,
ALLOCSET_DEFAULT_MINSIZE
,
ALLOCSET_DEFAULT_INITSIZE
,
ALLOCSET_DEFAULT_MAXSIZE
);
hashctl
.
hash
=
tag_hash
;
/*
* The entry contents is not used for anything, we just check if an oid is
* in the hash table or not.
*/
hashctl
.
keysize
=
sizeof
(
Oid
);
hashctl
.
entrysize
=
1
;
hashctl
.
h
cxt
=
mcxt
;
hashctl
.
entrysize
=
sizeof
(
Oid
)
;
hashctl
.
h
ash
=
tag_hash
;
relfilenodeHash
=
hash_create
(
"relfilenodeHash"
,
100
,
&
hashctl
,
HASH_FUNCTION
|
HASH_ELEM
|
HASH_CONTEXT
);
HASH_FUNCTION
|
HASH_ELEM
);
/* Read all relfilenodes from pg_class into the hash table */
{
...
...
@@ -209,10 +191,9 @@ CheckStaleRelFilesFrom(Oid tablespaceoid, Oid dboid)
rnode
.
relNode
=
relfilenode
;
filepath
=
relpath
(
rnode
);
ereport
(
LOG
,
(
errcode_for_file_access
(),
errmsg
(
"
The table or index file
\"
%s
\"
is stale and can be safely
removed"
,
errmsg
(
"
table or index file
\"
%s
\"
is stale and can safely be
removed"
,
filepath
)));
pfree
(
filepath
);
}
...
...
@@ -221,5 +202,4 @@ CheckStaleRelFilesFrom(Oid tablespaceoid, Oid dboid)
FreeDir
(
dirdesc
);
pfree
(
path
);
hash_destroy
(
relfilenodeHash
);
MemoryContextDelete
(
mcxt
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment