BUG #13823: Database crash - import requests in plpython3u

From: george(dot)wesington(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #13823: Database crash - import requests in plpython3u
Date: 2015-12-17 13:34:09
Message-ID: 20151217133409.3886.97313@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 13823
Logged by: George Wesington
Email address: george(dot)wesington(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message grzegorz 2015-12-17 13:45:02 BUG #13824: EXISTS sometimes uses seq scan instead of index
Previous Message marek.petr 2015-12-17 12:50:25 BUG #13822: Slave terminated - WAL contains references to invalid page