Re: ALTER TABLE lock strength reduction patch is unsafe

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, Peter Geoghegan <pg(at)heroku(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER TABLE lock strength reduction patch is unsafe
Date: 2014-03-03 21:18:20
Message-ID: CA+U5nM+mpKzanYe-0skJfB829QeBaauecen9oZqk2JBGWTu7fA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3 March 2014 16:36, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

>>> This hunk in ATRewriteCatalogs() looks scary:
>>>
>>> + /*
>>> + * If we think we might need to add/re-add toast tables then
>>> + * we currently need to hold an AccessExclusiveLock.
>>> + */
>>> + if (lockmode < AccessExclusiveLock)
>>> + return;
>>>
>>> It would make sense to me to add an Assert() or elog() check inside
>>> the subsequent loop to verify that the lock level is adequate ... but
>>> just returning silently seems like a bad idea.
>>
>> OK, I will check elog.
>>
>>> I have my doubts about whether it's safe to do AT_AddInherit,
>>> AT_DropInherit, AT_AddOf, or AT_DropOf with a full lock. All of those
>>> can change the tuple descriptor, and we discussed, back when we did
>>> this the first time, the fact that the executor may get *very* unhappy
>>> if the tuple descriptor changes in mid-execution. I strongly suspect
>>> these are unsafe with less than a full AccessExclusiveLock.
>>
>> I'm happy to change those if you feel there is insufficient evidence.
>
> Not sure what that means, but yes, I think the lock levels on those
> need to be increased.

v21 with all requested changes, comments and cleanup

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
reduce_lock_levels.v21.patch application/octet-stream 183.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-03-03 21:48:15 Re: Changeset Extraction v7.9
Previous Message Andres Freund 2014-03-03 20:47:21 Re: GSoC proposal - "make an unlogged table logged"