Skip to content

"readonly" is only supported for serializable transactions #743

Closed
@pauldraper

Description

@pauldraper

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions