Skip to content

Changing isolation level with psycopg2 doesn't work #10032

@alamaison

Description

@alamaison

AKA: Consider supporting SET default_transaction_isolation in the postgresql wire API.

Calling set_isolation_level to change the isolation level of a psycopg2 connection to cockroach fails with this error: ERROR: unknown variable: "DEFAULT_TRANSACTION_ISOLATION". That happens because psycopg2 sends SET default_transaction_isolation TO '<the isolation level>' but cockroach doesn't support that syntax in the postgres wire API (it does in the CLI).

The easiest way to reproduce this it to connect to a cockroach server using psql (psql postgres://localhost:26257) and executing the command at the prompt, e.g. SET default_transaction_isolation TO 'serializable'.

Note: the problem only shows up via psycopg2 if you set the isolation level to something other than the default, i.e. ISOLATION_LEVEL_READ_UNCOMMITTED or ISOLATION_LEVEL_READ_COMMITTED because psycopg2 won't send the command if the isolation level doesn't need to change.

Metadata

Metadata

Assignees

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