Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
94a5c4a0
Commit
94a5c4a0
authored
19 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Use posix_fadvise() to avoid kernel caching of WAL contents on WAL file
close. ITAGAKI Takahiro
parent
a584c124
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/access/transam/xlog.c
+33
-25
33 additions, 25 deletions
src/backend/access/transam/xlog.c
with
33 additions
and
25 deletions
src/backend/access/transam/xlog.c
+
33
−
25
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/0
4/20 04:07:38 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.23
8
2006/0
6/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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment