workaround db connection getting closed at runtime...#307
Merged
rspeer merged 1 commit intocommonsense:masterfrom Sep 7, 2021
amirouche:master
Merged
workaround db connection getting closed at runtime...#307rspeer merged 1 commit intocommonsense:masterfrom amirouche:master
rspeer merged 1 commit intocommonsense:masterfrom
amirouche:master
Conversation
... 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
... for unknown reasons, the db connection is closed at runtime, due
to a high load. Here is an example traceback:
This patch will re-create the connection any time the connection is
closed. Bonus: factor connection creation inside a property called
connection.
ref: #306