SCM

[#1011026] Long running ObjectContext with EF 4.0

View Trackers | Bugs | Download .csv | Monitor

Date:
2011-04-29 17:47
Priority:
3
State:
Open
Submitted by:
Diane Jewett (jewettdiane)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.11
Category:
Group:
Resolution:
None
Summary:
Long running ObjectContext with EF 4.0

Detailed description
Problem saving changes with a long running context in a transaction.
Get an error Disposing the Context and closing the connection.
Doing something similiar to:
http://msdn.microsoft.com/en-us/library/bb738701.aspx

using (TransactionScope transaction =
new TransactionScope(TransactionScopeOption.Required) {
try
{
context.Connection.Open();

returnObj = ExecuteFunction();

context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);

transaction.Complete();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message, ex);
throw ex;
} finally {
context.Dispose();
}
}


Where Execute function updates multiple records.

Followup

Message
Date: 2011-11-14 15:35
Sender: Diane Jewett

Now I am getting.
Timeout while getting a connection from pool.
Why are the connections not returning to the pool after I
dispose.
I added context.Connection.Dispose() on the finally.
Yet the connection is not being reused. I keep seeing
connections going up.
Date: 2011-05-10 17:12
Sender: Francisco Figueiredo jr.

Hmmmm, maybe this is related:

http://www.postgresql.org/docs/current/static/runtime-config-resource.html#GUC-MAX-PREPARED-TRANSACTIONS

" Setting this parameter to zero (which is the default) disables the prepared-transaction feature. This parameter can only be set at server start."

Can you check this parameter in your postgresql.conf file?

I hope it helps.
Date: 2011-05-10 16:33
Sender: Diane Jewett

This is the output:

ProductsService.CreateObjectContext: Creating the Context
Updated Product: 1 UnitsInStock: 41
Updated Product: 2 UnitsInStock: 19
Updated Product: 3 UnitsInStock: 15
ProductsService.Execute: ProductsService Saved 3 changes.
ProductsService.Execute: Exception. An error occurred while
closing the provider
connection. See the inner exception for details.
System.Data.EntityException: A
n error occurred while closing the provider connection. See
the inner exception
for details. ---> Npgsql.NpgsqlException: ERROR: 55000:
prepared transactions ar
e disabled
at
Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveN
ext()
at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()
at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
at Npgsql.ForwardsOnlyDataReader.NextResult()
at Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1
dataEnumeration, Command
Behavior behavior, NpgsqlCommand command,
NotificationThreadBlock threadBlock, B
oolean synchOnReadError)
at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)
at Npgsql.NpgsqlCommand.ExecuteBlind()
at Npgsql.NpgsqlTransactionCallbacks.PrepareTransaction()
at Npgsql.NpgsqlPromotableSinglePhaseNotification.Prepare
()
at Npgsql.NpgsqlConnection.Close()
at
System.Data.EntityClient.EntityConnection.StoreCloseHelper()
--- End of inner exception stack trace ---
at
System.Data.EntityClient.EntityConnection.StoreCloseHelper()
at System.Data.EntityClient.EntityConnection.Dispose
(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.Data.Objects.ObjectContext.Dispose(Boolean
disposing)
at System.Data.Objects.ObjectContext.Dispose()
at NpgsqlEF4.BaseService`1.Execute() in C:\visual
studio\samples\NpgsqlEF4\Np
gsqlEF4\BaseService.cs:line 70
Date: 2011-04-30 00:51
Sender: Francisco Figueiredo jr.


What is the error you are getting?

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge