Don't do that: Changing the working directory in a plpython function

Поиск
Список
Период
Сортировка
От Wolfgang Walther
Тема Don't do that: Changing the working directory in a plpython function
Дата
Msg-id 3930213a-5d04-7f38-fe94-fbd2bdbdfa4c@technowledgy.de
обсуждение исходный текст
Ответы Re: Don't do that: Changing the working directory in a plpython function  (Magnus Hagander <magnus@hagander.net>)
Список pgsql-bugs
Hi,

this is on PG 12.5:

create extension plpython3u;
create function cwd() returns void
language plpython3u as $$
   import os
   os.chdir('/tmp')
$$;
select cwd();
create table t();

ERROR: could not open file "base/13457/2663": No such file or directory
LINE 1: create table t();

The server is now unusable, almost everything will throw.

Somebody did something similar on a server with a bit more stuff going 
on and this gave:

PANIC: could not create file "pg_wal/xlogtemp.xxxxx": No such file or 
directory

And then the whole PG server restarted.

It's not really that surprising - after the fact. Before, I wouldn't 
have guessed that this has such an impact.

As a side-note: plperlu is obviously the same, but plperl blocks chdir.

I am not sure whether this is considered a bug or just in the category 
"don't do that, stupid..."?

As a naive (super)user I wonder: Why can't PG just remember where the 
data folder was when it started? It's not like I'm going to ever move 
this folder while the server is running...

Best

Wolfgang



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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: Don't do that: Changing the working directory in a plpython function