buckbuchanan wrote:
Hi Otis
Many thanks for taking the time to reply.
I have had a look at the profiler and I can see the nolock option being appended to the queries and the problem has now resolved.
I agree with your comments about the writer app and it is now being changed. However, I am concerned that if an app can bring the system to it's knees so could anything else (a long report being run, someone querying the DB, etc). This is why I want the read process to be un-aware of locks.
So, the only outstanding question I have is that after reading the threads posted above it looks to me like adding "nolocks" is the same as using READUNCOMMITTED. Is this really the case? I can't allow this process to pick up uncommitted data.
You can't have it both ways. The locks are set by the RDBMS to prevent readers reading the rows which are altered. The transaction isolation of the WRITER determines if readers can read the locked rows. As the reader has NOLOCK set, it reads all rows regardless of locks, so it will read uncommitted data.
You can't have a deadlock by two processes working on the same table, or at least it's not common. You can have a deadlock with 1 process working on the table with 2 threads, where one thread places locks, CPU goes over to other thread, thread place locks, CPU goes back to first thread, thread can't proceed as it has to wait for the locks of other thread to be lifted, but those will never be lifted as that thread has to wait for the first thread's locks to be lifted.
What you could do is creating a process queue (just a queue in which you place objects what to do, and a thread reads them one at a time and executes them) for the operations on this table.
What's also an option is to create a way to avoid having to poll the table. Polling is expensive, you could research the option where the receiver of the polling result will receive a message, call, object from the routine which will WRITE a value in the table: e.g.: routine X writes an entity to the table, calls afterwards routine Y which will then either poll or if that's unnecessary because X has passed on the info what's been changed to Y, send the changes to the receiver of the polling result.