From Alexey Ts, 4 Years ago, written in FreeSWITCH.
- view diff
Embed
  1. Hello.
  2.  
  3. There is 1700 calls daily. Max 20 simultaneous calls, usually 1-2.
  4. And freeswitch crashed about 2 times a day.
  5. There is Python script that polls the database and creates calls via the console command using a Lua script
  6.  
  7. >>>
  8. proc = subprocess.Popen(shlex.split('fs_cli -x "lua out_confirm_order.lua ' + phone + ' ' + phone7 + ' ' + str(id) + ' ' + str(iscell) + ' \'' + streetname + '\' \'' + housename + '\'"'))
  9. <<<
  10.  
  11. Lua:
  12.  
  13. >>>
  14. function save_status_out_call(id, hcause)
  15.     local dbh = freeswitch.Dbh(freeswitch.getGlobalVariable("db_connection"))
  16.    
  17.     if (hcause == "ORIGINATOR_CANCEL" or hcause == "NORMAL_UNSPECIFIED") then
  18.         hcause = "rej"
  19.     elseif (hcause == "USER_BUSY") then
  20.         hcause = "busy"
  21.     elseif (hcause == "NO_ANSWER") then
  22.         hcause = "noans"
  23.     elseif (hcause == "NORMAL_CLEARING") then
  24.         hcause = "clear"
  25.     else
  26.         --hcause = "rej"
  27.     end
  28.    
  29.     assert(dbh:connected())
  30.     dbh:query("select cc.proc_call_center_out_reject(" ..  id .. ",'" .. hcause .. "')", function(row)
  31.        
  32.     end)
  33.    
  34.     dbh:release()
  35. end
  36.  
  37. local phone = argv[1]
  38. local phone7 = argv[2]
  39. local id = argv[3]
  40. local iscell = argv[4]
  41. local streetname = argv[5]
  42. local housename = argv[6]
  43.  
  44. originate_str1 = "{origination_caller_id_name='',originate_timeout=50,origination_caller_id_number=+79997771111,ignore_early_media=true}sofia/gateway/mobile_st/" .. phone7
  45.  
  46. freeswitch.consoleLog("notice", "OUT CALL START to " .. phone .. " " .. phone7 .. " iscell " .. iscell .. " by id " .. id .. "\n");
  47.  
  48. start_time = os.time()
  49. local session1 = freeswitch.Session(originate_str1);
  50. freeswitch.consoleLog("notice", string.format("\n OUT CALL DIF4 %s ID %s \n", os.difftime(os.time(),start_time), id));
  51.  
  52. if (session1:ready()) then
  53.     session1:setVariable("outCallsID", id);
  54.     session1:execute("start_dtmf");
  55.    
  56.     session1:setVariable("dataRowStreet", streetname);
  57.     session1:setVariable("dataRowHouse", housename);
  58.    
  59.     session1:execute("ivr","menu_out_call_confirm_order_ivr");
  60.    
  61.     hcause = session1:hangupCause();
  62.    
  63.     if not session1:getVariable("delOutOrder") then
  64.        freeswitch.consoleLog("notice", "OUT 1 by id "  .. id .. "\n");
  65.         if hcause == "SUCCESS" then
  66.            freeswitch.consoleLog("notice", "OUT 2 by id "  .. id .. "\n");
  67.             local dbh = freeswitch.Dbh(freeswitch.getGlobalVariable("db_connection"))
  68.  
  69.             assert(dbh:connected())
  70.             dbh:query("select cc.proc_call_center_order_extend(" ..  id .. ")", function(row)
  71.                
  72.             end)
  73.             dbh:release()
  74.         else
  75.            freeswitch.consoleLog("notice", "OUT 3 by id "  .. id .. "\n");
  76.  
  77.             save_status_out_call(id,hcause);
  78.         end
  79.        
  80.     end
  81.    freeswitch.consoleLog("notice",string.format("\n OUT CALL END4 %s ID %s \n", session1:getState(), id));
  82.    freeswitch.consoleLog("notice", "OUT CALL END1 to " .. phone .. " by id "  .. id .. " WITH hangupCause " .. hcause .. "\n");
  83. else
  84.     hcause = session1:hangupCause();
  85.     save_status_out_call(id,hcause);
  86.  
  87.    freeswitch.consoleLog("notice",string.format("\n OUT CALL END3 %s ID %s \n", session1:getState(), id));
  88.    freeswitch.consoleLog("notice", "OUT CALL END2 to " .. phone .. " by id "  .. id .. " WITH hangupCause " .. hcause .. "\n");
  89. end
  90.  
  91. return;
  92. <<<
  93.  
  94.  
  95. Dump of crash:
  96. >>>
  97. #0  hash (h=h@entry=0x0, k=0x7f45e46a1080) at ./src/include/private/switch_hashtable_private.h:53
  98.         i = <optimized out>
  99. #1  switch_hashtable_insert_destructor (h=h@entry=0x0, k=0x7f45e46a1080, v=v@entry=0x0, flags=flags@entry=(HASHTABLE_FLAG_FREE_KEY | HASHTABLE_DUP_CHECK), destructor=destructor@entry=0x0) at src/switch_hashtable.c:197
  100.         e = <optimized out>
  101.         hashvalue = 0
  102.         index = <optimized out>
  103. #2  0x00007f46d454479b in switch_core_hash_insert_destructor (hash=hash@entry=0x0, key=key@entry=0x7f4646c9fa08 "CoreSession", data=data@entry=0x0, destructor=destructor@entry=0x0) at src/switch_core_hash.c:60
  104. No locals.
  105. #3  0x00007f46d45447e5 in switch_core_hash_insert_locked (hash=0x0, key=0x7f4646c9fa08 "CoreSession", data=0x0, mutex=0x7f45e42ad378) at src/switch_core_hash.c:71
  106. No locals.
  107. #4  0x00007f46d4528899 in switch_channel_set_private (channel=<optimized out>, key=<optimized out>, private_info=<optimized out>) at src/switch_channel.c:1029
  108.         __PRETTY_FUNCTION__ = "switch_channel_set_private"
  109. #5  0x00007f4646c68044 in LUA::Session::destroy (this=0x7f45e430e5b0, err=0x0) at freeswitch_lua.cpp:41
  110.         err = 0x0
  111.         this = 0x7f45e430e5b0
  112. #6  0x00007f4646c6814a in LUA::Session::~Session (this=0x7f45e430e5b0, __in_chrg=<optimized out>) at freeswitch_lua.cpp:63
  113. No locals.
  114. #7  0x00007f4646c68179 in LUA::Session::~Session (this=0x7f45e430e5b0, __in_chrg=<optimized out>) at freeswitch_lua.cpp:64
  115. No locals.
  116. #8  0x00007f4646c6a301 in SWIG_Lua_class_destruct (L=0x7f45e4702470) at mod_lua_wrap.cpp:1396
  117.         usr = <optimized out>
  118.         clss = <optimized out>
  119. #9  0x00007f4646c855c5 in luaD_precall (L=L@entry=0x7f45e4702470, func=<optimized out>, nresults=0) at lua/ldo.c:318
  120.         f = 0x7f4646c6a2c0 <SWIG_Lua_class_destruct(lua_State*)>
  121.         ci = <optimized out>
  122.         n = <optimized out>
  123.         funcr = <optimized out>
  124. #10 0x00007f4646c8588d in luaD_call (L=0x7f45e4702470, func=<optimized out>, nResults=<optimized out>, allowyield=0) at lua/ldo.c:394
  125. No locals.
  126. #11 0x00007f4646c84f1c in luaD_rawrunprotected (L=L@entry=0x7f45e4702470, f=f@entry=0x7f4646c86c70 <dothecall>, ud=ud@entry=0x0) at lua/ldo.c:131
  127.         oldnCcalls = 0
  128.         lj = {previous = 0x0, b = {{__jmpbuf = {139938162025584, -8284848512000002007, 0, 1, 0, 139938162025712, -8286327603693815767, -8286329346556102615}, __mask_was_saved = 0, __saved_mask = {__val = {12422489200, 139939811989869,
  129.                   33, 139938162025584, 0, 4294967224, 33, 139938162025584, 0, 139939812024569, 12422489504, 139939811989869, 139938162025792, 139938162025584, 139938162025792, 32}}}}, status = 0}
  130. #12 0x00007f4646c85ad1 in luaD_pcall (L=L@entry=0x7f45e4702470, func=func@entry=0x7f4646c86c70 <dothecall>, u=u@entry=0x0, old_top=48, ef=ef@entry=0) at lua/ldo.c:595
  131.         status = <optimized out>
  132.         old_ci = 0x7f45e47024f0
  133.         old_allowhooks = 0 '\000'
  134.         old_nny = 1
  135.         old_errfunc = 0
  136. #13 0x00007f4646c86bd9 in GCTM (L=L@entry=0x7f45e4702470, propagateerrors=propagateerrors@entry=1) at lua/lgc.c:817
  137.         status = <optimized out>
  138.         oldah = 1 '\001'
  139.         running = 1
  140.         g = 0x7f45e4702540
  141.         tm = <optimized out>
  142.         v = {value_ = {gc = 0x7f45e4451240, p = 0x7f45e4451240, b = -465235392, f = 0x7f45e4451240, n = 6,9138637004406086e-310}, tt_ = 71}
  143. #14 0x00007f4646c86c5f in callallpendingfinalizers (L=0x7f45e4702470, propagateerrors=propagateerrors@entry=1) at lua/lgc.c:971
  144.         g = 0x7f45e4702540
  145. #15 0x00007f4646c8828b in luaC_fullgc (L=<optimized out>, isemergency=isemergency@entry=0) at lua/lgc.c:1208
  146.         g = <optimized out>
  147.         origkind = <optimized out>
  148. #16 0x00007f4646c81e0f in lua_gc (L=0x7f45e4702470, what=<optimized out>, data=<optimized out>) at lua/lapi.c:1037
  149.         res = 0
  150.         g = 0x7f45e4702540
  151. #17 0x00007f4646c65dd0 in lua_uninit (L=0x7f45e4702470) at mod_lua.cpp:62
  152. No locals.
  153. #18 0x00007f4646c66cea in lua_api_function (cmd=<optimized out>, session=<optimized out>, stream=0x7f46451f5bf0) at mod_lua.cpp:554
  154.         L = <optimized out>
  155.         mycmd = 0x7f45e4198af0 "out_confirm_order.lua"
  156.        error = <optimized out>
  157.         __PRETTY_FUNCTION__ = "switch_status_t lua_api_function(const char*, switch_core_session_t*, switch_stream_handle_t*)"
  158. #19 0x00007f46d4590c0c in switch_api_execute (cmd=cmd@entry=0x7f45e44bddb0 "lua", arg=arg@entry=0x7f45e44bddb4 "out_confirm_order.lua 89992354545 +79992354545 38929 True 'Сарыарка Пр. ' '1Б'", session=session@entry=0x0,
  159.     stream=stream@entry=0x7f46451f5bf0) at src/switch_loadable_module.c:2438
  160.         api = 0x27769a0
  161.         status = <optimized out>
  162.         arg_used = 0x7f45e4a30d50 "out_confirm_order.lua 89992354545 +79992354545 38929 True 'Сарыарка Пр. ' '1Б'"
  163.         cmd_used = 0x7f45e429f920 "lua"
  164.         __PRETTY_FUNCTION__ = "switch_api_execute"
  165.         __func__ = "switch_api_execute"
  166. #20 0x00007f46d4535714 in switch_console_execute (xcmd=<optimized out>, rec=rec@entry=0, istream=istream@entry=0x7f46451f5bf0) at src/switch_console.c:391
  167.         arg = 0x7f45e44bddb4 "out_confirm_order.lua 89992354545 +79992354545 38929 True 'Сарыарка Пр. ' '1Б'"
  168.         alias = 0x7f45e44bddb0 "lua"
  169.         delim = 0x7f46d4634a4e ";;"
  170.         argc = <optimized out>
  171.        argv = {0x7f45e44bddb0 "lua", 0x0 <repeats 102 times>, 0x400 <error: Cannot access memory at address 0x400>, 0xffff80b9bae0a4b1 <error: Cannot access memory at address 0xffff80b9bae0a4b1>,
  172.          0x41 <error: Cannot access memory at address 0x41>, 0x10 <error: Cannot access memory at address 0x10>, 0x40 <error: Cannot access memory at address 0x40>, 0x7f46451f5b50 "", 0x2 <error: Cannot access memory at address 0x2>,
  173.          0x5d00000000 <error: Cannot access memory at address 0x5d00000000>, 0x0, 0x0, 0x770000006e <error: Cannot access memory at address 0x770000006e>, 0x0, 0x7f46451f5b4f "", 0x0, 0x0,
  174.          0x7c <error: Cannot access memory at address 0x7c>, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7f45e4000020 "", 0x400 <error: Cannot access memory at address 0x400>, 0x0}
  175.         x = <optimized out>
  176.         dup = 0x7f45e44bddb0 "lua"
  177.         cmd = 0x7f45e44bddb0 "lua"
  178.         status = SWITCH_STATUS_FALSE
  179.         __func__ = "switch_console_execute"
  180. #21 0x00007f46bef8e3e5 in api_exec (thread=thread@entry=0x0, obj=obj@entry=0x7f46451f6590) at mod_event_socket.c:1504
  181.         acs = 0x7f46451f6590
  182.         stream = {read_function = 0x0, write_function = 0x7f46d4534da0 <switch_console_stream_write>, raw_write_function = 0x7f46d4534d10 <switch_console_stream_raw_write>, data = 0x7f45e40893e0, end = 0x7f45e40893e0, data_size = 1024,
  183.           data_len = 0, alloc_len = 1024, alloc_chunk = 1024, param_event = 0x7f45e4170170}
  184.         reply = <optimized out>
  185.         freply = 0x0
  186.         status = <optimized out>
  187.         __func__ = "api_exec"
  188.         __PRETTY_FUNCTION__ = "api_exec"
  189. #22 0x00007f46bef90ee0 in parse_command (listener=listener@entry=0x7f4640013d88, event=event@entry=0x7f46451f6820, reply=reply@entry=0x7f46451f6850 "", reply_len=512) at mod_event_socket.c:2254
  190.         acs = {api_cmd = 0x7f45e4179774 "lua out_confirm_order.lua 89992354545 +79992354545 38929 True 'Сарыарка Пр. ' '1Б'", arg = 0x0, listener = 0x7f4640013d88, uuid_str = '\000' <repeats 256 times>, bg = 0, ack = 1,
  191.           console_execute = 1, pool = 0x0}
  192.         console_execute = 0x7f45e42fffe0 "true"
  193.         api_cmd = 0x7f45e4179774 "lua out_confirm_order.lua 89992354545 +79992354545 38929 True 'Сарыарка Пр. ' '1Б'"
  194.         arg = <optimized out>
  195.         status = SWITCH_STATUS_SUCCESS
  196.         cmd = 0x7f45e4179770 "api lua out_confirm_order.lua 89992354545 +79992354545 38929 True 'Сарыарка Пр. ' '1Б'"
  197.         unload_cheat = "api bgapi unload mod_event_socket"
  198.         reload_cheat = "api bgapi reload mod_event_socket"
  199. #23 0x00007f46bef92300 in listener_run (thread=<optimized out>, obj=0x7f4640013d88) at mod_event_socket.c:2678
  200.         listener = 0x7f4640013d88
  201.         buf = '\000' <repeats 1023 times>
  202.         len = 1024
  203.         status = <optimized out>
  204.         event = 0x0
  205.         reply = "\000OK accepted", '\000' <repeats 499 times>
  206.         session = 0x0
  207.         channel = 0x0
  208.         revent = 0x7f45e44512b0
  209.         var = <optimized out>
  210.         locked = 1
  211.         __PRETTY_FUNCTION__ = "listener_run"
  212.         __func__ = "listener_run"
  213. #24 0x00007f46d40ca184 in start_thread (arg=0x7f46451f7700) at pthread_create.c:312
  214.         __res = <optimized out>
  215.         pd = 0x7f46451f7700
  216.         now = <optimized out>
  217.         unwind_buf = {cancel_jmp_buf = {{jmp_buf = {139939784128256, 8326459497492052009, 0, 0, 139939784128960, 139939784128256, -8286327601737172951, -8286571820217599959}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0},
  218.             data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
  219.         not_first_call = <optimized out>
  220.         pagesize_m1 = <optimized out>
  221.         sp = <optimized out>
  222.         freesize = <optimized out>
  223.         __PRETTY_FUNCTION__ = "start_thread"
  224. #25 0x00007f46d3df6ffd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
  225. <<<
  226.  
  227. Log of freeswitch:
  228. >>>
  229. 2017-09-13 03:26:13.397245 [NOTICE] switch_cpp.cpp:1328 OUT 2 by id 38929
  230. 2017-09-13 03:26:13.417252 [NOTICE] switch_cpp.cpp:1328
  231.  OUT CALL END4 CS_DESTROY ID 38929
  232. 2017-09-13 03:26:13.417252 [NOTICE] switch_cpp.cpp:1328 OUT CALL END1 to 89992354545 by id 38929 WITH hangupCause SUCCESS
  233. <<<<<<<<<<<<<<<<<MY COMMENT : THIS IS MOMENT OF CRASH>>>>>>>>>>>>>>>
  234. 2017-09-13 03:26:35.732994 [NOTICE] switch_loadable_module.c:227 Adding Dialplan 'enum'
  235. 2017-09-13 03:26:35.733019 [NOTICE] switch_loadable_module.c:269 Adding Application 'enum'
  236. 2017-09-13 03:26:35.733043 [NOTICE] switch_loadable_module.c:315 Adding API Function 'enum'
  237. <<<
  238.  
  239.  
  240. It's crashed right after Lua script is done. This is last console log from Lua:
  241. >>>2017-09-13 03:26:13.417252 [NOTICE] switch_cpp.cpp:1328 OUT CALL END1 to 89992354545 by id 38929 WITH hangupCause SUCCESS
  242. Add then first message from freeswitch that it try to start:
  243. >>>2017-09-13 03:26:35.732994 [NOTICE] switch_loadable_module.c:227 Adding Dialplan 'enum'