lpsmith/postgresql-simple — pull request #34 by joeyadams (2012-08-21 20:28:22+00:00)
Title: Add withTransactionSerializable

This is a convenience function for running serializable transactions, that automatically retries the transaction when a serialization failure arises.

I'm not sure if I like this API though:

withTransactionSerializable :: ReadWriteMode -> Connection -> IO a -> IO a

This only lets you customize the `readWriteMode`. It ought to be possible to customize `isolationLevel`, too, but the only isolation levels in which serialization failure can occur are `RepeatableRead` and `Serializable`.

Perhaps we could do this:

withTransactionRetry :: Connection -> IO a -> IO a
withTransactionRetryMode :: TransactionMode -> Connection -> IO a -> IO a

In any case, we probably don't want to make automatic retry the default behavior of `withTransactionMode`