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
923e994d
Commit
923e994d
authored
Nov 13, 2003
by
Jan Wieck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ARC strategy backed out ... sorry
Jan
parent
256d2f09
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
216 additions
and
932 deletions
+216
-932
src/backend/commands/vacuum.c
src/backend/commands/vacuum.c
+1
-21
src/backend/storage/buffer/buf_init.c
src/backend/storage/buffer/buf_init.c
+18
-8
src/backend/storage/buffer/buf_table.c
src/backend/storage/buffer/buf_table.c
+42
-26
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/bufmgr.c
+37
-34
src/backend/storage/buffer/freelist.c
src/backend/storage/buffer/freelist.c
+106
-795
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+1
-11
src/backend/utils/misc/postgresql.conf.sample
src/backend/utils/misc/postgresql.conf.sample
+0
-1
src/include/miscadmin.h
src/include/miscadmin.h
+1
-8
src/include/storage/buf_internals.h
src/include/storage/buf_internals.h
+10
-28
No files found.
src/backend/commands/vacuum.c
View file @
923e994d
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.26
6 2003/11/13 00:40:00
wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.26
7 2003/11/13 05:34:57
wieck Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
#include "commands/vacuum.h"
#include "commands/vacuum.h"
#include "executor/executor.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "miscadmin.h"
#include "storage/buf_internals.h"
#include "storage/freespace.h"
#include "storage/freespace.h"
#include "storage/sinval.h"
#include "storage/sinval.h"
#include "storage/smgr.h"
#include "storage/smgr.h"
...
@@ -311,16 +310,8 @@ vacuum(VacuumStmt *vacstmt)
...
@@ -311,16 +310,8 @@ vacuum(VacuumStmt *vacstmt)
else
else
old_context
=
MemoryContextSwitchTo
(
anl_context
);
old_context
=
MemoryContextSwitchTo
(
anl_context
);
/*
* Tell the buffer replacement strategy that vacuum is
* causing the IO
*/
StrategyHintVacuum
(
true
);
analyze_rel
(
relid
,
vacstmt
);
analyze_rel
(
relid
,
vacstmt
);
StrategyHintVacuum
(
false
);
if
(
vacstmt
->
vacuum
)
if
(
vacstmt
->
vacuum
)
CommitTransactionCommand
();
CommitTransactionCommand
();
else
else
...
@@ -758,12 +749,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
...
@@ -758,12 +749,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
SetQuerySnapshot
();
/* might be needed for functions in
SetQuerySnapshot
();
/* might be needed for functions in
* indexes */
* indexes */
/*
* Tell the cache replacement strategy that vacuum is causing
* all following IO
*/
StrategyHintVacuum
(
true
);
/*
/*
* Check for user-requested abort. Note we want this to be inside a
* Check for user-requested abort. Note we want this to be inside a
* transaction, so xact.c doesn't issue useless WARNING.
* transaction, so xact.c doesn't issue useless WARNING.
...
@@ -778,7 +763,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
...
@@ -778,7 +763,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
ObjectIdGetDatum
(
relid
),
ObjectIdGetDatum
(
relid
),
0
,
0
,
0
))
0
,
0
,
0
))
{
{
StrategyHintVacuum
(
false
);
CommitTransactionCommand
();
CommitTransactionCommand
();
return
true
;
/* okay 'cause no data there */
return
true
;
/* okay 'cause no data there */
}
}
...
@@ -812,7 +796,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
...
@@ -812,7 +796,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
(
errmsg
(
"skipping
\"
%s
\"
--- only table or database owner can vacuum it"
,
(
errmsg
(
"skipping
\"
%s
\"
--- only table or database owner can vacuum it"
,
RelationGetRelationName
(
onerel
))));
RelationGetRelationName
(
onerel
))));
relation_close
(
onerel
,
lmode
);
relation_close
(
onerel
,
lmode
);
StrategyHintVacuum
(
false
);
CommitTransactionCommand
();
CommitTransactionCommand
();
return
false
;
return
false
;
}
}
...
@@ -827,7 +810,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
...
@@ -827,7 +810,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
(
errmsg
(
"skipping
\"
%s
\"
--- cannot vacuum indexes, views, or special system tables"
,
(
errmsg
(
"skipping
\"
%s
\"
--- cannot vacuum indexes, views, or special system tables"
,
RelationGetRelationName
(
onerel
))));
RelationGetRelationName
(
onerel
))));
relation_close
(
onerel
,
lmode
);
relation_close
(
onerel
,
lmode
);
StrategyHintVacuum
(
false
);
CommitTransactionCommand
();
CommitTransactionCommand
();
return
false
;
return
false
;
}
}
...
@@ -842,7 +824,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
...
@@ -842,7 +824,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
if
(
isOtherTempNamespace
(
RelationGetNamespace
(
onerel
)))
if
(
isOtherTempNamespace
(
RelationGetNamespace
(
onerel
)))
{
{
relation_close
(
onerel
,
lmode
);
relation_close
(
onerel
,
lmode
);
StrategyHintVacuum
(
false
);
CommitTransactionCommand
();
CommitTransactionCommand
();
return
true
;
/* assume no long-lived data in temp
return
true
;
/* assume no long-lived data in temp
* tables */
* tables */
...
@@ -882,7 +863,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
...
@@ -882,7 +863,6 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
/*
/*
* Complete the transaction and free all temporary memory used.
* Complete the transaction and free all temporary memory used.
*/
*/
StrategyHintVacuum
(
false
);
CommitTransactionCommand
();
CommitTransactionCommand
();
/*
/*
...
...
src/backend/storage/buffer/buf_init.c
View file @
923e994d
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.5
5 2003/11/13 00:40:01
wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.5
6 2003/11/13 05:34:58
wieck Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -48,6 +48,9 @@ long *CurTraceBuf;
...
@@ -48,6 +48,9 @@ long *CurTraceBuf;
int
ShowPinTrace
=
0
;
int
ShowPinTrace
=
0
;
int
Data_Descriptors
;
int
Data_Descriptors
;
int
Free_List_Descriptor
;
int
Lookup_List_Descriptor
;
int
Num_Descriptors
;
BufferDesc
*
BufferDescriptors
;
BufferDesc
*
BufferDescriptors
;
Block
*
BufferBlockPointers
;
Block
*
BufferBlockPointers
;
...
@@ -130,6 +133,9 @@ InitBufferPool(void)
...
@@ -130,6 +133,9 @@ InitBufferPool(void)
int
i
;
int
i
;
Data_Descriptors
=
NBuffers
;
Data_Descriptors
=
NBuffers
;
Free_List_Descriptor
=
Data_Descriptors
;
Lookup_List_Descriptor
=
Data_Descriptors
+
1
;
Num_Descriptors
=
Data_Descriptors
+
1
;
/*
/*
* It's probably not really necessary to grab the lock --- if there's
* It's probably not really necessary to grab the lock --- if there's
...
@@ -150,7 +156,7 @@ InitBufferPool(void)
...
@@ -150,7 +156,7 @@ InitBufferPool(void)
BufferDescriptors
=
(
BufferDesc
*
)
BufferDescriptors
=
(
BufferDesc
*
)
ShmemInitStruct
(
"Buffer Descriptors"
,
ShmemInitStruct
(
"Buffer Descriptors"
,
Data
_Descriptors
*
sizeof
(
BufferDesc
),
&
foundDescs
);
Num
_Descriptors
*
sizeof
(
BufferDesc
),
&
foundDescs
);
BufferBlocks
=
(
char
*
)
BufferBlocks
=
(
char
*
)
ShmemInitStruct
(
"Buffer Blocks"
,
ShmemInitStruct
(
"Buffer Blocks"
,
...
@@ -170,14 +176,16 @@ InitBufferPool(void)
...
@@ -170,14 +176,16 @@ InitBufferPool(void)
block
=
BufferBlocks
;
block
=
BufferBlocks
;
/*
/*
* link the buffers into a single linked list. This will become the
* link the buffers into a circular, doubly-linked list to
* LiFo list of unused buffers returned by StragegyGetBuffer().
* initialize free list, and initialize the buffer headers. Still
* don't know anything about replacement strategy in this file.
*/
*/
for
(
i
=
0
;
i
<
Data_Descriptors
;
block
+=
BLCKSZ
,
buf
++
,
i
++
)
for
(
i
=
0
;
i
<
Data_Descriptors
;
block
+=
BLCKSZ
,
buf
++
,
i
++
)
{
{
Assert
(
ShmemIsValid
((
unsigned
long
)
block
));
Assert
(
ShmemIsValid
((
unsigned
long
)
block
));
buf
->
bufNext
=
i
+
1
;
buf
->
freeNext
=
i
+
1
;
buf
->
freePrev
=
i
-
1
;
CLEAR_BUFFERTAG
(
&
(
buf
->
tag
));
CLEAR_BUFFERTAG
(
&
(
buf
->
tag
));
buf
->
buf_id
=
i
;
buf
->
buf_id
=
i
;
...
@@ -191,12 +199,14 @@ InitBufferPool(void)
...
@@ -191,12 +199,14 @@ InitBufferPool(void)
buf
->
wait_backend_id
=
0
;
buf
->
wait_backend_id
=
0
;
}
}
/* Correct last entry */
/* close the circular queue */
BufferDescriptors
[
Data_Descriptors
-
1
].
bufNext
=
-
1
;
BufferDescriptors
[
0
].
freePrev
=
Data_Descriptors
-
1
;
BufferDescriptors
[
Data_Descriptors
-
1
].
freeNext
=
0
;
}
}
/* Init other shared buffer-management stuff */
/* Init other shared buffer-management stuff */
StrategyInitialize
(
!
foundDescs
);
InitBufTable
();
InitFreeList
(
!
foundDescs
);
LWLockRelease
(
BufMgrLock
);
LWLockRelease
(
BufMgrLock
);
}
}
...
...
src/backend/storage/buffer/buf_table.c
View file @
923e994d
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.3
0 2003/11/13 00:40:01
wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.3
1 2003/11/13 05:34:58
wieck Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -38,7 +38,7 @@ static HTAB *SharedBufHash;
...
@@ -38,7 +38,7 @@ static HTAB *SharedBufHash;
* Initialize shmem hash table for mapping buffers
* Initialize shmem hash table for mapping buffers
*/
*/
void
void
InitBufTable
(
int
size
)
InitBufTable
(
void
)
{
{
HASHCTL
info
;
HASHCTL
info
;
...
@@ -50,7 +50,7 @@ InitBufTable(int size)
...
@@ -50,7 +50,7 @@ InitBufTable(int size)
info
.
hash
=
tag_hash
;
info
.
hash
=
tag_hash
;
SharedBufHash
=
ShmemInitHash
(
"Shared Buffer Lookup Table"
,
SharedBufHash
=
ShmemInitHash
(
"Shared Buffer Lookup Table"
,
size
,
size
,
NBuffers
,
NBuffers
,
&
info
,
&
info
,
HASH_ELEM
|
HASH_FUNCTION
);
HASH_ELEM
|
HASH_FUNCTION
);
...
@@ -58,63 +58,79 @@ InitBufTable(int size)
...
@@ -58,63 +58,79 @@ InitBufTable(int size)
elog
(
FATAL
,
"could not initialize shared buffer hash table"
);
elog
(
FATAL
,
"could not initialize shared buffer hash table"
);
}
}
/*
BufferDesc
*
* BufTableLookup
*/
int
BufTableLookup
(
BufferTag
*
tagPtr
)
BufTableLookup
(
BufferTag
*
tagPtr
)
{
{
BufferLookupEnt
*
result
;
BufferLookupEnt
*
result
;
if
(
tagPtr
->
blockNum
==
P_NEW
)
if
(
tagPtr
->
blockNum
==
P_NEW
)
return
-
1
;
return
NULL
;
result
=
(
BufferLookupEnt
*
)
result
=
(
BufferLookupEnt
*
)
hash_search
(
SharedBufHash
,
(
void
*
)
tagPtr
,
HASH_FIND
,
NULL
);
hash_search
(
SharedBufHash
,
(
void
*
)
tagPtr
,
HASH_FIND
,
NULL
);
if
(
!
result
)
if
(
!
result
)
return
-
1
;
return
NULL
;
return
result
->
id
;
return
&
(
BufferDescriptors
[
result
->
id
])
;
}
}
/*
/*
* BufTableDelete
* BufTableDelete
*/
*/
bool
bool
BufTable
Insert
(
BufferTag
*
tagPtr
,
Buffer
buf_id
)
BufTable
Delete
(
BufferDesc
*
buf
)
{
{
BufferLookupEnt
*
result
;
BufferLookupEnt
*
result
;
bool
found
;
result
=
(
BufferLookupEnt
*
)
/*
hash_search
(
SharedBufHash
,
(
void
*
)
tagPtr
,
HASH_ENTER
,
&
found
);
* buffer not initialized or has been removed from table already.
* BM_DELETED keeps us from removing buffer twice.
*/
if
(
buf
->
flags
&
BM_DELETED
)
return
TRUE
;
if
(
!
result
)
buf
->
flags
|=
BM_DELETED
;
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of shared memory"
)));
if
(
found
)
/* found something else in the table? */
result
=
(
BufferLookupEnt
*
)
hash_search
(
SharedBufHash
,
(
void
*
)
&
(
buf
->
tag
),
HASH_REMOVE
,
NULL
);
if
(
!
result
)
/* shouldn't happen */
elog
(
ERROR
,
"shared buffer hash table corrupted"
);
elog
(
ERROR
,
"shared buffer hash table corrupted"
);
result
->
id
=
buf_id
;
/*
* Clear the buffer's tag. This doesn't matter for the hash table,
* since the buffer is already removed from it, but it ensures that
* sequential searches through the buffer table won't think the buffer
* is still valid for its old page.
*/
buf
->
tag
.
rnode
.
relNode
=
InvalidOid
;
buf
->
tag
.
rnode
.
tblNode
=
InvalidOid
;
return
TRUE
;
return
TRUE
;
}
}
/*
* BufTableDelete
*/
bool
bool
BufTable
Delete
(
BufferTag
*
tagPtr
)
BufTable
Insert
(
BufferDesc
*
buf
)
{
{
BufferLookupEnt
*
result
;
BufferLookupEnt
*
result
;
bool
found
;
/* cannot insert it twice */
Assert
(
buf
->
flags
&
BM_DELETED
);
buf
->
flags
&=
~
(
BM_DELETED
);
result
=
(
BufferLookupEnt
*
)
result
=
(
BufferLookupEnt
*
)
hash_search
(
SharedBufHash
,
(
void
*
)
tagPtr
,
HASH_REMOVE
,
NULL
);
hash_search
(
SharedBufHash
,
(
void
*
)
&
(
buf
->
tag
),
HASH_ENTER
,
&
found
);
if
(
!
result
)
/* shouldn't happen */
if
(
!
result
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of shared memory"
)));
if
(
found
)
/* found something else in the table? */
elog
(
ERROR
,
"shared buffer hash table corrupted"
);
elog
(
ERROR
,
"shared buffer hash table corrupted"
);
result
->
id
=
buf
->
buf_id
;
return
TRUE
;
return
TRUE
;
}
}
...
...
src/backend/storage/buffer/bufmgr.c
View file @
923e994d
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.14
2 2003/11/13 00:40:01
wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.14
3 2003/11/13 05:34:58
wieck Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -260,8 +260,12 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum,
...
@@ -260,8 +260,12 @@ ReadBufferInternal(Relation reln, BlockNumber blockNum,
if
(
status
==
SM_FAIL
)
if
(
status
==
SM_FAIL
)
{
{
/* IO Failed. cleanup the data structures and go home */
/* IO Failed. cleanup the data structures and go home */
StrategyInvalidateBuffer
(
bufHdr
);
if
(
!
BufTableDelete
(
bufHdr
))
{
LWLockRelease
(
BufMgrLock
);
elog
(
FATAL
,
"buffer table broken after I/O error"
);
}
/* remember that BufferAlloc() pinned the buffer */
/* remember that BufferAlloc() pinned the buffer */
UnpinBuffer
(
bufHdr
);
UnpinBuffer
(
bufHdr
);
...
@@ -314,7 +318,7 @@ BufferAlloc(Relation reln,
...
@@ -314,7 +318,7 @@ BufferAlloc(Relation reln,
INIT_BUFFERTAG
(
&
newTag
,
reln
,
blockNum
);
INIT_BUFFERTAG
(
&
newTag
,
reln
,
blockNum
);
/* see if the block is in the buffer pool already */
/* see if the block is in the buffer pool already */
buf
=
StrategyBufferLookup
(
&
newTag
,
false
);
buf
=
BufTableLookup
(
&
newTag
);
if
(
buf
!=
NULL
)
if
(
buf
!=
NULL
)
{
{
/*
/*
...
@@ -375,7 +379,7 @@ BufferAlloc(Relation reln,
...
@@ -375,7 +379,7 @@ BufferAlloc(Relation reln,
inProgress
=
FALSE
;
inProgress
=
FALSE
;
for
(
buf
=
(
BufferDesc
*
)
NULL
;
buf
==
(
BufferDesc
*
)
NULL
;)
for
(
buf
=
(
BufferDesc
*
)
NULL
;
buf
==
(
BufferDesc
*
)
NULL
;)
{
{
buf
=
StrategyGet
Buffer
();
buf
=
GetFree
Buffer
();
/* GetFreeBuffer will abort if it can't find a free buffer */
/* GetFreeBuffer will abort if it can't find a free buffer */
Assert
(
buf
);
Assert
(
buf
);
...
@@ -488,7 +492,7 @@ BufferAlloc(Relation reln,
...
@@ -488,7 +492,7 @@ BufferAlloc(Relation reln,
* we haven't gotten around to insert the new tag into the
* we haven't gotten around to insert the new tag into the
* buffer table. So we need to check here. -ay 3/95
* buffer table. So we need to check here. -ay 3/95
*/
*/
buf2
=
StrategyBufferLookup
(
&
newTag
,
true
);
buf2
=
BufTableLookup
(
&
newTag
);
if
(
buf2
!=
NULL
)
if
(
buf2
!=
NULL
)
{
{
/*
/*
...
@@ -531,12 +535,29 @@ BufferAlloc(Relation reln,
...
@@ -531,12 +535,29 @@ BufferAlloc(Relation reln,
*/
*/
/*
/*
* Tell the buffer replacement strategy that we are replacing the
* Change the name of the buffer in the lookup table:
* buffer content. Then rename the buffer.
*
* Need to update the lookup table before the read starts. If someone
* comes along looking for the buffer while we are reading it in, we
* don't want them to allocate a new buffer. For the same reason, we
* didn't want to erase the buf table entry for the buffer we were
* writing back until now, either.
*/
*/
StrategyReplaceBuffer
(
buf
,
reln
,
blockNum
);
if
(
!
BufTableDelete
(
buf
))
{
LWLockRelease
(
BufMgrLock
);
elog
(
FATAL
,
"buffer wasn't in the buffer hash table"
);
}
INIT_BUFFERTAG
(
&
(
buf
->
tag
),
reln
,
blockNum
);
INIT_BUFFERTAG
(
&
(
buf
->
tag
),
reln
,
blockNum
);
if
(
!
BufTableInsert
(
buf
))
{
LWLockRelease
(
BufMgrLock
);
elog
(
FATAL
,
"buffer in buffer hash table twice"
);
}
/*
/*
* Buffer contents are currently invalid. Have to mark IO IN PROGRESS
* Buffer contents are currently invalid. Have to mark IO IN PROGRESS
* so no one fiddles with them until the read completes. If this
* so no one fiddles with them until the read completes. If this
...
@@ -688,28 +709,13 @@ BufferSync(void)
...
@@ -688,28 +709,13 @@ BufferSync(void)
BufferDesc
*
bufHdr
;
BufferDesc
*
bufHdr
;
ErrorContextCallback
errcontext
;
ErrorContextCallback
errcontext
;
int
num_buffer_dirty
;
int
*
buffer_dirty
;
/* Setup error traceback support for ereport() */
/* Setup error traceback support for ereport() */
errcontext
.
callback
=
buffer_write_error_callback
;
errcontext
.
callback
=
buffer_write_error_callback
;
errcontext
.
arg
=
NULL
;
errcontext
.
arg
=
NULL
;
errcontext
.
previous
=
error_context_stack
;
errcontext
.
previous
=
error_context_stack
;
error_context_stack
=
&
errcontext
;
error_context_stack
=
&
errcontext
;
/*
for
(
i
=
0
,
bufHdr
=
BufferDescriptors
;
i
<
NBuffers
;
i
++
,
bufHdr
++
)
* Get a list of all currently dirty buffers and how many there are.
* We do not flush buffers that get dirtied after we started. They
* have to wait until the next checkpoint.
*/
buffer_dirty
=
(
int
*
)
palloc
(
NBuffers
*
sizeof
(
int
));
num_buffer_dirty
=
0
;
LWLockAcquire
(
BufMgrLock
,
LW_EXCLUSIVE
);
num_buffer_dirty
=
StrategyDirtyBufferList
(
buffer_dirty
,
NBuffers
);
LWLockRelease
(
BufMgrLock
);
for
(
i
=
0
;
i
<
num_buffer_dirty
;
i
++
)
{
{
Buffer
buffer
;
Buffer
buffer
;
int
status
;
int
status
;
...
@@ -717,11 +723,10 @@ BufferSync(void)
...
@@ -717,11 +723,10 @@ BufferSync(void)
XLogRecPtr
recptr
;
XLogRecPtr
recptr
;
Relation
reln
;
Relation
reln
;
LWLockAcquire
(
BufMgrLock
,
LW_EXCLUSIVE
);
bufHdr
=
&
BufferDescriptors
[
buffer_dirty
[
i
]];
errcontext
.
arg
=
bufHdr
;
errcontext
.
arg
=
bufHdr
;
LWLockAcquire
(
BufMgrLock
,
LW_EXCLUSIVE
);
if
(
!
(
bufHdr
->
flags
&
BM_VALID
))
if
(
!
(
bufHdr
->
flags
&
BM_VALID
))
{
{
LWLockRelease
(
BufMgrLock
);
LWLockRelease
(
BufMgrLock
);
...
@@ -850,8 +855,6 @@ BufferSync(void)
...
@@ -850,8 +855,6 @@ BufferSync(void)
RelationDecrementReferenceCount
(
reln
);
RelationDecrementReferenceCount
(
reln
);
}
}
pfree
(
buffer_dirty
);
/* Pop the error context stack */
/* Pop the error context stack */
error_context_stack
=
errcontext
.
previous
;
error_context_stack
=
errcontext
.
previous
;
}
}
...
@@ -956,9 +959,9 @@ AtEOXact_Buffers(bool isCommit)
...
@@ -956,9 +959,9 @@ AtEOXact_Buffers(bool isCommit)
if
(
isCommit
)
if
(
isCommit
)
elog
(
WARNING
,
elog
(
WARNING
,
"buffer refcount leak: [%03d] (
bufNext
=%d, "
"buffer refcount leak: [%03d] (
freeNext=%d, freePrev
=%d, "
"rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)"
,
"rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)"
,
i
,
buf
->
bufNext
,
i
,
buf
->
freeNext
,
buf
->
freePrev
,
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
,
buf
->
tag
.
rnode
.
tblNode
,
buf
->
tag
.
rnode
.
relNode
,
buf
->
tag
.
blockNum
,
buf
->
flags
,
buf
->
tag
.
blockNum
,
buf
->
flags
,
buf
->
refcount
,
PrivateRefCount
[
i
]);
buf
->
refcount
,
PrivateRefCount
[
i
]);
...
@@ -1226,7 +1229,7 @@ recheck:
...
@@ -1226,7 +1229,7 @@ recheck:
/*
/*
* And mark the buffer as no longer occupied by this rel.
* And mark the buffer as no longer occupied by this rel.
*/
*/
StrategyInvalidateBuffer
(
bufHdr
);
BufTableDelete
(
bufHdr
);
}
}
}
}
...
@@ -1292,7 +1295,7 @@ recheck:
...
@@ -1292,7 +1295,7 @@ recheck:
/*
/*
* And mark the buffer as no longer occupied by this page.
* And mark the buffer as no longer occupied by this page.
*/
*/
StrategyInvalidateBuffer
(
bufHdr
);
BufTableDelete
(
bufHdr
);
}
}
}
}
...
@@ -1540,7 +1543,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
...
@@ -1540,7 +1543,7 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
return
-
2
;
return
-
2
;
}
}
if
(
bufHdr
->
tag
.
blockNum
>=
firstDelBlock
)
if
(
bufHdr
->
tag
.
blockNum
>=
firstDelBlock
)
StrategyInvalidateBuffer
(
bufHdr
);
BufTableDelete
(
bufHdr
);
}
}
}
}
...
...
src/backend/storage/buffer/freelist.c
View file @
923e994d
This diff is collapsed.
Click to expand it.
src/backend/utils/misc/guc.c
View file @
923e994d
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.16
7 2003/11/13 00:40:01
wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.16
8 2003/11/13 05:34:58
wieck Exp $
*
*
*--------------------------------------------------------------------
*--------------------------------------------------------------------
*/
*/
...
@@ -73,7 +73,6 @@ extern int CheckPointTimeout;
...
@@ -73,7 +73,6 @@ extern int CheckPointTimeout;
extern
int
CommitDelay
;
extern
int
CommitDelay
;
extern
int
CommitSiblings
;
extern
int
CommitSiblings
;
extern
char
*
preload_libraries_string
;
extern
char
*
preload_libraries_string
;
extern
int
BufferStrategyStatInterval
;
#ifdef HAVE_SYSLOG
#ifdef HAVE_SYSLOG
extern
char
*
Syslog_facility
;
extern
char
*
Syslog_facility
;
...
@@ -1191,15 +1190,6 @@ static struct config_int ConfigureNamesInt[] =
...
@@ -1191,15 +1190,6 @@ static struct config_int ConfigureNamesInt[] =
-
1
,
-
1
,
INT_MAX
/
1000
,
NULL
,
NULL
-
1
,
-
1
,
INT_MAX
/
1000
,
NULL
,
NULL
},
},
{
{
"buffer_strategy_status_interval"
,
PGC_POSTMASTER
,
RESOURCES_MEM
,
gettext_noop
(
"Interval to report buffer strategy status in seconds"
),
NULL
},
&
BufferStrategyStatInterval
,
0
,
0
,
600
,
NULL
,
NULL
},
/* End-of-list marker */
/* End-of-list marker */
{
{
{
NULL
,
0
,
0
,
NULL
,
NULL
},
NULL
,
0
,
0
,
0
,
NULL
,
NULL
{
NULL
,
0
,
0
,
NULL
,
NULL
},
NULL
,
0
,
0
,
0
,
NULL
,
NULL
...
...
src/backend/utils/misc/postgresql.conf.sample
View file @
923e994d
...
@@ -58,7 +58,6 @@
...
@@ -58,7 +58,6 @@
#shared_buffers = 1000 # min 16, at least max_connections*2, 8KB each
#shared_buffers = 1000 # min 16, at least max_connections*2, 8KB each
#sort_mem = 1024 # min 64, size in KB
#sort_mem = 1024 # min 64, size in KB
#vacuum_mem = 8192 # min 1024, size in KB
#vacuum_mem = 8192 # min 1024, size in KB
#buffer_strategy_status_interval = 0 # 0-600 seconds
# - Free Space Map -
# - Free Space Map -
...
...
src/include/miscadmin.h
View file @
923e994d
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: miscadmin.h,v 1.13
5 2003/11/13 00:40:01
wieck Exp $
* $Id: miscadmin.h,v 1.13
6 2003/11/13 05:34:58
wieck Exp $
*
*
* NOTES
* NOTES
* some of the information in this file should be moved to
* some of the information in this file should be moved to
...
@@ -96,13 +96,6 @@ extern void ProcessInterrupts(void);
...
@@ -96,13 +96,6 @@ extern void ProcessInterrupts(void);
CritSectionCount--; \
CritSectionCount--; \
} while(0)
} while(0)
#define PG_DELAY(_msec) \
{ \
struct timeval delay; \
delay.tv_sec = (_msec) / 1000; \
delay.tv_usec = ((_msec) % 1000) * 1000; \
(void) select(0, NULL, NULL, NULL, &delay); \
}
/*****************************************************************************
/*****************************************************************************
* globals.h -- *
* globals.h -- *
...
...
src/include/storage/buf_internals.h
View file @
923e994d
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: buf_internals.h,v 1.6
2 2003/11/13 00:40:02
wieck Exp $
* $Id: buf_internals.h,v 1.6
3 2003/11/13 05:34:58
wieck Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -72,29 +72,17 @@ typedef struct buftag
...
@@ -72,29 +72,17 @@ typedef struct buftag
(a)->rnode = (xx_reln)->rd_node \
(a)->rnode = (xx_reln)->rd_node \
)
)
#define BUFFERTAG_EQUALS(a,xx_reln,xx_blockNum) \
( \
(a)->rnode.tblNode == (xx_reln)->rd_node.tblNode && \
(a)->rnode.relNode == (xx_reln)->rd_node.relNode && \
(a)->blockNum == (xx_blockNum) \
)
#define BUFFERTAGS_EQUAL(a,b) \
( \
(a)->rnode.tblNode == (b)->rnode.tblNode && \
(a)->rnode.relNode == (b)->rnode.relNode && \
(a)->blockNum == (b)->blockNum \
)
/*
/*
* BufferDesc -- shared buffer cache metadata for a single
* BufferDesc -- shared buffer cache metadata for a single
* shared buffer descriptor.
* shared buffer descriptor.
*/
*/
typedef
struct
sbufdesc
typedef
struct
sbufdesc
{
{
Buffer
bufNext
;
/* link in freelist chain */
Buffer
freeNext
;
/* links for freelist chain */
Buffer
freePrev
;
SHMEM_OFFSET
data
;
/* pointer to data in buf pool */
SHMEM_OFFSET
data
;
/* pointer to data in buf pool */
/* tag and id must be together for table lookup */
/* tag and id must be together for table lookup
(still true?)
*/
BufferTag
tag
;
/* file/block identifier */
BufferTag
tag
;
/* file/block identifier */
int
buf_id
;
/* buffer's index number (from 0) */
int
buf_id
;
/* buffer's index number (from 0) */
...
@@ -119,7 +107,6 @@ typedef struct sbufdesc
...
@@ -119,7 +107,6 @@ typedef struct sbufdesc
#define BufferDescriptorGetBuffer(bdesc) ((bdesc)->buf_id + 1)
#define BufferDescriptorGetBuffer(bdesc) ((bdesc)->buf_id + 1)
/*
/*
* Each backend has its own BufferLocks[] array holding flag bits
* Each backend has its own BufferLocks[] array holding flag bits
* showing what locks it has set on each buffer.
* showing what locks it has set on each buffer.
...
@@ -180,19 +167,14 @@ extern long int LocalBufferFlushCount;
...
@@ -180,19 +167,14 @@ extern long int LocalBufferFlushCount;
/*freelist.c*/
/*freelist.c*/
extern
void
PinBuffer
(
BufferDesc
*
buf
);
extern
void
PinBuffer
(
BufferDesc
*
buf
);
extern
void
UnpinBuffer
(
BufferDesc
*
buf
);
extern
void
UnpinBuffer
(
BufferDesc
*
buf
);
extern
BufferDesc
*
StrategyBufferLookup
(
BufferTag
*
tagPtr
,
bool
recheck
);
extern
BufferDesc
*
GetFreeBuffer
(
void
);
extern
BufferDesc
*
StrategyGetBuffer
(
void
);
extern
void
InitFreeList
(
bool
init
);
extern
void
StrategyReplaceBuffer
(
BufferDesc
*
buf
,
Relation
rnode
,
BlockNumber
blockNum
);
extern
void
StrategyInvalidateBuffer
(
BufferDesc
*
buf
);
extern
void
StrategyHintVacuum
(
bool
vacuum_active
);
extern
int
StrategyDirtyBufferList
(
int
*
buffer_dirty
,
int
max_buffers
);
extern
void
StrategyInitialize
(
bool
init
);
/* buf_table.c */
/* buf_table.c */
extern
void
InitBufTable
(
int
size
);
extern
void
InitBufTable
(
void
);
extern
int
BufTableLookup
(
BufferTag
*
tagPtr
);
extern
BufferDesc
*
BufTableLookup
(
BufferTag
*
tagPtr
);
extern
bool
BufTable
Insert
(
BufferTag
*
tagPtr
,
Buffer
buf_id
);
extern
bool
BufTable
Delete
(
BufferDesc
*
buf
);
extern
bool
BufTable
Delete
(
BufferTag
*
tagPtr
);
extern
bool
BufTable
Insert
(
BufferDesc
*
buf
);
/* bufmgr.c */
/* bufmgr.c */
extern
BufferDesc
*
BufferDescriptors
;
extern
BufferDesc
*
BufferDescriptors
;
...
...
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