sql - Using IsolationLevel.Snapshot but DB is still locking -


I'm an ADO. I'm part of a team that creates a net based web-site. We are sometimes working together with the development copy of many developers and automated testing tool databases.

We use snapshot isolation level, which is the best of my knowledge, uses optimistic concurrency: instead of locking, hopes for the best and throws an exception if you do the transaction During the change of rows affected by any other party, try to do the transaction.

We use this to make the snapshot isolation level:

  Alternative Database & lt; Database Name & gt; Set ALLOW_SNAPSHOT_ISOLATION on;  

and C #:

  Transactions = SqlConnection.BeginTransaction (IsolationLevel.Snapshot); Keep in mind that the segregation level snapshot is not similar to a read comet snapshot, which we have also tried to do, but it is not currently being used. 

When a developer enters into debug mode and. Prevents the NET app, during debugging, they will maintain a connection with an active transaction. Now, I hope this will not be a problem - after all, all transactions are using the snapshot isolation level, so a transaction has been stopped, while other transactions should be able to proceed normally as prevented transactions Of course, when a canceled transaction is completed, it can detect a conflict; But it is acceptable until other developers and automatic tests can be interrupted.

However, in practice, when a person stops the transaction during debugging, then all other DB users who try to reach the same lines using the snapshot isolation level.

Does anyone know why this happens, and / or how can I get true optimistic (non-blocking) concurrency?

Resolution (one unfortunate one for me) : It is well known that writers always block other authors; It is supported - it does not quite come out and says this, but only ever reader-writer mentions to avoid locks. In essence, the behavior I want does not apply to SQL Server.

The snapshot isolation level is affected, such as the level of all isolation, only the writing is still a second If you believe that what you are looking at reads the blocks, then you should check further and check resource types and resource names, which are blocked (wait_type and wait_resource these) .

I do not advise in making a code change to support a scenario in which the developers stare at the debugger for minutes in the end. If you think this scenario can repeat in production (i.e. the client is hanging) then there is a different story that you want to write to reduce your writing and to write all at the end of the transaction, a single call In this way, before any such withdrawal, no customer can keep the X lock in for long (can not hang while holding X lock), it is very difficult to pull off in practice and developers The part is a lot of need discipline to data access code to write.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -