8000 workaround db connection getting closed at runtime... by amirouche · Pull Request #307 · commonsense/conceptnet5 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

workaround db c 8000 onnection getting closed at runtime... #307

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 1 commit into from
Sep 7, 2021
Merged

workaround db connection getting closed at runtime... #307

merged 1 commit into from
Sep 7, 2021

Conversation

amirouche
Copy link
@amirouche amirouche commented Aug 19, 2021

... for unknown reasons, the db connection is closed at runtime, due
to a high load. Here is an example traceback:

 [2021-08-15 17:00:46,840] ERROR in app: Exception on /a/[/r/EtymologicallyRelatedTo/,/c/en/drag/,/c/nds/dragge/] [GET]
 Traceback (most recent call last):
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
     response = self.full_dispatch_request()
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
     rv = self.handle_user_exception(e)
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
     reraise(exc_type, exc_value, tb)
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
     raise value
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
     rv = self.dispatch_request()
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
     return self.view_functions[rule.endpoint](**req.view_args)
   File "/home/conceptnet/conceptnet5/web/conceptnet_web/web.py", line 133, in browse_node
     results = responses.lookup_paginated(path, offset=offset, limit=limit)
   File "/home/conceptnet/conceptnet5/conceptnet5/api.py", line 150, in lookup_paginated
     found = FINDER.lookup(term, limit=(limit + 1), offset=offset)
   File "/home/conceptnet/conceptnet5/conceptnet5/db/query.py", line 142, in lookup
     return self.lookup_assertion(uri)
   File "/home/conceptnet/conceptnet5/conceptnet5/db/query.py", line 194, in lookup_assertion
     cursor = self.connection.cursor()
 psycopg2.InterfaceError: connection already closed

This patch will re-create the connection any time the connection is
closed. Bonus: factor connection creation inside a property called
connection.

ref: #306

... for unknown reasons, the db connection is closed at runtime, due
to a high load. Here is an example traceback:

 [2021-08-15 17:00:46,840] ERROR in app: Exception on /a/[/r/EtymologicallyRelatedTo/,/c/en/drag/,/c/nds/dragge/] [GET]
 Traceback (most recent call last):
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
     response = self.full_dispatch_request()
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
     rv = self.handle_user_exception(e)
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
     reraise(exc_type, exc_value, tb)
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
     raise value
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
     rv = self.dispatch_request()
   File "/home/conceptnet/env/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
     return self.view_functions[rule.endpoint](**req.view_args)
   File "/home/conceptnet/conceptnet5/web/conceptnet_web/web.py", line 133, in browse_node
     results = responses.lookup_paginated(path, offset=offset, limit=limit)
   File "/home/conceptnet/conceptnet5/conceptnet5/api.py", line 150, in lookup_paginated
     found = FINDER.lookup(term, limit=(limit + 1), offset=offset)
   File "/home/conceptnet/conceptnet5/conceptnet5/db/query.py", line 142, in lookup
     return self.lookup_assertion(uri)
   File "/home/conceptnet/conceptnet5/conceptnet5/db/query.py", line 194, in lookup_assertion
     cursor = self.connection.cursor()
 psycopg2.InterfaceError: connection already closed

This patch will re-create the connection any time the connection is
closed. Bonus: factor connection creation inside a property called
connection.
@rspeer rspeer merged commit fda1b39 into commonsense:master Sep 7, 2021
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.

2 participants
0