Closed ElDeveloper closed 4 years ago
I think the issue is this line: https://github.com/biocore/qiita/blob/master/qiita_db/environment_manager.py#L180
Since that connection is open with the database, we need to explicitly close that one, so any further connection to the DB re-opens it with a non-admin connection to a database.
Ah, that makes sense, let me try it out in my system.
On (May-28-15|12:29), josenavas wrote:
I think the issue is this line: https://github.com/biocore/qiita/blob/master/qiita_db/environment_manager.py#L180
Since that connection is open with the database, we need to explicitly close that one, so any further connection to the DB re-opens it with a non-admin connection to a database.
Reply to this email directly or view it on GitHub: https://github.com/biocore/qiita/issues/1216#issuecomment-106573624
I tried doing admin_conn.close() right before del admin_conn, but that didn't seem to work either, so I'm not sure what's going on.
On (May-28-15|12:29), josenavas wrote:
I think the issue is this line: https://github.com/biocore/qiita/blob/master/qiita_db/environment_manager.py#L180
Since that connection is open with the database, we need to explicitly close that one, so any further connection to the DB re-opens it with a non-admin connection to a database.
Reply to this email directly or view it on GitHub: https://github.com/biocore/qiita/issues/1216#issuecomment-106573624
Note that if I move the code, it the problem is not present anymore (not a real fix of course, but it's good to know):
diff --git a/qiita_db/environment_manager.py b/qiita_db/environment_manager.py
index 3fec1da..dc06373 100644
--- a/qiita_db/environment_manager.py
+++ b/qiita_db/environment_manager.py
@@ -209,6 +209,9 @@ def make_environment(load_ontologies, download_reference, add_demo_user):
create_layout_and_patch(conn, verbose=True)
+ if download_reference:
+ _download_reference_files(conn)
+
if load_ontologies:
_add_ontology_data(conn)
@@ -218,9 +221,6 @@ def make_environment(load_ontologies, download_reference, add_demo_user):
ontology = Ontology(convert_to_id('ENA', 'ontology'))
ontology.add_user_defined_term('Amplicon Sequencing')
- if download_reference:
- _download_reference_files(conn)
-
# we don't do this if it's a test environment because populate.sql
# already adds this user...
if add_demo_user and not qiita_config.test_environment:
That is really interesting! Something in the ontology code?
All the execute
calls in the SQLConnectionHandler commit, that's why we needed to create the queues.
Why the autocommit then?
Actually, suspect this line may be the issue. __del__
is not defined, so it is not explicitly closing the connection. Recommend using conn.close()
as del
will rely on the gc
and this previously caused problems. We had to remove __del__
as the destructor was always closing the connection so we weren't getting the benefit of retaining a single open connection
You're right. We had the __del__
defined before, but when we changed to a single connection, we remove that code. We should probably create a close
function in the connection handler, so we can close the connection without accessing any to its attributes.
there is one...
This is still a problem and calling the close method doesn't work. At this point the solution is still to swap these statements as in the patch that I posted earlier in this thread. Would anyone oppose to me making that change and keep this issue open until we can figure out what the source of the error is?
Closing as the DB connection code has been improved multiple times since this issue was opened and we haven't seen this error in a really long time; please open another issue if it happens again.
Calling
qiita_env make --add-demo-user --load-ontologies --download-reference
will fail with the following traceback:If you read the traceback, the problem is pointing to
settings
not existing in the database, however if you open a python session and try to use the function that's failing, you won't be able to reproduce the error:@josenavas suggested that this might be due to some uncommitted changes in the SQL connection, or maybe something else related to the fact that we only have one connection.