List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:July 30 1999 10:28pm
Subject:Merge thread lock queue
View as plain text  
>>>>> "Steven" == Steven Roussey <sroussey@stripped>
> writes:

Steven> Hi all!
Steven> Since we have locking issues (i.e. some thread is locking a table used by
Steven> everyone) I wanted to make mysql use a single queue rather than separate
Steven> read and write queues. Does the following change accomplish this, and what
Steven> are some of the dangers of this change?

Steven> Change (in thr_lock.c):

Steven> 	#define LOCK_CMP(A,B) ((byte*) (A->lock) - (uint) ((A)->type) <
> (byte*)
Steven> (B->lock)- (uint) ((B)->type))

Steven> to

Steven> 	#define LOCK_CMP(A,B) ((byte*) (A->lock) < (byte*) (B->lock))

Steven> TIA!


No, the above will not do what you want!

The above sorts all WRITE locks in one SQL statement before READ
locks. If you don't do this, then two clients that request a write
lock on one table and a read lock on some other table may deadlock!

If you want only a single lock queue, you must change the

thr_lock() function to only use one lock list.  (This is not trivial,
but not that hard)

Merge thread lock queueSteven Roussey19 Jul
  • Merge thread lock queuesinisa19 Jul
  • Merge thread lock queueMichael Widenius31 Jul