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
fa3bd4db
Commit
fa3bd4db
authored
21 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Error message editing: finish up undone task of reporting the problem
xid when we fail to access pg_clog.
parent
2a4a0c4d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/access/transam/slru.c
+49
-30
49 additions, 30 deletions
src/backend/access/transam/slru.c
with
49 additions
and
30 deletions
src/backend/access/transam/slru.c
+
49
−
30
View file @
fa3bd4db
/*-------------------------------------------------------------------------
*
* slru.c
* Simple LRU
* Simple LRU
buffering for transaction status logfiles
*
* This module replaces the old "pg_log" access code, which treated pg_log
* essentially like a relation, in that it went through the regular buffer
* manager. The problem with that was that there wasn't any good way to
* recycle storage space for transactions so old that they'll never be
* looked up again. Now we use specialized access code so that the commit
* log can be broken into relatively small, independent segments.
*
* Portions Copyright (c) 2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/slru.c,v 1.
1
2003/0
6
/1
1
2
2
:37:
45 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/slru.c,v 1.
2
2003/0
7
/1
9
2
1
:37:
37 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -363,7 +356,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, TransactionId xid, bool forwrite)
LWLockRelease
(
ctl
->
locks
->
BufferLocks
[
slotno
]);
/* Now it's okay to e
log
if we failed */
/* Now it's okay to e
report
if we failed */
if
(
!
ok
)
SlruReportIOError
(
ctl
,
pageno
,
xid
);
...
...
@@ -449,7 +442,7 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
LWLockRelease
(
ctl
->
locks
->
BufferLocks
[
slotno
]);
/* Now it's okay to e
log
if we failed */
/* Now it's okay to e
report
if we failed */
if
(
!
ok
)
SlruReportIOError
(
ctl
,
pageno
,
InvalidTransactionId
);
}
...
...
@@ -457,7 +450,7 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
/*
* Physical read of a (previously existing) page into a buffer slot
*
* On failure, we cannot just e
log
(ERROR) since caller has put state in
* On failure, we cannot just e
report
(ERROR) since caller has put state in
* shared memory that must be undone. So, we return FALSE and save enough
* info in static variables to let SlruReportIOError make the report.
*
...
...
@@ -493,7 +486,9 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
return
false
;
}
elog
(
LOG
,
"file %s doesn't exist, reading as zeroes"
,
path
);
ereport
(
LOG
,
(
errmsg
(
"file
\"
%s
\"
doesn't exist, reading as zeroes"
,
path
)));
MemSet
(
shared
->
page_buffer
[
slotno
],
0
,
BLCKSZ
);
return
true
;
}
...
...
@@ -520,7 +515,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
/*
* Physical write of a page from a buffer slot
*
* On failure, we cannot just e
log
(ERROR) since caller has put state in
* On failure, we cannot just e
report
(ERROR) since caller has put state in
* shared memory that must be undone. So, we return FALSE and save enough
* info in static variables to let SlruReportIOError make the report.
*
...
...
@@ -606,33 +601,49 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
int
offset
=
rpageno
*
BLCKSZ
;
char
path
[
MAXPGPATH
];
/* XXX TODO: provide xid as context in error messages */
SlruFileName
(
ctl
,
path
,
segno
);
errno
=
slru_errno
;
switch
(
slru_errcause
)
{
case
SLRU_OPEN_FAILED
:
elog
(
ERROR
,
"open of %s failed: %m"
,
path
);
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not access status of transaction %u"
,
xid
),
errdetail
(
"open of file
\"
%s
\"
failed: %m"
,
path
)));
break
;
case
SLRU_CREATE_FAILED
:
elog
(
ERROR
,
"creation of file %s failed: %m"
,
path
);
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not access status of transaction %u"
,
xid
),
errdetail
(
"creation of file
\"
%s
\"
failed: %m"
,
path
)));
break
;
case
SLRU_SEEK_FAILED
:
elog
(
ERROR
,
"lseek of file %s, offset %u failed: %m"
,
path
,
offset
);
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not access status of transaction %u"
,
xid
),
errdetail
(
"lseek of file
\"
%s
\"
, offset %u failed: %m"
,
path
,
offset
)));
break
;
case
SLRU_READ_FAILED
:
elog
(
ERROR
,
"read of file %s, offset %u failed: %m"
,
path
,
offset
);
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not access status of transaction %u"
,
xid
),
errdetail
(
"read of file
\"
%s
\"
, offset %u failed: %m"
,
path
,
offset
)));
break
;
case
SLRU_WRITE_FAILED
:
elog
(
ERROR
,
"write of file %s, offset %u failed: %m"
,
path
,
offset
);
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not access status of transaction %u"
,
xid
),
errdetail
(
"write of file
\"
%s
\"
, offset %u failed: %m"
,
path
,
offset
)));
break
;
default:
/* can't get here, we trust */
elog
(
ERROR
,
"unknown SimpleLru I/O error"
);
elog
(
ERROR
,
"unrecognized SimpleLru error cause: %d"
,
(
int
)
slru_errcause
);
break
;
}
}
...
...
@@ -799,7 +810,9 @@ restart:;
if
(
ctl
->
PagePrecedes
(
shared
->
latest_page_number
,
cutoffPage
))
{
LWLockRelease
(
ctl
->
locks
->
ControlLock
);
elog
(
LOG
,
"unable to truncate %s: apparent wraparound"
,
ctl
->
Dir
);
ereport
(
LOG
,
(
errmsg
(
"unable to truncate
\"
%s
\"
: apparent wraparound"
,
ctl
->
Dir
)));
return
;
}
...
...
@@ -855,7 +868,9 @@ SlruScanDirectory(SlruCtl ctl, int cutoffPage, bool doDeletions)
cldir
=
opendir
(
ctl
->
Dir
);
if
(
cldir
==
NULL
)
elog
(
ERROR
,
"could not open directory (%s): %m"
,
ctl
->
Dir
);
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not open directory
\"
%s
\"
: %m"
,
ctl
->
Dir
)));
errno
=
0
;
while
((
clde
=
readdir
(
cldir
))
!=
NULL
)
...
...
@@ -870,7 +885,9 @@ SlruScanDirectory(SlruCtl ctl, int cutoffPage, bool doDeletions)
found
=
true
;
if
(
doDeletions
)
{
elog
(
LOG
,
"removing file %s/%s"
,
ctl
->
Dir
,
clde
->
d_name
);
ereport
(
LOG
,
(
errmsg
(
"removing file
\"
%s/%s
\"
"
,
ctl
->
Dir
,
clde
->
d_name
)));
snprintf
(
path
,
MAXPGPATH
,
"%s/%s"
,
ctl
->
Dir
,
clde
->
d_name
);
unlink
(
path
);
}
...
...
@@ -879,7 +896,9 @@ SlruScanDirectory(SlruCtl ctl, int cutoffPage, bool doDeletions)
errno
=
0
;
}
if
(
errno
)
elog
(
ERROR
,
"could not read directory (%s): %m"
,
ctl
->
Dir
);
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not read directory
\"
%s
\"
: %m"
,
ctl
->
Dir
)));
closedir
(
cldir
);
return
found
;
...
...
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