[Dbix-class] transaction isolation levels

Peter Rabbitson rabbit+dbic at rabbit.us
Mon May 6 08:33:37 GMT 2013


On Sat, May 04, 2013 at 04:12:38PM +0100, Stanley Pilton wrote:
> I have been unable to find documentation about how to use different
> transaction isolation levels, or even what the default isolation level
> is, generally, but also specifically for postgres.
> 
> I've read documentation such as that for the methods
> DBIx::Class::Schema::txn_do and DBIx::Class::Storage::txn_begin
> 
> By experiment, I have determined that "read committed" is in use.
> This is postgres's default.  How do I go about using either postgres's
> "repeatable read" or "serializable" isolation levels?  I'll then want
> to know what the exceptions will look like if a transaction fails at
> either of these levels due to a conflict.

It is entirely out of the scope of DBIC to handle isolation levels,
and as you correctly noticed you observe the default isolation level
upon connection.

All you need to do is get a connection (or several for different levels, 
in case you need them) with the proper on_connect_do [1] magic [2] being
executed on every (re)connect.

Does this answer your question or did I miss something...?

Cheers

[1] https://metacpan.org/module/DBIx::Class::Storage::DBI#on_connect_do
[2] SET SESSION CHARACTERISTICS AS TRANSACTION .... http://www.postgresql.org/docs/9.2/static/sql-set-transaction.html




More information about the DBIx-Class mailing list