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
49f68a85
Commit
49f68a85
authored
Jun 29, 1999
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid disk writes for read-only transactions.
parent
cffd0f9c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
29 deletions
+49
-29
src/backend/access/transam/xact.c
src/backend/access/transam/xact.c
+33
-28
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/bufmgr.c
+16
-1
No files found.
src/backend/access/transam/xact.c
View file @
49f68a85
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.4
1 1999/06/10 14:17:0
6 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.4
2 1999/06/29 04:54:4
6 vadim Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
...
...
@@ -158,6 +158,8 @@
#include <commands/sequence.h>
#include <libpq/be-fsstubs.h>
extern
bool
SharedBufferChanged
;
static
void
AbortTransaction
(
void
);
static
void
AtAbort_Cache
(
void
);
static
void
AtAbort_Locks
(
void
);
...
...
@@ -618,30 +620,36 @@ RecordTransactionCommit()
*/
xid
=
GetCurrentTransactionId
();
/*
----------------
/*
* flush the buffer manager pages. Note: if we have stable
* main memory, dirty shared buffers are not flushed
* plai 8/7/90
* ----------------
*/
leak
=
BufferPoolCheckLeak
();
/*
* If no one shared buffer was changed by this transaction then
* we don't flush shared buffers and don't record commit status.
*/
if
(
SharedBufferChanged
)
{
FlushBufferPool
(
!
TransactionFlushEnabled
());
if
(
leak
)
ResetBufferPool
();
/* ----------------
/*
* have the transaction access methods record the status
* of this transaction id in the pg_log / pg_time relations.
* ----------------
* of this transaction id in the pg_log relation.
*/
TransactionIdCommit
(
xid
);
/* ----------------
* Now write the log/time info to the disk too.
* ----------------
/*
* Now write the log info to the disk too.
*/
leak
=
BufferPoolCheckLeak
();
FlushBufferPool
(
!
TransactionFlushEnabled
());
}
if
(
leak
)
ResetBufferPool
();
}
...
...
@@ -731,19 +739,14 @@ RecordTransactionAbort()
*/
xid
=
GetCurrentTransactionId
();
/*
----------------
*
have the transaction access methods record the status
*
of this transaction id in the pg_log / pg_time relations.
*
----------------
/*
*
Have the transaction access methods record the status of
*
this transaction id in the pg_log relation. We skip it
*
if no one shared buffer was changed by this transaction.
*/
if
(
SharedBufferChanged
)
TransactionIdAbort
(
xid
);
/* ----------------
* flush the buffer manager pages. Note: if we have stable
* main memory, dirty shared buffers are not flushed
* plai 8/7/90
* ----------------
*/
ResetBufferPool
();
}
...
...
@@ -965,6 +968,7 @@ CommitTransaction()
* ----------------
*/
s
->
state
=
TRANS_DEFAULT
;
SharedBufferChanged
=
false
;
/* safest place to do it */
}
...
...
@@ -1028,6 +1032,7 @@ AbortTransaction()
* ----------------
*/
s
->
state
=
TRANS_DEFAULT
;
SharedBufferChanged
=
false
;
/* safest place to do it */
}
/* --------------------------------
...
...
src/backend/storage/buffer/bufmgr.c
View file @
49f68a85
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.5
5 1999/06/11 09:00:02
vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.5
6 1999/06/29 04:54:47
vadim Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -78,6 +78,15 @@ extern long int LocalBufferHitCount;
extern
long
int
BufferFlushCount
;
extern
long
int
LocalBufferFlushCount
;
/*
* It's used to avoid disk writes for read-only transactions
* (i.e. when no one shared buffer was changed by transaction).
* We set it to true in WriteBuffer/WriteNoReleaseBuffer when
* marking shared buffer as dirty. We set it to false in xact.c
* after transaction is committed/aborted.
*/
bool
SharedBufferChanged
=
false
;
static
int
WriteMode
=
BUFFER_LATE_WRITE
;
/* Delayed write is
* default */
...
...
@@ -699,6 +708,8 @@ WriteBuffer(Buffer buffer)
bufHdr
=
&
BufferDescriptors
[
buffer
-
1
];
SharedBufferChanged
=
true
;
SpinAcquire
(
BufMgrLock
);
Assert
(
bufHdr
->
refcount
>
0
);
bufHdr
->
flags
|=
(
BM_DIRTY
|
BM_JUST_DIRTIED
);
...
...
@@ -810,6 +821,8 @@ FlushBuffer(Buffer buffer, bool release)
bufrel
=
RelationIdCacheGetRelation
(
bufHdr
->
tag
.
relId
.
relId
);
Assert
(
bufrel
!=
(
Relation
)
NULL
);
SharedBufferChanged
=
true
;
/* To check if block content changed while flushing. - vadim 01/17/97 */
SpinAcquire
(
BufMgrLock
);
bufHdr
->
flags
&=
~
BM_JUST_DIRTIED
;
...
...
@@ -875,6 +888,8 @@ WriteNoReleaseBuffer(Buffer buffer)
bufHdr
=
&
BufferDescriptors
[
buffer
-
1
];
SharedBufferChanged
=
true
;
SpinAcquire
(
BufMgrLock
);
bufHdr
->
flags
|=
(
BM_DIRTY
|
BM_JUST_DIRTIED
);
SpinRelease
(
BufMgrLock
);
...
...
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