Re: How about a proper TEMPORARY TABLESPACE?

From: Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Fabrízio Mello <fabriziomello(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Stephen Frost <sfrost(at)snowman(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: How about a proper TEMPORARY TABLESPACE?
Date: 2014-06-30 11:05:24
Message-ID: CAJghg4K62e8viEH1KdQvJyEEM5BBOB96p8vuMgSaY9cENfj2Jw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 30, 2014 at 5:14 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:

> Right now PostgreSQL appears to rely on the absence of the tablespace
> directory as a flag to tell it "don't start up, something's badly wrong
> here".
>
>
Well, in fact the behavior is just to give a LOG message:

LOG: could not open tablespace directory
"pg_tblspc/100607/PG_9.3_201306121": No such file or directory

But it starts fine. No?

I ask because I'm relying on that. My patch does not on startup, so in the
absence of the tablespace directory, the above LOG is shown even for
"temporary-tablespace", and it tries to create the directory when any
process tries to use it. As we don't have catalog access on startup, it
will require me to use some kind of _init fork for tablespace if we want it
to be re-created during startup. Should we bother about this?

If the user creates the tablespace directory, it figures they at least
> know what they're doing and carries on starting up with the empty
> tablespace. It's treated as an admin statement - "I know it's gone, it's
> not coming back, just carry on as best you can".
>
>
Well, I think for a tablespace like that it is okay to create it on-demand
(note that I have done this only for "temp", not ordinary ones).

> If Pg were to auto-create the directory, then if (say) a mount of a
> tablespace dir failed at boot, Pg would still happily start up and might
> create files in the tablespace, despite there being inaccessible
> tables/indexes/etc on the not-mounted volume that's *supposed* to be the
> tablespace storage. That'd create plenty of mess.
>
> So no, I don't think Pg should auto-create the tablespace directory if
> it's missing for non-temporary tablespaces.
>

Ok. I agree. Let's create only for temporary ones (as done by the patch
now).

> Not unless the current (less
> than friendly) behaviour around lost tablespaces is replaced with
> something like an `ignore_missing_tablespaces` or
> `drop_missing_tablespaces` GUC - akin to our existing
> `zero_missing_pages` recovery GUC.
>

You meant `zero_damaged_pages`, I think. I don't think that is really
necessary in this case.

Anyway, I was thinking about some way to this tablespace to also allow
creation of non-temporary indexes, and after a crash we could mark such
indexes as `NOT VALID` (perhaps `zero_damaged_pages` could be of help
here?!). That should be part of another patch thought, and would require
more thoughts. But I think that would be a great improvement for some
environments, like those on AWS with their ephemeral SSDs.

Regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-06-30 11:07:47 Re: Set new system identifier using pg_resetxlog
Previous Message Abhijit Menon-Sen 2014-06-30 11:01:08 Re: psql: show only failed queries