PROC_VACUUM_FOR_WRAPAROUND doesn't work expectedly
От | ITAGAKI Takahiro |
---|---|
Тема | PROC_VACUUM_FOR_WRAPAROUND doesn't work expectedly |
Дата | |
Msg-id | 20080314103837.63D3.52131E4D@oss.ntt.co.jp обсуждение исходный текст |
Ответы |
Re: PROC_VACUUM_FOR_WRAPAROUND doesn't work expectedly
Re: PROC_VACUUM_FOR_WRAPAROUND doesn't work expectedly |
Список | pgsql-hackers |
I found autovacuum can be canceled by blocked backends even if the vacuum is for preventing XID wraparound in 8.3.0 and HEAD. Autovacuum sets PROC_VACUUM_FOR_WRAPAROUND flag just before vacuum, but the flag will be cleared at the beginning of vacuum; PROC_VACUUM_FOR_WRAPAROUND is not set during the vacuum. The sequence is below: vacuum()-> CommitTransactionCommand() -> ProcArrayEndTransaction() -> proc->vacuumFlags &= ~PROC_VACUUM_STATE_MASK;->vacuum_rel() PROC_VACUUM_STATE_MASK is defined as (0x0E), that is including PROC_VACUUM_FOR_WRAPAROUND (0x08). The wraparound flag is cleared before vacuum tasks. I tried to make a patch to exclude PROC_VACUUM_FOR_WRAPAROUND from PROC_VACUUM_STATE_MASK and make autovacuum workers to clear PROC_VACUUM_FOR_WRAPAROUND by themselves. Is it a reasonable solution? Index: src/backend/postmaster/autovacuum.c =================================================================== --- src/backend/postmaster/autovacuum.c (HEAD) +++ src/backend/postmaster/autovacuum.c (working copy) @@ -2163,6 +2163,12 @@ PG_END_TRY(); /* the PGPROC flags are reset at the next end of transaction */ + if (tab->at_wraparound) + { + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); + MyProc->vacuumFlags &= ~PROC_VACUUM_FOR_WRAPAROUND; + LWLockRelease(ProcArrayLock); + } /* be tidy */ pfree(tab); Index: src/include/storage/proc.h =================================================================== --- src/include/storage/proc.h (HEAD) +++ src/include/storage/proc.h (working copy) @@ -45,7 +45,7 @@#define PROC_VACUUM_FOR_WRAPAROUND 0x08 /* set by autovac only *//* flags reset at EOXact*/ -#define PROC_VACUUM_STATE_MASK (0x0E) +#define PROC_VACUUM_STATE_MASK (PROC_IN_VACUUM | PROC_IN_ANALYZE)/* * Each backend has a PGPROC struct in sharedmemory. There is also a list of Regards, --- ITAGAKI Takahiro NTT Open Source Software Center
В списке pgsql-hackers по дате отправления: