-
Notifications
You must be signed in to change notification settings - Fork 365
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
SEGFAULT when subscribing to change notifications without importing threading #275
Comments
I understand from https://github.com/oracle/oracle-db-examples/blob/master/python/DatabaseChangeNotification.py that the threading module should be imported. However, getting a SEGFAULT when the module is not imported could be confusing. Ideally, it would be great if the module could be automatically imported lazily or the SEGFAULT prevented and turned into an informative exception. |
From valgrind
|
Playing around a bit more with the above snippet, I noticed that even importing threading causes SEGFAULTs. Hence the problem looks more like a race condition (I even reached what seemed to be a deadlock in one of the execution runs). |
The problem in this case lies in your code. You are closing the connection while activity may still be ongoing. That's the race condition: whether the closing of the database occurs before the message is sent to the callback. So you need to make sure the subscription is destroyed before closing the database. Adding the line db.unsubscribe(sub) before calling I've changed this to an enhancement -- ideally it would be nice to prevent this situation. I'm not sure exactly how at the moment but I'll think about it some more. In the meantime, you have a solution! |
Thanks, that makes sense. Although I would have expected that the close method is taking care of any necessary "cleanup". Perhaps the list of current subscription objects could be swept and the unsubscribe method called on each of them as part of Connection.close()? |
Yeah, that would make sense....but unfortunately the subscriptions live independently of the connections -- if they are pooled. So the subscription is tied to a standalone connection or to a pool of connections, not directly to a single connection in all cases. So its a bit more complex, but probably still doable -- and as you say, you expect things to "just work". :-) |
Answer the following questions:
What is your version of Python? Is it 32-bit or 64-bit? Python 3.6.3 (64-bit)
What is your cx_Oracle version? 7.1.1
What exact command caused the problem (e.g. what command did you try to install with)? Who were you logged in as? N.A.
What error(s) you are seeing? SEGFAULT
What OS (and version) is Python executing on? Oracle Linux Server 7.6 (under systemd-nspawn on Ubuntu 18.04.2 LTS)
What is your version of the Oracle client (e.g. Instant Client)? How was it installed? Where is it installed?
SQL*Plus: Release 18.0.0.0.0 - Production on Mon Mar 4 12:48:41 2019
Version 18.4.0.0.0
Installed from repositories
What is your Oracle Database version?
Oracle XE 18c installed from the OTN RPM
What is the
PATH
environment variable (on Windows) orLD_LIBRARY_PATH
(on Linux) set to? On macOS, what is in~/lib
?LD_LIBRARY_PATH="/lib64:/opt/oracle/product/18c/dbhomeXE/lib"
No ~/lib folder
What Oracle environment variables did you set? How exactly did you set them?
ORACLE_SID=XE
ORACLE_BASE=/opt/oracle
ORAENV_ASK=NO
ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE
Do you have a small, single Python script that immediately runs to show us the problem?
The text was updated successfully, but these errors were encountered: