Re: Doubt about AccessExclusiveLock in ALTER TABLE .. SET ( .. );

Поиск
Список
Период
Сортировка
От Fabrízio de Royes Mello
Тема Re: Doubt about AccessExclusiveLock in ALTER TABLE .. SET ( .. );
Дата
Msg-id CAFcNs+rv1JT77i1S1GH+odzTGOE_vC33NF9rqE_XUqF2vP2iQw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Doubt about AccessExclusiveLock in ALTER TABLE .. SET ( .. );  (Fabrízio de Royes Mello <fabriziomello@gmail.com>)
Ответы Re: Doubt about AccessExclusiveLock in ALTER TABLE .. SET ( .. );  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers


On Mon, Mar 30, 2015 at 8:14 PM, Fabrízio de Royes Mello <fabriziomello@gmail.com> wrote:
>
>
>
> On Mon, Mar 30, 2015 at 7:41 PM, Jim Nasby <Jim.Nasby@bluetreble.com> wrote:
> >
> > On 3/27/15 2:23 PM, Fabrízio de Royes Mello wrote:
> >>
> >> Hi all,
> >>
> >> I'm tweaking some autovacuum settings in a table with high write usage
> >> but with ALTER TABLE .. SET ( .. ) this task was impossible, so I did a
> >> catalog update  (pg_class) to change reloptions.
> >>
> >> Maybe it's a stupid doubt, but why we need to get an AccessExclusiveLock
> >> on relation to set reloptions if we just touch in pg_class tuples
> >> (RowExclusiveLock) ?
> >
> >
> > For a very long time catalog access was not MVCC safe. I think that's been changed, so at this point it may be OK to relax the lock, at least in the case of autovac settings. There may well be other settings in there where it would not be safe.
> >
>
> Hummm.... There are a comment in AlterTableGetLockLevel:
>
>  3017                 /*
>  3018                  * Rel options are more complex than first appears. Options
>  3019                  * are set here for tables, views and indexes; for historical
>  3020                  * reasons these can all be used with ALTER TABLE, so we can't
>  3021                  * decide between them using the basic grammar.
>  3022                  *
>  3023                  * XXX Look in detail at each option to determine lock level,
>  3024                  * e.g. cmd_lockmode = GetRelOptionsLockLevel((List *)
>  3025                  * cmd->def);
>  3026                  */
>  3027             case AT_SetRelOptions:      /* Uses MVCC in getIndexes() and
>  3028                                          * getTables() */
>  3029             case AT_ResetRelOptions:    /* Uses MVCC in getIndexes() and
>  3030                                          * getTables() */
>  3031                 cmd_lockmode = AccessExclusiveLock;
>  3032                 break;
>
>
> Maybe it's time to implement "GetRelOptionsLockLevel" to relax the lock to autovac settings (AccessShareLock). To other settings we continue using AccessExclusiveLock.
>
> There are some objection to implement in that way?
>

Attached a very WIP patch to reduce lock level when setting autovacuum reloptions in "ALTER TABLE .. SET ( .. )" statement.

I confess the implementation is ugly, maybe we should add a new item to reloptions constants in src/backend/access/common/reloptions.c and a proper function to get lock level by reloption. Thoughts?

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog: http://fabriziomello.github.io
>> Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
>> Github: http://github.com/fabriziomello
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Parallel Seq Scan
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: WAL format changes break the suppression of do-nothing checkpoints.