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
94a5c4a0
Commit
94a5c4a0
authored
Jun 15, 2006
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use posix_fadvise() to avoid kernel caching of WAL contents on WAL file
close. ITAGAKI Takahiro
parent
a584c124
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
25 deletions
+33
-25
src/backend/access/transam/xlog.c
src/backend/access/transam/xlog.c
+33
-25
No files found.
src/backend/access/transam/xlog.c
View file @
94a5c4a0
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.23
7 2006/04/20 04:07:38 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.23
8 2006/06/15 19:15:00 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -478,6 +478,7 @@ static bool InstallXLogFileSegment(uint32 *log, uint32 *seg, char *tmppath,
bool
use_lock
);
static
int
XLogFileOpen
(
uint32
log
,
uint32
seg
);
static
int
XLogFileRead
(
uint32
log
,
uint32
seg
,
int
emode
);
static
void
XLogFileClose
(
void
);
static
bool
RestoreArchivedFile
(
char
*
path
,
const
char
*
xlogfname
,
const
char
*
recovername
,
off_t
expectedSize
);
static
int
PreallocXlogFiles
(
XLogRecPtr
endptr
);
...
...
@@ -1384,14 +1385,7 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
*/
Assert
(
npages
==
0
);
if
(
openLogFile
>=
0
)
{
if
(
close
(
openLogFile
))
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"could not close log file %u, segment %u: %m"
,
openLogId
,
openLogSeg
)));
openLogFile
=
-
1
;
}
XLogFileClose
();
XLByteToPrevSeg
(
LogwrtResult
.
Write
,
openLogId
,
openLogSeg
);
/* create/use new log file */
...
...
@@ -1567,14 +1561,7 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
{
if
(
openLogFile
>=
0
&&
!
XLByteInPrevSeg
(
LogwrtResult
.
Write
,
openLogId
,
openLogSeg
))
{
if
(
close
(
openLogFile
))
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"could not close log file %u, segment %u: %m"
,
openLogId
,
openLogSeg
)));
openLogFile
=
-
1
;
}
XLogFileClose
();
if
(
openLogFile
<
0
)
{
XLByteToPrevSeg
(
LogwrtResult
.
Write
,
openLogId
,
openLogSeg
);
...
...
@@ -2152,6 +2139,34 @@ XLogFileRead(uint32 log, uint32 seg, int emode)
return
-
1
;
}
/*
* Close the current logfile segment for writing.
*/
static
void
XLogFileClose
(
void
)
{
Assert
(
openLogFile
>=
0
);
#ifdef _POSIX_ADVISORY_INFO
/*
* WAL caches will not be accessed in the future, so we advise OS to
* free them. But we will not do so if WAL archiving is active,
* because archivers might use the caches to read the WAL segment.
* While O_DIRECT works for O_SYNC, posix_fadvise() works for fsync()
* and O_SYNC, and some platforms only have posix_fadvise().
*/
if
(
!
XLogArchivingActive
())
posix_fadvise
(
openLogFile
,
0
,
0
,
POSIX_FADV_DONTNEED
);
#endif
if
(
close
(
openLogFile
))
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"could not close log file %u, segment %u: %m"
,
openLogId
,
openLogSeg
)));
openLogFile
=
-
1
;
}
/*
* Attempt to retrieve the specified file from off-line archival storage.
* If successful, fill "path" with its complete path (note that this will be
...
...
@@ -5609,14 +5624,7 @@ assign_xlog_sync_method(const char *method, bool doit, GucSource source)
errmsg
(
"could not fsync log file %u, segment %u: %m"
,
openLogId
,
openLogSeg
)));
if
(
open_sync_bit
!=
new_sync_bit
)
{
if
(
close
(
openLogFile
))
ereport
(
PANIC
,
(
errcode_for_file_access
(),
errmsg
(
"could not close log file %u, segment %u: %m"
,
openLogId
,
openLogSeg
)));
openLogFile
=
-
1
;
}
XLogFileClose
();
}
sync_method
=
new_sync_method
;
open_sync_bit
=
new_sync_bit
;
...
...
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