Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdbe4876

Browse files
committed
Extract catalog info for error reporting before an error actually happens.
Also, remove redundant reset of for-wraparound PGPROC flag.Thanks to Tom Lane for noticing both bogosities.
1 parentfcc20bd commitdbe4876

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.63 2007/10/24 20:55:36 alvherre Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.64 2007/10/25 14:45:55 alvherre Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -1994,6 +1994,9 @@ do_autovacuum(void)
19941994
autovac_table*tab;
19951995
WorkerInfoworker;
19961996
boolskipit;
1997+
char*datname,
1998+
*nspname,
1999+
*relname;
19972000

19982001
CHECK_FOR_INTERRUPTS();
19992002

@@ -2094,6 +2097,17 @@ do_autovacuum(void)
20942097
LWLockRelease(ProcArrayLock);
20952098
}
20962099

2100+
/*
2101+
* Save the relation name for a possible error message, to avoid a
2102+
* catalog lookup in case of an error. We do it in
2103+
* TopTransactionContext so that they go away automatically in the next
2104+
* iteration.
2105+
*/
2106+
MemoryContextSwitchTo(TopTransactionContext);
2107+
datname=get_database_name(MyDatabaseId);
2108+
nspname=get_namespace_name(get_rel_namespace(tab->at_relid));
2109+
relname=get_rel_name(tab->at_relid);
2110+
20972111
/*
20982112
* We will abort vacuuming the current table if something errors out,
20992113
* and continue with the next one in schedule; in particular, this
@@ -2102,7 +2116,6 @@ do_autovacuum(void)
21022116
PG_TRY();
21032117
{
21042118
/* have at it */
2105-
MemoryContextSwitchTo(TopTransactionContext);
21062119
autovacuum_do_vac_analyze(tab->at_relid,
21072120
tab->at_dovacuum,
21082121
tab->at_doanalyze,
@@ -2118,14 +2131,10 @@ do_autovacuum(void)
21182131
HOLD_INTERRUPTS();
21192132
if (tab->at_dovacuum)
21202133
errcontext("automatic vacuum of table \"%s.%s.%s\"",
2121-
get_database_name(MyDatabaseId),
2122-
get_namespace_name(get_rel_namespace(tab->at_relid)),
2123-
get_rel_name(tab->at_relid));
2134+
datname,nspname,relname);
21242135
else
21252136
errcontext("automatic analyze of table \"%s.%s.%s\"",
2126-
get_database_name(MyDatabaseId),
2127-
get_namespace_name(get_rel_namespace(tab->at_relid)),
2128-
get_rel_name(tab->at_relid));
2137+
datname,nspname,relname);
21292138
EmitErrorReport();
21302139

21312140
/* this resets the PGPROC flags too */
@@ -2139,13 +2148,7 @@ do_autovacuum(void)
21392148
}
21402149
PG_END_TRY();
21412150

2142-
/* reset my PGPROC flag */
2143-
if (tab->at_wraparound)
2144-
{
2145-
LWLockAcquire(ProcArrayLock,LW_EXCLUSIVE);
2146-
MyProc->vacuumFlags &= ~PROC_VACUUM_FOR_WRAPAROUND;
2147-
LWLockRelease(ProcArrayLock);
2148-
}
2151+
/* the PGPROC flags are reset at the next end of transaction */
21492152

21502153
/* be tidy */
21512154
pfree(tab);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp