最近組內升級了PHP7,某個接口偶發502,看了下php的錯誤日志如下:
igbinary_unserialize_ref: invalid reference 4034265088 >= 0 in xxx.php on line 426 Memcached::getMulti(): could not unserialize value with igbinary in xxx.php on line 426
組內的同事查了下,igbinary 的源碼,拋出異常的代碼為:
if (n >= igsd->references_count) { zend_error(E_WARNING, "igbinary_unserialize_ref: invalid reference %zu >= %zu", (int) n, (int)igsd->references_count); return 1; }
即是 igbinary 的引用計數出現了問題,導致了 segment fault, 進而導致出現 502,應該是 igbinary 這個擴展,對於php 7.0的兼容性問題
進一步去看了 igbinary 近期的更新日志,發現,居然修復了這個bug,如下:
這個是bug相關的連接:https://github.com/php-memcached-dev/php-memcached/issues/326
這個是修復的詳情: https://github.com/igbinary/igbinary/commit/b090b05ca301b64f4bebe2df8c79528c13c7176e
至此,問題已經搞清楚了,解決這個問題有兩種解決方案:
(1)在用到 igbinary 代碼中不要使用引用
(2)更新 igbinary 的擴展
當然更推薦第二種方式。