[asterisk-bugs] [JIRA] (ASTERISK-25455) Deadlock of PJSIP realtime over res_config_pgsql

mdu113 (JIRA) noreply at issues.asterisk.org
Tue Oct 13 14:16:33 CDT 2015


    [ https://issues.asterisk.org/jira/browse/ASTERISK-25455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=227857#comment-227857 ] 

mdu113 edited comment on ASTERISK-25455 at 10/13/15 2:16 PM:
-------------------------------------------------------------

I guess you're right. To avoid deadlock it should be enough to unlock pgsql_lock before destroying cached table.
Then there's a possibility that after unlocking pgsql_lock in unload_module(), the find_table() or another function waiting for pgsql_lock will reconnect to postgres in _pgsql_exec().
I guess the logic then should be:

int unloading=0;

_pgsql_exec() {
   if (unloading) return NULL;
   ...
}

find_tables() {
   lock pgsql_tables;
   if (unloading) return NULL;
   ...
}

unload_module() {
    lock pgsql_tables;
    lock pgsql_lock;
    unloading=1;
    destroy cached table;
    destroy pgsql connection;
    unlock pgsql_lock;
    unlock pgsql_tables;
}

or something like that



was (Author: mdu113):
I guess you're right. To avoid deadlock it should be enough to unlock pgsql_lock before destroying cached table.
Then there's a possibility that after unlocking pgsql_lock in unload_module(), the find_table() or another function waiting for pgsql_lock will reconnect to postgres in _pgsql_exec().
I guess the logic then should be:

int unloading=0;

_pgsql_exec() {
   if (unloading) return NULL;
   ...
}

find_tables() {
   lock pgsql_tables
   if (unloading) return NULL;
   ...
}

unload_module() {
    lock pgsql_tables
    lock pgsql_lock
    unloading=1
    destroy cached table
    destroy pgsql connection
    unlock pgsql_lock
    unlock pgsql_tables  
}

or something like that


> Deadlock of PJSIP realtime over res_config_pgsql 
> -------------------------------------------------
>
>                 Key: ASTERISK-25455
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-25455
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Channels/chan_pjsip, Resources/res_config_pgsql, Resources/res_pjsip
>    Affects Versions: 13.5.0, 13.6.0
>         Environment: linux 64bit
> kernel 3.10.17
> distro slackware64 14.1 
>            Reporter: mdu113
>            Assignee: Unassigned
>         Attachments: backtrace-threads2.txt, core-show-locks2.txt, core-show-locks.txt, lock-bt-full.txt, res_config_pgsql.c-connlock.diff
>
>
> Asterisk intermittently deadlocks during initial loading of pjsip endpoints. It seems to depend on number of endpoints loaded. With small number of endpoints (up to a 100) it loads ok most of the time. With several hundreds of endpoints it deadlocks sometimes. With several thousand of endpoints it deadlocks most of the time.
> Attached are backtrace and output of "core show locks". The testing was done on asterisk 13.6.0-rc2



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list