Hi,
We are maintaining cache tables in SQL Server where tables required for cache are marked for caching using [dbo].[AspNet_SqlCacheRegisterTableStoredProcedure] and those marked tables are added into dbo.AspNet_SqlCacheTablesForChangeNotification and triggers
added to cache table to maintain changeid
.Net is using NHibernate with multiple webservers where different clients are trying to access the table of cache and others are reading in parallel to check for any change in cached tables
When i have enabled T1222, i keep on getting deadlock-list in the logs
As per deadlock graph, most of the time deadlock-victim is SELECT
SELECT tableName, changeId FROM dbo.AspNet_SqlCacheTablesForChangeNotification
which at the moment is tolerable, However in few cases victim is Update
UPDATE dbo.AspNet_SqlCacheTablesForChangeNotification WITH (ROWLOCK) SET changeId = changeId + 1 WHERE tableName = @tableName
Questions:
1: Can we avoid these kind of deadlocks somehow?
2: In case of deadlock when Update is a victim, it throws an error within trigger "dbo.Table1_AspNet_SqlCacheNotification_Trigger" which by design, rolls back external transaction as well, and in our case we want trigger not to throw such error to
external transaction, can this be handled with some option or logic?
Any idea, how to handle this situation?
Thanks.
Be positive, to see the world more positive.