Skip to content
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

"readonly" is only supported for serializable transactions #743

Closed
pauldraper opened this issue Apr 23, 2021 · 0 comments · Fixed by #747
Closed

"readonly" is only supported for serializable transactions #743

pauldraper opened this issue Apr 23, 2021 · 0 comments · Fixed by #747

Comments

@pauldraper
Copy link
Contributor

pauldraper commented Apr 23, 2021

asyncpg version: 0.22.0

Example

import asyncio
import asyncpg

async def main():
    conn = await asyncpg.connect()
    conn.transaction(isolation='repeatable_read', readonly=True)

asyncio.run(main())

Expected result

No error.

Actual result

 "readonly" is only supported for serializable transactions

That's just not true.

START TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY;

The really bizarre thing is that some had to go out of their way to break this in asyncpg.

And not only that, but the check doesn't really even work that well.

A workaround is to first run SET default_transaction_isolation = 'repeatable read'; for the connection, and then avoid passing an isolation argument to the transaction() function.

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 a pull request may close this issue.

1 participant