Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# adrian.libotean 6/28/2006 11:11 AM
I've created a custom website with a number of custom modules and everything went fine until we first released it for a real life test. When two or more users are accessing the website there are lot of crashes from NHibernate:

2006-06-28 19:07:21,998 [5692] ERROR NHibernate.StaleObjectStateException [(null)] <(null)> - An operation failed due to stale data
NHibernate.StaleObjectStateException: Row was updated or deleted by another transaction for Cuyahoga.Core.Domain.Node instance with identifier: 1
2006-06-28 19:07:21,998 [5692] ERROR NHibernate.Impl.SessionImpl [(null)] <(null)> - could not synchronize database state with session
NHibernate.StaleObjectStateException: Row was updated or deleted by another transaction for Cuyahoga.Core.Domain.Node instance with identifier: 1
at NHibernate.Persister.AbstractEntityPersister.Check(Int32 rows, Object id)
at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Object oldVersion, Object obj, SqlString sqlUpdateString, ISessionImplementor session)
at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledUpdate.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()
2006-06-28 19:07:25,664 [5692] ERROR NHibernate.StaleObjectStateException [(null)] <(null)> - An operation failed due to stale data
NHibernate.StaleObjectStateException: Row was updated or deleted by another transaction for Cuyahoga.Core.Domain.Node instance with identifier: 1
2006-06-28 19:07:25,664 [5692] ERROR NHibernate.Impl.SessionImpl [(null)] <(null)> - could not synchronize database state with session
NHibernate.StaleObjectStateException: Row was updated or deleted by another transaction for Cuyahoga.Core.Domain.Node instance with identifier: 1
at NHibernate.Persister.AbstractEntityPersister.Check(Int32 rows, Object id)
at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Object oldVersion, Object obj, SqlString sqlUpdateString, ISessionImplementor session)
at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledUpdate.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()

Does enybody know what this is all about? Thanks.
# martijnb 6/28/2006 11:49 AM
What is your test platform (OS, database)?

The errors indicate that there is something going wrong with the update timestamps.
# adrian.libotean 6/28/2006 1:18 PM
Windows 2003 Server
ASP.Net 2.0
NHibernate 1.0.2.0

It seems that when I just select with either a query or a criteria from the nodes table NHibernate generates several (more than a hundred) updates for the nodes table (lloks live every node is udpated) and when several users try to access a page these updates conflict.

PS: I've commented out the timestamp property UpdateTimestamp and removed it from the mapping xml. I still get the same updates:

exec sp_executesql N'UPDATE cuyahoga_node SET metaSource = @p0, shortdescription = @p1, simpletextinmenus = @p2, showinsitemap = @p3, internalTransfer = @p4, culture = @p5, tags = @p6, templateid = @p7, showinnavigation = @p8, title = @p9, parentnodeid = @p10, metaDescription = @p11, position = @p12, linktarget = @p13, metaKeywords = @p14, linkurl = @p15, cacheValidity = @p16, active = @p17, cacheMode = @p18, inserttimestamp = @p19, siteid = @p20 WHERE nodeid = @p21', N'@p0 int,@p1 nvarchar(4000),@p2 bit,@p3 bit,@p4 bit,@p5 nvarchar(4000),@p6 nvarchar(4000),@p7 int,@p8 bit,@p9 nvarchar(4000),@p10 int,@p11 ntext,@p12 int,@p13 int,@p14 ntext,@p15 nvarchar(4000),@p16 int,@p17 bit,@p18 int,@p19 datetime,@p20 int,@p21 int', @p0 = 0, @p1 = N'partners/locate-partner', @p2 = 0, @p3 = 1, @p4 = 0, @p5 = N'en-US', @p6 = NULL, @p7 = 11, @p8 = 1, @p9 = N'Locate a Partner', @p10 = 22, @p11 = NULL, @p12 = 2, @p13 = 0, @p14 = NULL, @p15 = NULL, @p16 = -1, @p17 = 1, @p18 = 5, @p19 = 'May 5 2006 3:39:18:000PM', @p20 = 1, @p21 = 57

They all look like this. When the timestamp was active the WHERE clause included a test for the timestamp as well (along with the id).
# adrian.libotean 6/28/2006 3:31 PM
I've compared the data in the cuyahoga_node table BEFORE and AFTER the updates and it seems to be unchanged, so NHIbernate just resets the fields with the same values.
# martijnb 6/28/2006 3:58 PM (edited 6/28/2006 4:00 PM)
Are you sure it's not something in your own code? Looking at the generated SQL, I smell a heavily modified version of Cuyahoga. Some custom caching solution?
# adrian.libotean 6/29/2006 2:24 AM
Yes, you are right, it is a heavily modified version of Cuyahoga. I've finally tracked down the problem to a NHibernate class mapping issue. Thanks for all your input.
# martijnb 6/29/2006 3:26 AM
Next time, please mention that you're dealing with a modified Cuyahoga a little bit earlier just to give me a little bit less grey hairs ;) .
# bobwold 10/18/2007 3:18 AM
Adrian:
What was the problem in your mapping file? I'm writing a custom module, and I hit this same error. I'll look closer at my mappings, and if I see something I'll post it, but this error is totally wacky.
# bobwold 10/18/2007 3:42 AM
This one was tricky, The error message is so informative, that I assumed it was accurate, when it was actually just mis-leading.

It turned out that it had nothing to do with the Id of the object. It was actually being caused because I had a timestamp node, and the value in the database for that field was null. If I changed this to a property of type DateTime, the error was way closer to accurate, and it was a quick and easy fix.

I guess that's one rule you really need to be strict about: keep your null constraints in the DB and in Hibernate the same :)

...Also, Just to clarify, I didn't get this error on the Node object, but on my own hibernate object.
# terotero 5/1/2009 12:46 AM
Hello:

Hi have the same problem with cuyahoga 1.5.2 and 1.60
I run cuyahoga on GNU/Linux Debian with mono 2.0 and 2.4. with apacha 2.0
I have create other module with out Database.

My cuyahoga show error message:
in : http://192.169.24.14/cuyahoga/Login.aspx
this error

Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for Cuyahoga.Core.Domain.User instance with identifier: 1
Description: HTTP 500. Error processing request.

Stack Trace:

NHibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for Cuyahoga.Core.Domain.User instance with identifier: 1
at NHibernate.Persister.Entity.AbstractEntityPersister.Check (Int32 rows, System.Object id, Int32 tableNumber, IExpectation expectation, IDbCommand statement) [0x00000]
at NHibernate.Persister.Entity.AbstractEntityPersister.Update (System.Object id, System.Object[] fields, System.Object[] oldFields, System.Boolean[] includeProperty, Int32 j, System.Object oldVersion, System.Object obj, NHibernate.SqlCommand.SqlCommandInfo sql, ISessionImplementor session) [0x00000]


--------------------------------------------------------------------------------
Version information: Mono Version: 2.0.50727.42; ASP.NET Version: 2.0.50727.42