Re: Locking problem

From: Francisco D. Kurpiel (francisco.kurpiel_at_westbest.com.br)
Date: 03/02/04


Date: Tue, 2 Mar 2004 11:31:06 -0300


(The indexes names!!! Who I lived before this proc?)

> The reason for all of this is that without snapshot concurrency, it's easy
> to become overly syncronized, and loose concurency. There is a very
strong
> policy in favor of concurrency, and so you might not get all the locks you
> expect.

It’s okay to be a default behavior, but I don't have the option to serialize
data access when using covering index? Allowing serialization just on index
doesn’t sounds very arbitrary? If Microsoft chooses to don’t allow
programmers to serialize data access (ignoring the standard definition of
serializable transaction level), why they just remove the serialization
resource of the SQL Server? This is a big argument to concurrency (just
kidding...). If I create an index exactly to be a covering index to a
procedure that’s working may I insert a bug on the app?

(woo-hoo!!! index names!!)

Suppose we create a select statement on three tables for some application.
We released the app to users do her work. After some weeks the query plan,
initially very trivial to waste the time of the optimizer, is getting more
costly. SQL Server wastes just some milliseconds and chooses another plan,
with other indexes. I now that this example is a little obvious, but it
illustrates perfectly my preoccupation. Some applications need serialization
in some resources. And serialization needs to be deterministic. I’m sorry to
be so emphatic, but this kind of problem is my responsibility on my project.

>
> select * from bla takes an IS lock on bla and an S lock on un_bla_nome
> because un_bla_nome is, suprisingly, a covering index for the query. It's
> only a covering index because the only columns in bla, but not in
> un_bla_nome, are the clustered index columns (ie id). The clustered index
> columns are included in the index because that's the only way to locate a
> row in a table with a clusered index.
>
> And IX and IS are compatable. Here's the lock compatability matrix from
> BOL.
>
You are right. But I forgot to say that the behavior I just described occurs
when table doesn’t have clustered index. Without clustered index the fist
script creates an IX lock (if using the xlock hint) on the table, and the
second creates S lock, what solves the restrict problem of my example. But
if I do a “select nome from bla” on the second script it uses the unique
index, creating just a IS lock on the table and some locks that’s just
applicable to this index, what I just discovered that don’t grant anything.

>
> > Do you have a link to some documentation about this subject? My current
> > project probably will become big and I don’t want more surprises.
> >
>
> Inside Microsoft® SQL Server™ 2000 by Kalen Delaney
> http://www.microsoft.com/MSPress/books/4297.asp
>

Hei, I have read this book! But I don't remember anything about covering
index being locked independently of the table. I will reread this session.

> >
> > I appreciate your help and the enfort on make it clear. Any additional
> > reference will be welcome.
> >
> > PS: Where did you get this sp_lock2? The one that I have doesn’t show
the
> > index name. It helps a lot.
>
> http://support.microsoft.com/support/kb/articles/Q255/5/96.ASP
>
I was using this one before you send me the other script.

Thank you for the help and sorry for my poor english.

(hehehe... index names...)



Relevant Pages

  • Re: Lock-free databases
    ... > lock, latch, enqueue, or other name is a lock for the purpose of this ... Database concurrency control. ... be it Oracle or SQL Server ...
    (comp.databases.theory)
  • Re: How to update multiple rows atomically
    ... I don't want to lock just one up, ... be subject to deadlock or starvation? ... Whether it might experience deadlock or starvation or any other concurrency problem will depend on what concurrency mechanisms the dbms implements, which concurrency options the dba and various users choose, and how the dbms implements them. ...
    (comp.databases.theory)
  • about concurrency (again)
    ... I have been reading the recent thread about concurrency, ... def disable_safe_mode: ... # "instantiate" the manager in the main thread ... the lock could be a file lock or a transactional lock. ...
    (comp.lang.functional)
  • Re: [PHP] Concurrency in a multi-user environment
    ... One idea is to lock the record when User A enters but this may make it inaccessible for a long period if User A decided to get up and leave for a three hour lunch. ... locking a record means I have to convert from MyISAM to InnoDB but this is probably necessary for concurrency. ... Compare it to the incoming data and your stored copy ... You can work out which fields have been changed since the user started editing by comparing the stored copy with the latest you got in step 2 ...
    (php.general)
  • Re: Concurrency Issues
    ... >>done on the file such as ADD at EOF, Modify, Delete, make rise to race ... > If you use file locking, the lock can be specific to a particular ... you lose the appearance of concurrency. ...
    (comp.unix.programmer)