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

Support Transactions with different isolation levels #476

Closed
jtaekema opened this issue Jul 20, 2016 · 6 comments
Closed

Support Transactions with different isolation levels #476

jtaekema opened this issue Jul 20, 2016 · 6 comments

Comments

@jtaekema
Copy link

jtaekema commented Jul 20, 2016

Postgres supports several isolation levels: see https://www.postgresql.org/docs/current/static/transaction-iso.html

  • Read Uncommitted (internally the same as Read Committed)
  • Read Committed (default)
  • Repeatable Read
  • Serializable

Some types of systems need the guarantees provided by the more strict isolation levels.

To get around this support I have been running a simple command to upgrade the transaction, but it would be nice if there was an easy way to start the transaction that way.

Like:

conn.BeginTransaction(IsolationLevel.RepeatableRead)

There are other options that would be useful for performance tuning, such as READ WRITE, READ ONLY, and [ NOT ] DEFERRABLE.

@johto
Copy link
Contributor

johto commented Jul 20, 2016

To get around this support I have been running a simple command to upgrade the transaction, but it would be nice if there was an easy way to start the transaction that way.

Unfortunately I don't see how this could possibly work given that we have to work with the interface database/sql provides.

@msakrejda
Copy link
Contributor

I agree--I think the limited database/sql API ties our hands here. Do you have a concrete suggestion as to how to approach this?

@itsjamie
Copy link

itsjamie commented Nov 7, 2016

This issue should be able to be fixed with the introduction of IsolationLevels to database/sql with 1.8 assuming enough implementation happens with #531 for it not to be pulled.

@ThomasHabets
Copy link

This is in 1.8 and lack of it is preventing me from cleaning up code manually setting isolation level inside every transaction.

@mattyw
Copy link

mattyw commented Jun 23, 2017

Has this not been fixed now that ed1a26d has landed?

@ThomasHabets
Copy link

I can confirm that it works perfectly for me.

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

No branches or pull requests

6 participants