[Home]

Summary:ASTERISK-14058: [patch] Bad locking logic on res_config_mysql.c
Reporter:Cristian Dimache (cristiandimache)Labels:
Date Opened:2009-05-03 14:09:26Date Closed:2009-05-14 14:21:21
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Addons/res_config_mysql
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20090514__issue15090.diff.txt
Description:store_mysql calls find_database(), which locks the database handle.
Then, it calls internal_require(), which calls require_mysql(), which calls find_table(), which calls find_database(), thus requesting a new lock on the database handle.
I could be wrong in the call chain, but the result is always the same: Asterisk stops waiting for a lock to be released.

****** ADDITIONAL INFORMATION ******

Problem occurs on version 1.6.1.0 of asterisk-addons, but I think it is there since 1.6.1-rc1
Comments:By: Tilghman Lesher (tilghman) 2009-05-04 12:29:32

Have you tried this and gotten a lockup, or are you speculating?

By: Cristian Dimache (cristiandimache) 2009-05-04 12:41:01

I've tried it. A patch is a little above my skills and spare time, but I added some debug and reached at that conclusion.

By: Tilghman Lesher (tilghman) 2009-05-04 12:53:45

Okay, then compile with 'DEBUG_THREADS' and obtain a 'core show locks' when this occurs.

A lockup should not occur, because we're using recursive locks in Asterisk.  The fact that a mutex was already locked by our same thread isn't relevant to our programming model.

By: Cristian Dimache (cristiandimache) 2009-05-11 00:58:17

I should be able to test it tonight or in about 48h. Thanks for waiting.

By: Tilghman Lesher (tilghman) 2009-05-14 09:01:05

Patch uploaded.  Found with a 'core show locks' in related issue ASTERISK-14113.  Please test and verify.

By: Cristian Dimache (cristiandimache) 2009-05-14 13:37:06

Looks okay.

BTW, is ASTERISK-14113 private? Should it be?

By: Leif Madsen (lmadsen) 2009-05-14 13:39:58

Yes, it is marked private because the reporter requested it since it contained some personal information.

By: Digium Subversion (svnbot) 2009-05-14 14:17:01

Repository: asterisk-addons
Revision: 910

U   trunk/res/res_config_mysql.c

------------------------------------------------------------------------
r910 | tilghman | 2009-05-14 14:17:00 -0500 (Thu, 14 May 2009) | 7 lines

Change database list to be rwlist locks, to avoid a potential deadlock between 2 readers.
(closes issue ASTERISK-14058, related to issue ASTERISK-14113)
Reported by: cristiandimache
Patches:
      20090514__issue15090.diff.txt uploaded by tilghman (license 14)
Tested by: cristiandimache

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk-addons?view=rev&revision=910

By: Digium Subversion (svnbot) 2009-05-14 14:19:51

Repository: asterisk-addons
Revision: 913

_U  branches/1.6.1/
U   branches/1.6.1/res/res_config_mysql.c

------------------------------------------------------------------------
r913 | tilghman | 2009-05-14 14:19:50 -0500 (Thu, 14 May 2009) | 14 lines

Merged revisions 910 via svnmerge from
https://origsvn.digium.com/svn/asterisk-addons/trunk

........
 r910 | tilghman | 2009-05-14 14:16:53 -0500 (Thu, 14 May 2009) | 7 lines
 
 Change database list to be rwlist locks, to avoid a potential deadlock between 2 readers.
 (closes issue ASTERISK-14058, related to issue ASTERISK-14113)
  Reported by: cristiandimache
  Patches:
        20090514__issue15090.diff.txt uploaded by tilghman (license 14)
  Tested by: cristiandimache
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk-addons?view=rev&revision=913

By: Digium Subversion (svnbot) 2009-05-14 14:21:20

Repository: asterisk-addons
Revision: 914

_U  branches/1.6.2/
U   branches/1.6.2/res/res_config_mysql.c

------------------------------------------------------------------------
r914 | tilghman | 2009-05-14 14:21:20 -0500 (Thu, 14 May 2009) | 14 lines

Merged revisions 910 via svnmerge from
https://origsvn.digium.com/svn/asterisk-addons/trunk

........
 r910 | tilghman | 2009-05-14 14:16:53 -0500 (Thu, 14 May 2009) | 7 lines
 
 Change database list to be rwlist locks, to avoid a potential deadlock between 2 readers.
 (closes issue ASTERISK-14058, related to issue ASTERISK-14113)
  Reported by: cristiandimache
  Patches:
        20090514__issue15090.diff.txt uploaded by tilghman (license 14)
  Tested by: cristiandimache
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk-addons?view=rev&revision=914