pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #13823: Database crash - import requests in plpython3u
3+ messages / 3 participants
[nested] [flat]
* BUG #13823: Database crash - import requests in plpython3u
@ 2015-12-17 13:34 george.wesington@gmail.com
2015-12-18 05:59 ` Re: BUG #13823: Database crash - import requests in plpython3u Terje Elde <terje@elde.net>
0 siblings, 1 reply; 3+ messages in thread
From: george.wesington@gmail.com @ 2015-12-17 13:34 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 13823
Logged by: George Wesington
Email address: george.wesington@gmail.com
PostgreSQL version: 9.4.5
Operating system: Windows 7 64bit
Description:
Dear PostgreSQL,
i was trying to use requests module in python function but as soon as the
import statement is written in the function the database completely
crashes.
I am using PostgreSQL 9.4.5 on Windows 7 64 bit with 64 bit Python 3.5.1.
The function I am trying to run is following (never mind the empty fields)
:
CREATE OR REPLACE FUNCTION globalapp.f_my_function()
RETURNS TEXT
AS
$$
import requests
api_url = ""
access_token = ""
payload = ""
api_url = api_base_url + "?access_token=" + access_token
api_request = requests.post(api_url, data=payload)
api_response = api_request.text
return api_response
$$
LANGUAGE plpython3u;
The log file after running the function is:
2015-12-17 14:17:05 CET LOG: database system was interrupted; last known up
at 2015-12-17 14:16:05 CET
2015-12-17 14:17:06 CET LOG: database system was not properly shut down;
automatic recovery in progress
2015-12-17 14:17:06 CET LOG: record with zero length at 0/2078150
2015-12-17 14:17:06 CET LOG: redo is not required
2015-12-17 14:17:06 CET LOG: MultiXact member wraparound protections are
now enabled
2015-12-17 14:17:06 CET LOG: database system is ready to accept
connections
2015-12-17 14:17:06 CET LOG: autovacuum launcher started
Fatal Python error: PyThreadState_Get: no current thread
2015-12-17 14:17:17 CET LOG: server process (PID 5184) was terminated by
exception 0xC0000005
2015-12-17 14:17:17 CET DETAIL: Failed process was running: SELECT * FROM
f_my_function()
2015-12-17 14:17:17 CET HINT: See C include file "ntstatus.h" for a
description of the hexadecimal value.
2015-12-17 14:17:17 CET LOG: terminating any other active server processes
2015-12-17 14:17:17 CET WARNING: terminating connection because of crash of
another server process
2015-12-17 14:17:17 CET 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.
2015-12-17 14:17:17 CET HINT: In a moment you should be able to reconnect
to the database and repeat your command.
2015-12-17 14:17:17 CET LOG: all server processes terminated;
reinitializing
After the crash the database needs to be restarted because it cannot be
accessed anymore. The same script runs perfectly when run directly from
python.
Let me know if you need any more information.
Best,
George
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #13823: Database crash - import requests in plpython3u
2015-12-17 13:34 BUG #13823: Database crash - import requests in plpython3u george.wesington@gmail.com
@ 2015-12-18 05:59 ` Terje Elde <terje@elde.net>
2015-12-18 13:17 ` Re: BUG #13823: Database crash - import requests in plpython3u George Wesington <george.wesington@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Terje Elde @ 2015-12-18 05:59 UTC (permalink / raw)
To: george.wesington@gmail.com; +Cc: pgsql-bugs
> On 17 Dec 2015, at 14:34, george.wesington@gmail.com wrote:
>
> After the crash the database needs to be restarted because it cannot be
> accessed anymore. The same script runs perfectly when run directly from
> python.
>
> Let me know if you need any more information.
Could you try to run it as the PostgreSQL user, but outside PostgreSQL?
Also, please double check that it's run as Python 3 when testing that. The code looks fairly compatible between 2.7 and 3.x, and my best initial guess would be that Python crashes on a missing or faulty import.
Can you successfully run a simpler Python function from PostgreSQL? (One that doesn't import anything). Easy way to narrow down if it's likely the requests-module in Python, or if it's related to plpython.
Oh, and how did you install Python, PostgreSQL, plpython and the requests module?
Terje
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #13823: Database crash - import requests in plpython3u
2015-12-17 13:34 BUG #13823: Database crash - import requests in plpython3u george.wesington@gmail.com
2015-12-18 05:59 ` Re: BUG #13823: Database crash - import requests in plpython3u Terje Elde <terje@elde.net>
@ 2015-12-18 13:17 ` George Wesington <george.wesington@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: George Wesington @ 2015-12-18 13:17 UTC (permalink / raw)
To: Terje Elde <terje@elde.net>; +Cc: pgsql-bugs
Hi Terje,
Thank you for your reply!
The information i submitted was while running the function as postgres
user (database owner).
I can run simple python scripts and I can also import some other modules
without crashing (logging, sys, string, subprocess...)
Python was installed from the executable installer downloaded from the
official pages, same goes for postgres (from edb). Requests were
acquired with pip ( 'pip install requests').
The requests module does not even have to be used in the code, as soon
as the "import requests" statement is written in any script, the
database crashes.
Python 2 is not connected to postgres as I was actually not able to do
it. I noticed that in distribution I downloaded there is no plpython2
dll to connect postgres with it? Is there another way to do it?
Best,
George
On 18/12/2015 06:59, Terje Elde wrote:
>
>> On 17 Dec 2015, at 14:34, george.wesington@gmail.com wrote:
>>
>> After the crash the database needs to be restarted because it cannot be
>> accessed anymore. The same script runs perfectly when run directly from
>> python.
>>
>> Let me know if you need any more information.
> Could you try to run it as the PostgreSQL user, but outside PostgreSQL?
>
> Also, please double check that it's run as Python 3 when testing that. The code looks fairly compatible between 2.7 and 3.x, and my best initial guess would be that Python crashes on a missing or faulty import.
>
> Can you successfully run a simpler Python function from PostgreSQL? (One that doesn't import anything). Easy way to narrow down if it's likely the requests-module in Python, or if it's related to plpython.
>
> Oh, and how did you install Python, PostgreSQL, plpython and the requests module?
>
> Terje
>
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2015-12-18 13:17 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-12-17 13:34 BUG #13823: Database crash - import requests in plpython3u george.wesington@gmail.com
2015-12-18 05:59 ` Terje Elde <terje@elde.net>
2015-12-18 13:17 ` George Wesington <george.wesington@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox