postgresql server crash on windows 7 when using plpython

Поиск
Список
Период
Сортировка
Искать

postgresql server crash on windows 7 when using plpython

От:
c k <shreeseva.learning@gmail.com>
Дата:
Dear Friends,
For client requirements, I am testing postgresql 9.0.4 on windows 7 with plpython. First I installed python 2.7 and then added python installation path to windows PATH variable. Then installed postgresql from one-click installer. Server started and every thing was ok. Then I go to create plpythonu in a database. But it failed. After searching, I found that it needs python 2.6. So I again installed python 2.6 and then dropped plpython from database and created again. It was successful. Normal python functions returning text etc. are working but when conatining

import sys
from uuid import getnode as get_mac
mac = get_mac()
return mac

fails. What will be the reason?

Advance thanks for your help.

Chaitanya Kulkarni

Re: [GENERAL] postgresql server crash on windows 7 when using plpython

От:
Adrian Klaver <adrian.klaver@gmail.com>
Дата:


On Tue, Aug 9, 2011 at 7:54 AM, c k <shreeseva.learning@gmail.com> wrote:
Dear Friends,
For client requirements, I am testing postgresql 9.0.4 on windows 7 with plpython. First I installed python 2.7 and then added python installation path to windows PATH variable. Then installed postgresql from one-click installer. Server started and every thing was ok. Then I go to create plpythonu in a database. But it failed. After searching, I found that it needs python 2.6. So I again installed python 2.6 and then dropped plpython from database and created again. It was successful. Normal python functions returning text etc. are working but when conatining

import sys
from uuid import getnode as get_mac
mac = get_mac()
return mac

fails. What will be the reason?

What would be the error message(s)?

The actual function code would also be helpful, to put things into context.
 

Advance thanks for your help.

Chaitanya Kulkarni



--
Adrian Klaver
adrian.klaver@gmail.com

Re: [GENERAL] postgresql server crash on windows 7 when using plpython

От:
c k <shreeseva.learning@gmail.com>
Дата:
Here is the actual function.
create or replace function software.python_test() returns text as
$body$
import sys
from uuid import getnode as get_mac
mac = get_mac()
return mac
$body$
language plpythonu volatile security definer;

When running the same code from python prompt, it run correctly without any error.


Chaitanya Kulkarni
On Wed, Aug 10, 2011 at 12:57 AM, Adrian Klaver <adrian.klaver@gmail.com> wrote:


On Tue, Aug 9, 2011 at 7:54 AM, c k <shreeseva.learning@gmail.com> wrote:
Dear Friends,
For client requirements, I am testing postgresql 9.0.4 on windows 7 with plpython. First I installed python 2.7 and then added python installation path to windows PATH variable. Then installed postgresql from one-click installer. Server started and every thing was ok. Then I go to create plpythonu in a database. But it failed. After searching, I found that it needs python 2.6. So I again installed python 2.6 and then dropped plpython from database and created again. It was successful. Normal python functions returning text etc. are working but when conatining

import sys
from uuid import getnode as get_mac
mac = get_mac()
return mac

fails. What will be the reason?

What would be the error message(s)?

The actual function code would also be helpful, to put things into context.
 

Advance thanks for your help.

Chaitanya Kulkarni



--
Adrian Klaver
adrian.klaver@gmail.com

Re: postgresql server crash on windows 7 when using plpython

От:
Craig Ringer <ringerc@ringerc.id.au>
Дата:
On 9/08/2011 10:54 PM, c k wrote:

> Normal python functions returning text etc. are working but when conatining
>
> import sys
> from uuid import getnode as get_mac
> mac = get_mac()
> return mac
>
> fails. What will be the reason?

You still haven't supplied the error message you get when you run this.

In the absence of better information, my guess would be that python's 
uuid module uses ossp-uuid, same as PostgreSQL does, but a different 
version or one compiled differently. The PostgreSQL `bin' dir with the 
postgresql version of the DLL will be in the path before the Python one, 
so Python is calling into a different version of the DLL than it expects 
and probably crashing as a result.

That would be consistent with it working from the python command line.

To work around this, I'd either use the ossp-uuid functions via the SPI 
rather than using the Python UUID module, or I'd remove the OSSP-UUID 
dll from the postgresql directory. You can certainly try that to see if 
it helps.

This is one of the joys you get with Windows software not being managed 
by a central packaging system. Everyone bundles their own versions of 
all the dependencies, leaving messes like this where two DLLs with the 
same name aren't quite compatible. Yay!

--
Craig Ringer

Re: postgresql server crash on windows 7 when using plpython

От:
c k <shreeseva.learning@gmail.com>
Дата:
I didn't get any error message. When calling the function from PGAdmin I get
********error**********.
When I try to re-execute it, it says 'no connection to the server'. When checked the logs I found

2011-08-09 19:46:00 IST LOG:  database system was interrupted; last known up at 2011-08-09 19:45:17 IST
2011-08-09 19:46:00 IST LOG:  database system was not properly shut down; automatic recovery in progress
2011-08-09 19:46:00 IST FATAL:  the database system is starting up
2011-08-09 19:46:00 IST LOG:  consistent recovery state reached at 0/420B8C00
2011-08-09 19:46:00 IST LOG:  record with zero length at 0/420B8C00
2011-08-09 19:46:00 IST LOG:  redo is not required
2011-08-09 19:46:00 IST LOG:  database system is ready to accept connections
2011-08-09 19:46:01 IST LOG:  autovacuum launcher started
Fatal Python error: PyThreadState_Get: no current thread
 
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
2011-08-09 19:49:39 IST LOG:  server process (PID 2596) exited with exit code 3
2011-08-09 19:49:39 IST LOG:  terminating any other active server processes
2011-08-09 19:49:39 IST WARNING:  terminating connection because of crash of another server process
2011-08-09 19:49:39 IST DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2011-08-09 19:49:39 IST HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2011-08-09 19:49:39 IST LOG:  all server processes terminated; reinitializing
2011-08-09 19:49:50 IST FATAL:  pre-existing shared memory block is still in use
2011-08-09 19:49:50 IST HINT:  Check if there are any old server processes still running, and terminate them.

It only crashes when calling the first stated get_mac. If I use any other logic inside the function it works fine. May be problem occurs when using hardware related methods.

When I restart the server manually, there is nothing about the problem.

Chaitanya Kulkarni

On Wed, Aug 10, 2011 at 12:07 PM, Craig Ringer <ringerc@ringerc.id.au> wrote:
On 9/08/2011 10:54 PM, c k wrote:

Normal python functions returning text etc. are working but when conatining

import sys
from uuid import getnode as get_mac
mac = get_mac()
return mac

fails. What will be the reason?

You still haven't supplied the error message you get when you run this.

In the absence of better information, my guess would be that python's uuid module uses ossp-uuid, same as PostgreSQL does, but a different version or one compiled differently. The PostgreSQL `bin' dir with the postgresql version of the DLL will be in the path before the Python one, so Python is calling into a different version of the DLL than it expects and probably crashing as a result.

That would be consistent with it working from the python command line.

To work around this, I'd either use the ossp-uuid functions via the SPI rather than using the Python UUID module, or I'd remove the OSSP-UUID dll from the postgresql directory. You can certainly try that to see if it helps.

This is one of the joys you get with Windows software not being managed by a central packaging system. Everyone bundles their own versions of all the dependencies, leaving messes like this where two DLLs with the same name aren't quite compatible. Yay!

--
Craig Ringer

Re: postgresql server crash on windows 7 when using plpython

От:
Scott Marlowe <scott.marlowe@gmail.com>
Дата:
On Wed, Aug 10, 2011 at 1:23 AM, c k  wrote:
> When I try to re-execute it, it says 'no connection to the server'. When
> checked the logs I found
>
> 2011-08-09 19:46:00 IST LOG:  database system was interrupted; last known up
> at 2011-08-09 19:45:17 IST
> 2011-08-09 19:46:00 IST LOG:  database system was not properly shut down;
> automatic recovery in progress
> 2011-08-09 19:46:00 IST FATAL:  the database system is starting up
> 2011-08-09 19:46:00 IST LOG:  consistent recovery state reached at
> 0/420B8C00
> 2011-08-09 19:46:00 IST LOG:  record with zero length at 0/420B8C00
> 2011-08-09 19:46:00 IST LOG:  redo is not required
> 2011-08-09 19:46:00 IST LOG:  database system is ready to accept connections
> 2011-08-09 19:46:01 IST LOG:  autovacuum launcher started
> Fatal Python error: PyThreadState_Get: no current thread

There should be an error before that that caused the database to not
shut down properly etc.
FAQ