Skip to content

Plpy interrupt #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 26, 2017
Merged

Plpy interrupt #2

merged 8 commits into from
May 26, 2017

Conversation

jgoizueta
Copy link
Contributor

Some fixes and enhancements for more reliable plpython execution interruption.

INT signals received when python code is not being executed affected code executed later.
The previous signal handler should always be restore upon module clean up.
Note that a null pointer may be a valid handler specifier (SIG_DFL actually).
We rely on _PG_fini calls being always paired with _PG_init.
Note also that as of PostgreSQL 9.6 _PG_init isn't actually called ever (modules are never unloaded).
Returning 0 from the pending call function has the effect of not raising errors immediately.
We must return -1 to make sure any errors are trapped in the current context.
Make sure Python exceptions occur in the context where the SIGINT occured
@jgoizueta
Copy link
Contributor Author

Two main improvements here:

  • Avoiding SIGINTs received during the execution of one plpython function (or while not executing plpython code) to affect a different plplython function
  • More reliable interruption (python exceptions where delayed due to the Py_AddPendingCall function returning 0 rather than -1)

Also minor fixes for correctness that affect none of CARTO operations to support SIG_DFL, SIG_IGN signal handler.

@ethervoid
Copy link

Glad you find a way to improve this patch. Great work, looks great for me :)))))

Remove unnecessary remnants from previous tests:
* No need to keep track of plpython context nesting level
* No need to pass arguments to the python pending call
@rafatower
Copy link
Contributor

while trying to generate the package from the sources:

$ debuild -uc -us
...
dpkg-source: error: expected [ +-] at start of line 24 of diff 'postgresql-9.5.2/debian/patches/92-plpython-interrupt.patch'
dpkg-source: info: applying 92-plpython-interrupt.patch
dpkg-source: info: the patch has fuzz which is not allowed, or is malformed
dpkg-source: info: if patch '92-plpython-interrupt.patch' is correctly applied by quilt, use 'quilt refresh' to update it
dpkg-buildpackage: error: dpkg-source --before-build postgresql-9.5.2 gave error exit status 2
debuild: fatal error at line 1376:
dpkg-buildpackage -rfakeroot -D -us -uc failed

I'll try to get it fixed.

Rafa de la Torre added 2 commits May 23, 2017 18:24
@rafatower
Copy link
Contributor

It should be soon available for testing here: https://launchpad.net/~cartodb/+archive/ubuntu/postgresql-next

@rafatower rafatower requested a review from azamorano May 24, 2017 09:58
@rafatower
Copy link
Contributor

@azamorano or @jvillarf can you please take a look?

@rafatower
Copy link
Contributor

@jgoizueta one last check?

@jgoizueta
Copy link
Contributor Author

jgoizueta commented May 25, 2017

👍 I've checked the effect of the final patch and it matches the intended code, which I've also updated in CartoDB/postgres#5 (it had some extraneous characters there as @ethervoid had noticed). Thanks for taking care of this!

@rafatower rafatower merged commit 3a2acfe into 9.5-cdb May 26, 2017
@rafatower rafatower deleted the plpy-interrupt branch May 26, 2017 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants