Skip site navigation (1) Skip section navigation (2)

could not create directory "...": File exists

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: could not create directory "...": File exists
Date: 2013-01-17 14:19:37
Message-ID: 20130117141936.GR16126@tamriel.snowman.net (view raw or flat)
Thread:
Lists: pgsql-hackers
Greetings,

  We've come across this rather annoying error happening during our
  builds:

  ERROR:  could not create directory "pg_tblspc/25120/PG_9.3_201212081/231253": File exists

  It turns out that this is coming from copydir() when called by
  createdb() during a CREATE DATABASE .. FROM TEMPLATE where the
  template has tables in tablespaces.

  It turns out that createdb() currently only takes an AccessShareLock
  on pg_tablespace when scanning it with SnapshotNow, making it possible
  for a concurrent process to make some uninteresting modification to a
  tablespace (such as an ACL change) which will cause the heap scan in
  createdb() to see a given tablespace multiple times.  copydir() will
  then, rightfully, complain that it's being asked to create a directory
  which already exists.

  Given that this is during createdb(), I'm guessing we don't have any
  option but to switch the scan to using ShareLock, since there isn't a
  snapshot available to do an MVCC scan with (I'm guessing that there
  could be other issues trying to do that anyway).

  Attached is a patch which does this and corrects the problem for us
  (of course, we're now going to go rework our build system to not
  modify tablespace ACLs, since with this patch concurrent builds end up
  blocking on each other, which is annoying).

  	Thanks,

		Stephen

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2013-01-17 14:53:27
Subject: Re: Removing PD_ALL_VISIBLE
Previous:From: Magnus HaganderDate: 2013-01-17 14:07:35
Subject: Re: default SSL compression (was: libpq compression)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group