Re: 9.0beta2 - server crash when using HS + SR

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: 9.0beta2 - server crash when using HS + SR
Дата
Msg-id 201006301715.o5UHFvb25845@momjian.us
обсуждение исходный текст
Ответ на Re: 9.0beta2 - server crash when using HS + SR  (Fujii Masao <masao.fujii@gmail.com>)
Ответы Re: 9.0beta2 - server crash when using HS + SR  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: 9.0beta2 - server crash when using HS + SR  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Fujii Masao wrote:
> On Mon, Jun 14, 2010 at 9:16 AM, Greg Smith <greg@2ndquadrant.com> wrote:
> > I wouldn't be adverse to improving the error messages emitted when this
> > happens by the server to make it more obvious what's gone wrong in 9.1.
> > ?That's the only genuine improvement I'd see value in here, to cut down on
> > other people running into what you did and being as confused by it.
>
> What about the attached patch? When we encounter that problem, we get
> the following hint message:
>
>   FATAL:  directory "/path_to/ts" does not exist
>   HINT:  create "/path_to/ts" directory for tablespace before
> restarting the server
>   CONTEXT:  xlog redo create ts: 16384 "/path_to/ts"

This is an interesting patch idea.  One problem with the patch is that
create_tablespace_directories() is called both during recovery and when
creating a tablespace, and the hint only makes sense in the first case.

The attached patch shows the hint only during recovery.  Unless there
are objections, I will apply this for 9.0.  I do think people will be
hit by this more often in 9.0.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + None of us is going to be here forever. +
Index: src/backend/commands/tablespace.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/commands/tablespace.c,v
retrieving revision 1.74
diff -c -c -r1.74 tablespace.c
*** src/backend/commands/tablespace.c    26 Feb 2010 02:00:39 -0000    1.74
--- src/backend/commands/tablespace.c    30 Jun 2010 17:08:42 -0000
***************
*** 85,91 ****


  static void create_tablespace_directories(const char *location,
!                               const Oid tablespaceoid);
  static bool destroy_tablespace_directories(Oid tablespaceoid, bool redo);


--- 85,91 ----


  static void create_tablespace_directories(const char *location,
!                       const Oid tablespaceoid, const bool in_recovery);
  static bool destroy_tablespace_directories(Oid tablespaceoid, bool redo);


***************
*** 333,339 ****
      /* Record dependency on owner */
      recordDependencyOnOwner(TableSpaceRelationId, tablespaceoid, ownerId);

!     create_tablespace_directories(location, tablespaceoid);

      /* Record the filesystem change in XLOG */
      {
--- 333,339 ----
      /* Record dependency on owner */
      recordDependencyOnOwner(TableSpaceRelationId, tablespaceoid, ownerId);

!     create_tablespace_directories(location, tablespaceoid, false);

      /* Record the filesystem change in XLOG */
      {
***************
*** 533,539 ****
   *    to the specified directory
   */
  static void
! create_tablespace_directories(const char *location, const Oid tablespaceoid)
  {
      char       *linkloc = palloc(OIDCHARS + OIDCHARS + 1);
      char       *location_with_version_dir = palloc(strlen(location) + 1 +
--- 533,540 ----
   *    to the specified directory
   */
  static void
! create_tablespace_directories(const char *location, const Oid tablespaceoid,
!                               const bool in_recovery)
  {
      char       *linkloc = palloc(OIDCHARS + OIDCHARS + 1);
      char       *location_with_version_dir = palloc(strlen(location) + 1 +
***************
*** 550,559 ****
      if (chmod(location, 0700) != 0)
      {
          if (errno == ENOENT)
!             ereport(ERROR,
!                     (errcode(ERRCODE_UNDEFINED_FILE),
!                      errmsg("directory \"%s\" does not exist",
!                             location)));
          else
              ereport(ERROR,
                      (errcode_for_file_access(),
--- 551,568 ----
      if (chmod(location, 0700) != 0)
      {
          if (errno == ENOENT)
!         {
!             if (!in_recovery)
!                 ereport(ERROR,
!                         (errcode(ERRCODE_UNDEFINED_FILE),
!                          errmsg("directory \"%s\" does not exist", location)));
!             else
!                 ereport(ERROR,
!                         (errcode(ERRCODE_UNDEFINED_FILE),
!                          errmsg("directory \"%s\" does not exist", location),
!                          errhint("create \"%s\" directory for tablespace before "
!                                  "restarting the server", location)));
!         }
          else
              ereport(ERROR,
                      (errcode_for_file_access(),
***************
*** 1359,1365 ****
          xl_tblspc_create_rec *xlrec = (xl_tblspc_create_rec *) XLogRecGetData(record);
          char       *location = xlrec->ts_path;

!         create_tablespace_directories(location, xlrec->ts_id);
      }
      else if (info == XLOG_TBLSPC_DROP)
      {
--- 1368,1374 ----
          xl_tblspc_create_rec *xlrec = (xl_tblspc_create_rec *) XLogRecGetData(record);
          char       *location = xlrec->ts_path;

!         create_tablespace_directories(location, xlrec->ts_id, true);
      }
      else if (info == XLOG_TBLSPC_DROP)
      {

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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Check constraints on non-immutable keys
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Check constraints on non-immutable keys