Page 1 of 1

Rollback is called on Postgres DB when closing connection

Posted: Thu 30 Jul 2009 12:10
by marek.kulvejt
Hello,

we get 'NOTICE: there is no transaction in progress' message on the server when closing a connection that contained a transaction. Pseudo code:

using (PgSqlConnection conn = new PgSqlConnection(..))
{
conn.Open();

using (PgSqlTransaction trans = conn.BeginTransaction(...))
{
...execute command under the transaction

if (everythingWentOk)
{
trans.Commit();
}
else
{
trans.Rollback();
}
}
} // !!!! There is the problem here: when executing "conn.Close()", the DB server complains

When we call conn.Commit() the situation does not change.

What are we doing wrong? Is it a bug in the dotConnect driver?

Thanks in advance,
Marek Kulvejt

P.S. The data are stored well and everything seems to work. The problem is that we save a lot of data and we get approx. 1GB of log every day. Moreover, the database itself must do some work just to execute an useless command.

Posted: Fri 31 Jul 2009 12:58
by Shalex
This is a designed behaviour. It is necessary to make rollback for the connection before placing it back to pool. As a workaround, you can turn off connection pooling (the Pooling=false; entry in the connection string).