This question is locked. New answers and comments are not allowed.
Hi there,
the WPF application i developed is based on a domain model approach data access layer.
It's multithreaded, and i have put a singleton to ensure only one access to the dbcontext simultaneously.
The backend configuration defines that:
The version i use is 2011.1.411.2.
Initially, i encountered some issues while accessing the context, because of several threads accessing it at the same time.
To workaround that, i have added some protection:
I'm not sure it's the correct way to work with multithreaded application, but it's the best i could do to avoid exceptions when saving the changes on the diagram if those protections were not put.
Today, is still have some problems, still when saving the changes on the context, even though i'm sure that no other access to the diagram are running.
2 exceptions occurs quite frequently.
First one is:
tx already active
‡ Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
‡ Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x)
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.beginCommon()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.begin()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.isResourceManagerEnlisted()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.isActive()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
‡ Telerik.OpenAccess.RT.EnlistableObjectScope.CommitChanges()
Second one is:
Telerik.OpenAccess.OpenAccessContextBase.SaveChanges(ConcurrencyConflictsProcessingMode failureMode)
‡ Telerik.OpenAccess.OpenAccessContextBase.SaveChanges()
‡ PHS.BusinessObjects.dbContext.SaveChangesInDiagram() dans BusinessObjects\dbContext.cs:ligne 177
Telerik.OpenAccess.RT.sql.SQLException: L'opération de transaction ne peut pas être exécutée parce que des demandes sont en attente dans cette transaction. (in english: the transaction operation cannot be performed because there are pending requests working on this transaction.)
‡ Telerik.OpenAccess.RT.Adonet2Generic.Impl.ConnectionImp.commit()
‡ OpenAccessRuntime.Relational.conn.LoggingConnection.commit()
‡ OpenAccessRuntime.Relational.conn.PooledConnection.commit()
It seems that there is a sort of delay when committing a transaction, or something like that, and the next transaction cannot access the db because of that, isn't it?
As a second workaround (you will see how bad it is), i have put a try catch block around the save changes, and if it fails, i wait 1 seconds and try again, and this seems to work at each time...
Can anyone give a hand on that, as i'm not far from despair...
Any advice on how to work properly with multithreaded applications, or any tutorial or example would also help (i have not found much information in the integrated help on multithreading concerns).
And more important, merry christmas and happy new year to everybody,
Antoine.
the WPF application i developed is based on a domain model approach data access layer.
It's multithreaded, and i have put a singleton to ensure only one access to the dbcontext simultaneously.
The backend configuration defines that:
- Isolation level is serialization
- Transaction mode is pessimistic locking first
- Multithreaded context option is checked
The version i use is 2011.1.411.2.
Initially, i encountered some issues while accessing the context, because of several threads accessing it at the same time.
To workaround that, i have added some protection:
- a lock on the diagram each time a read or a write is done on it
- a semaphore on the update of any object of the context (set prior to update attributes and released after the SaveChanges)
I'm not sure it's the correct way to work with multithreaded application, but it's the best i could do to avoid exceptions when saving the changes on the diagram if those protections were not put.
Today, is still have some problems, still when saving the changes on the context, even though i'm sure that no other access to the diagram are running.
2 exceptions occurs quite frequently.
First one is:
tx already active
‡ Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
‡ Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x)
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.beginCommon()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.begin()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.isResourceManagerEnlisted()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.isActive()
‡ OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
‡ Telerik.OpenAccess.RT.EnlistableObjectScope.CommitChanges()
Second one is:
Telerik.OpenAccess.OpenAccessContextBase.SaveChanges(ConcurrencyConflictsProcessingMode failureMode)
‡ Telerik.OpenAccess.OpenAccessContextBase.SaveChanges()
‡ PHS.BusinessObjects.dbContext.SaveChangesInDiagram() dans BusinessObjects\dbContext.cs:ligne 177
Telerik.OpenAccess.RT.sql.SQLException: L'opération de transaction ne peut pas être exécutée parce que des demandes sont en attente dans cette transaction. (in english: the transaction operation cannot be performed because there are pending requests working on this transaction.)
‡ Telerik.OpenAccess.RT.Adonet2Generic.Impl.ConnectionImp.commit()
‡ OpenAccessRuntime.Relational.conn.LoggingConnection.commit()
‡ OpenAccessRuntime.Relational.conn.PooledConnection.commit()
It seems that there is a sort of delay when committing a transaction, or something like that, and the next transaction cannot access the db because of that, isn't it?
As a second workaround (you will see how bad it is), i have put a try catch block around the save changes, and if it fails, i wait 1 seconds and try again, and this seems to work at each time...
Can anyone give a hand on that, as i'm not far from despair...
Any advice on how to work properly with multithreaded applications, or any tutorial or example would also help (i have not found much information in the integrated help on multithreading concerns).
And more important, merry christmas and happy new year to everybody,
Antoine.