Re: Index file got removed

From: Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: sudalai <sudalait2(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Index file got removed
Date: 2016-11-17 22:01:14
Message-ID: bc019d06-5928-d814-3193-7669c802d71c@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 17/11/2016 22:31, Julien Rouhaud wrote:
> On 16/11/2016 18:26, Tom Lane wrote:
>> Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
>>> On Wed, Nov 16, 2016 at 3:16 AM, sudalai <sudalait2(at)gmail(dot)com> wrote:
>>>> I am creating a table test and index for that table on default tablespace.
>>>> Then i'm changing default_tablespace to some other tablespace.
>>>> After that altering one of the index column.
>>>> This alter operation moves the index to new default_tablespace, but index
>>>> file is missing in new tablespace.
>>
>>> I am just digging into it, instinctively that would be something in
>>> tablecmds.c..
>>
>> I'm betting that where it reconstructs textual commands to create the new
>> indexes, it's forgotten to do anything about tablespaces.
>
> I looked at it, and IIUC the issue is that during AT_PASS_OLD_INDEX
> pass, ATExecAddIndex defines a new index using the old heap in original
> tablespace (stmt->oldNode is valid), and DefineIndex will create a new
> cat entry using the current default tablespace instead of the existing
> index one.
>
> The only way I found to fix this is to save the original tablespace in
> ATExecAddIndex() if the old heap is reused, see attached patch. I'm not
> at all familiar with this part of code, but at least initdb and
> regression tests don't fail.

After some more thoughts, this is probably broken if a single command
recreates a mix of indexes that should be and should not be rebuilt.
The original tablespace information could be saved and restored around
DefineIndex(), but since it looks like an ugly hack I prefer to wait if
there's a better fix for this.

--
Julien Rouhaud
http://dalibo.com - http://dalibo.org

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message vbochkov 2016-11-18 10:49:47 BUG #14428: decode function don't return correct value when executed from agent's job or external program
Previous Message Julien Rouhaud 2016-11-17 21:31:59 Re: Index file got removed