Groups | Blog | Home
all groups > sql server programming > june 2006 >

sql server programming : locking behaviour 2005?


Dan Guzman
6/10/2006 9:03:26 AM
Perhaps the database is configured for READ_COMMITTED_SNAPSHOT. This will
change the behavior of applications using the READ_COMMITED isolation level
to row-versioning instead of (pessimistic) locking.

[quoted text, click to view]

Did you mean to say 'unlocks'? BTW, I've been under the impression that
locks were released after update, unless work is done inside an explicit
transaction. I could be wrong though since I never use server-side dynamic
cursors.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Egbert Nierop (MVP for IIS)" <egbert_nierop@nospam.invalid> wrote in
message news:uK9yXJJjGHA.1260@TK2MSFTNGP05.phx.gbl...
[quoted text, click to view]

Dan Guzman
6/10/2006 12:42:36 PM
I ran some ADO tests with (adOpenDynamic and adLockPessimistic) and didn't
see any obvious differences in locking behavior with a simple query.
However, there are many other variables involved. The provider, query
particulars, table indexes and OLEDB properties can all influence
cursor/locking behavior.

SQL 2000 would implicitly convert some server cursor types depending on the
underlying query. I don't know the details of your case but you might check
out the SQL 2005 Books Online topic on cursor behavior changes
(ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/instsql9/html/65eaafa1-9e06-4264-b547-cbee8013c995.htm).

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Egbert Nierop (MVP for IIS)" <egbert_nierop@nospam.invalid> wrote in
message news:%2314Pr0JjGHA.3816@TK2MSFTNGP02.phx.gbl...
[quoted text, click to view]

Egbert Nierop (MVP for IIS)
6/10/2006 3:32:21 PM
Hello,

I know that SQL has changed a lot and that it should be backward compatible
with 2000.

(I'm certified with SQL 2000 fyi).

I'm experiencing a locking problem. For some specific app, I really -needed-
pessimistic row locking.
That was done through OLE DB and the following settings

(serverside cursor!)
propset.AddProperty(DBPROP_IRowsetChange, true);
propset.AddProperty(DBPROP_OTHERUPDATEDELETE, true);
propset.AddProperty(DBPROP_OWNUPDATEDELETE, true);
propset.AddProperty(DBPROP_UPDATABILITY, (LONG) DBPROPVAL_UP_CHANGE |
DBPROPVAL_UP_DELETE);
propset.AddProperty(DBPROP_SERVERCURSOR, true);
propset.AddProperty(DBPROP_LOCKMODE, (LONG)DBPROPVAL_LM_SINGLEROW);

this is more or less similar to an ADODB.Recordset being opened with options
(adOpenDynamic, adLockPessimistic)



But now, SQL 2005 simply seems to ignore these settings, and the locking has
become optimistic, so, it locks as soon as the record update is done.

Can someone shed a light on this?



Thanks!
Egbert Nierop (MVP for IIS)
6/10/2006 4:50:09 PM

[quoted text, click to view]

I've never configured it so.

[quoted text, click to view]

Sure, I mean if you close the record.

[quoted text, click to view]
Egbert Nierop (MVP for IIS)
6/10/2006 8:21:56 PM

[quoted text, click to view]

Thanks.


b.t.w. I believe that SQL 2000 really did respond correctly to the option as
in adOpenDynamic and adLockPessimistic as documented, but SQL 2005, was
proud to have improved scalability, because 'locking problems' should have
gone according to the ads.
Egbert Nierop (MVP for IIS)
6/10/2006 8:27:33 PM

[quoted text, click to view]

Got it.

I modified the SELECT statement that used to be without a lock hint, so it
contains a lock hint named 'UPDLOCK' .

Now the behaviour, is the same as with SQL 2000.
AddThis Social Bookmark Button