Bug #40899 Mutex not unlocked in ndb_util_thread_func

Submitted: 20 Nov 2008 19:16 Modified: 28 Jan 2009 17:33
Reporter: Marc ALFF Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:mysql-5.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: 5.1 and up

[20 Nov 2008 19:16] Marc ALFF
Description:
In 5.1, in ha_ndb_cluster.cc, in ndb_util_thread_func(),
the code contain at the beginning:

   pthread_mutex_lock(&LOCK_ndb_util_thread);

  thd= new THD; /* note that contructor of THD uses DBUG_ */
  if (thd == NULL)
  {
    my_errno= HA_ERR_OUT_OF_MEM;
    DBUG_RETURN(NULL);
  }

If the server is out of memory (which might happen under normal operations if we implement per thread memory quotas), this function returns while holding a lock on the LOCK_ndb_util_thread mutex.

Note that fix bug exist in 5.1 and 6.0, but not in 5.0,
so technically this is a risk of regression with a dead lock.

How to repeat:
Code review

Suggested fix:
Fix the indentation
Fix the comments typos
Allocate THD before locking the mutex, which will make the critical section smaller as well.
[16 Apr 2009 13:51] Jonathan Miller
Should be an unlock when exiting, but not during run time/per martin

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.