Hello community.

We have db with "read commited snapshot" set to ON.

We run query:

SET TRANSACTION ISOLATION LEVEL READ COMMITTED
BEGIN TRANSACTION
select * from Account where Id = 14
WAITFOR DELAY '00:00:15' 
COMMIT

While this transaction waiting, other transactions can read this data, so if we run query, we'll immediately get the result.

SET TRANSACTION ISOLATION LEVEL READ COMMITTED
BEGIN TRANSACTION
select * from Account where Id = 14
COMMIT

But when we trying to use DO, we get lock on data.

We run this code twice with 2-3 second difference.

using (var session = DomainBuilder.Domain.OpenSession())
{
    using (var trans = session.OpenTransaction(IsolationLevel.ReadCommitted))
    {

    var acc = session.Query.All<_Account>()
        .FirstOrDefault(a => a.Id == 14);

    Debug.Write("selected: " + acc.Name);

    Thread.Sleep(new TimeSpan(0, 0, 10));

    Debug.Write("stop waiting: " + acc.Name);

    trans.Complete();
}

}

We expected:

selected: John Smith
selected: John Smith
stop waiting: John Smith
stop waiting: John Smith

But result is:

selected: John Smith
stop waiting: John Smith
selected: John Smith
stop waiting: John Smith

Seems that first query locks Account with id=14 from reading by another transactions.

This happens even we use "read uncommited" or set "read commited snapshot" to OFF.

Where is our mistake?

Thanks in advance.

asked Feb 01 '13 at 04:37

Ness's gravatar image

Ness
155222328


One Answer:

Hey, we've found the answer!

Maybe, it could be found somewhere in specifications, but for now answer looks confusing for us.

So, we tested code by doing requests with browser. We decided to try different browser.

And we investigated, that Chrome, Opera and Firefox (newest stable versions) put our second request in queue, but IE9 - don't!

Example (all browsers except IE):

GET http://test/url1/ - send, then pending
GET http://test/url1/ - wait FOR COMPLETION of first request, then send, and then pending

IE:

GET http://test/url1/ - send, then pending
GET http://test/url1/ - send, then pending

It means, that IE allows simultaneous requests per one url, but other browsers - no. Maybe it also differs request by method or query string, we didn't perform such test for now.

And transactions don't affect this behaviour.

Does anybody have any ideas? Why is this happening?

answered Feb 01 '13 at 06:38

Ness's gravatar image

Ness
155222328

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA