Closed
Description
- asyncpg version: 0.9.0
- PostgreSQL version: Cockroachdb beta-20170223
- Python version: Python 3.6.0
- Platform: latest OS X
- Do you use pgbouncer?: no
- Did you install asyncpg with pip?: yes
- If you built asyncpg locally, which version of Cython did you use?: 0.25.2
- Can the issue be reproduced under both asyncio and
uvloop?: not related
I'm trying to use cockroachdb with asyncpg.
With plain connection it works like a charm. On the other hand using connection pool fails with the following error:
ERROR:sanic:Traceback (most recent call last):
File "/Users/krisz/.pyenv/versions/miniconda3-latest/envs/ml3/lib/python3.6/site-packages/sanic/app.py", line 391, in handle_request
response = await response
File "/Users/krisz/Workspace/papi/papi/app.py", line 34, in accounts_create
print(results)
File "/Users/krisz/.pyenv/versions/miniconda3-latest/envs/ml3/lib/python3.6/site-packages/asyncpg/pool.py", line 257, in __aexit__
await self.pool.release(con)
File "/Users/krisz/.pyenv/versions/miniconda3-latest/envs/ml3/lib/python3.6/site-packages/asyncpg/pool.py", line 189, in release
await connection.reset()
File "/Users/krisz/.pyenv/versions/miniconda3-latest/envs/ml3/lib/python3.6/site-packages/asyncpg/connection.py", line 412, in reset
''')
File "/Users/krisz/.pyenv/versions/miniconda3-latest/envs/ml3/lib/python3.6/site-packages/asyncpg/connection.py", line 171, in execute
return await self._protocol.query(query, timeout)
File "asyncpg/protocol/protocol.pyx", line 255, in query (asyncpg/protocol/protocol.c:56799)
asyncpg.exceptions.InternalServerError: syntax error at or near "DO"
Caused by the resetting the connection :
await self.execute('''
DO $$
BEGIN
PERFORM * FROM pg_listening_channels() LIMIT 1;
IF FOUND THEN
UNLISTEN *;
END IF;
END;
$$;
SET SESSION AUTHORIZATION DEFAULT;
RESET ALL;
CLOSE ALL;
SELECT pg_advisory_unlock_all();
''')
I don't know the exact solution, but I'd like to use Cockroach with asyncpg :)
I've created an issue for cockroach developers too cockroachdb/examples-orms#19