Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

sqlalchemy.exc.InvalidRequestError: Can't reconnect until invalid transaction is rolled back

Open
#122 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
20/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python, sqlalchemy
Domain
api, backend

Research direction

Start with the traceback and the resolver in /app/ql/dao/schema.py at resolve_focusInCoworkerById, then determine whether the failure is in graphql-core or the application's SQLAlchemy transaction handling. Reproduce the lost-connection scenario and establish a minimal case before identifying a confirmed fix or documenting the ownership boundary.

Written by the indexing model from the issue text.

Description

i get the following error, it lost connection once a while and not able to reconnect.

sqlalchemy.exc.InvalidRequestError: Can't reconnect until invalid transaction is rolled back

2017-05-25 21:20:40 +0000] [1034] [DEBUG] Closing connection.
[2017-05-25 21:20:42 +0000] [1034] [DEBUG] GET /graphiql
[2017-05-25 21:20:42 +0000] [1034] [DEBUG] Closing connection.
[2017-05-25 21:20:42 +0000] [1032] [DEBUG] GET /graphiql/graphiql.css
[2017-05-25 21:20:42 +0000] [1033] [DEBUG] GET /graphiql/graphiql.min.js
[2017-05-25 21:20:42 +0000] [1032] [DEBUG] Closing connection.
[2017-05-25 21:20:42 +0000] [1033] [DEBUG] Closing connection.
[2017-05-25 21:20:44 +0000] [1033] [DEBUG] POST /graphql
[2017-05-25 21:20:44 +0000] [1033] [DEBUG] Closing connection.
[2017-05-25 21:20:48 +0000] [1034] [DEBUG] POST /graphql
ERROR:graphql.execution.executor:An error occurred while resolving field Query.focusInCoworkerById
Traceback (most recent call last):
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1112, in _execute_context
conn = self.__connection
AttributeError: 'Connection' object has no attribute '_Connection__connection'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1114, in _execute_context
conn = self._revalidate_connection()
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 424, in _revalidate_connection
"Can't reconnect until invalid "
sqlalchemy.exc.InvalidRequestError: Can't reconnect until invalid transaction is rolled back

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/app/venv3/lib/python3.4/site-packages/graphql/execution/executor.py", line 200, in resolve_or_error
return executor.execute(resolve_fn, source, args, context, info)
File "/app/venv3/lib/python3.4/site-packages/graphql/execution/executors/sync.py", line 7, in execute
return fn(*args, **kwargs)
File "/app/ql/dao/schema.py", line 340, in resolve_focusInCoworkerById
return queryfocusInCoworker.filter_by(hubot_id=args.get('coworker_id')).all()
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2703, in all
return list(self)
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2855, in iter
return self._execute_and_instances(context)
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2878, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 945, in execute
return meth(self, multiparams, params)
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
compiled_sql, distilled_params
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1121, in _execute_context
None, None)
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
exc_info
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
raise value.with_traceback(tb)
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1114, in _execute_context
conn = self._revalidate_connection()
File "/app/venv3/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 424, in _revalidate_connection
"Can't reconnect until invalid "
sqlalchemy.exc.StatementError: (sqlalchemy.exc.InvalidRequestError) Can't reconnect until invalid transaction is rolled back [SQL: 'SELECT dashboard_hubot_vitals.id AS dashboard_hubot_vitals_id, dashboard_hubot_vitals.vital_id AS dashboard_hubot_vitals_vital_id, dashboard_hubot_vitals.hubot_id AS dashboard_hubot_vitals_hubot_id \nFROM dashboard_hubot_vitals \nWHERE dashboard_hubot_vitals.hubot_id = %s'] [parameters: [{}]]
[2017-05-25 21:20:48 +0000] [1034] [DEBUG] Closing connection.
[2017-05-25 21:20:49 +0000] [1032] [DEBUG] POST /graphql

Dominant language
Python
Stars
371
Forks
175
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from graphql-python/graphql-core-legacy

All issues in graphql-python/graphql-core-legacy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.