不要忽略任何一個錯誤提示,更要找到原因linked websocket controlling loop crashed with reason: kille...

 

開發程序的時候,好幾次都看到後臺打出下面的錯誤日誌。 但一直重現不了。

 

=ERROR REPORT==== 20-Feb-2013::14:07:56 ===

        module: misultin_websocket

        line: 243

linked websocket controlling loop crashed with reason: killed

 

 

直到昨天再測試程序時,突然發現頁面報出close提示,我以爲是timeout關閉的,查看了一下時間戳和日誌,發現不是超市引起。但正好看到上面錯誤 log。也沒發現什麼直接關係。

這時候我留意到ws_session(用來存儲用戶與ws之間的關係)中的記錄也沒有清除,這就證明是進程意外退出引起的。

反覆實驗發現,不論建立了多少個websocket連接。只要執行兩次http請求所有的連接都會報出close錯誤。同時日誌記錄linked websocket controlling loop crashed with reason: killed。這下重現了此錯誤。回想了一下,以前的token超時,丟失用戶消息都很可能與此有着間接的關係。

這個問題比較嚴重,花了幾個小時。一步步跟蹤代碼才發現。 每次http請求都會執行下面兩句話。

 63             Result = code:purge(Module1),  

 65             case code:load_binary(Module1, File, Bin) of

 

OK,找到問題了

purge(Module) -> boolean()

Types:

Module = module()

 

 

Purges the code for Module, that is, removes code marked as old. If some processes still linger in the old code, these processes are killed before the code is removed.

            Returns true if successful and any process needed to be killed, otherwise false.

 

 

load_binary(Module, Filename, Binary) ->
               {module, Module} | {error, What}

Types:

Module = module()
Filename = loaded_filename()
Binary = binary()
What = badarg | load_error_rsn()
loaded_filename() = (Filename :: file:filename())
                  | loaded_ret_atoms()
loaded_ret_atoms() = cover_compiled | preloaded

 

 

This function can be used to load object code on remote Erlang nodes. The argument Binary must contain object code for ModuleFilename is only used by the code server to keep a record of from which file the object code for Module comes. Accordingly, Filename is not opened and read by the code server.

Returns {module, Module} if successful, or {error, sticky_directory} if the object code resides in a sticky directory, or {error, badarg} if any argument is invalid. Also if the loading fails, an error tuple is returned. See erlang:load_module/2 for possible values of What.

 

 

發佈了27 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章