{"action":"created","issue":{"url":"https://api.github.com/repos/bullsoft/php-binlog/issues/5","labels_url":"https://api.github.com/repos/bullsoft/php-binlog/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/bullsoft/php-binlog/issues/5/comments","events_url":"https://api.github.com/repos/bullsoft/php-binlog/issues/5/events","html_url":"https://github.com/bullsoft/php-binlog/issues/5","id":96844246,"number":5,"title":"binlog_wait_for_next_event sometimes hangs ","user":{"login":"ghola","id":932205,"avatar_url":"https://avatars.githubusercontent.com/u/932205?v=3","gravatar_id":"","url":"https://api.github.com/users/ghola","html_url":"https://github.com/ghola","followers_url":"https://api.github.com/users/ghola/followers","following_url":"https://api.github.com/users/ghola/following{/other_user}","gists_url":"https://api.github.com/users/ghola/gists{/gist_id}","starred_url":"https://api.github.com/users/ghola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghola/subscriptions","organizations_url":"https://api.github.com/users/ghola/orgs","repos_url":"https://api.github.com/users/ghola/repos","events_url":"https://api.github.com/users/ghola/events{/privacy}","received_events_url":"https://api.github.com/users/ghola/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-23T15:46:00Z","updated_at":"2015-07-23T20:58:22Z","closed_at":null,"body":"The binlog extension does not provide the column names for the data (it only offers numerical keys) so i need to implement this mapping myself. To do so i need to read information from the mysql schema and for that i use a database connection (pdo_mysql).\r\n\r\nThe problem that i encounter sometimes is that when another mysql connection is present, the binlog_wait_for_next_event function just hangs. I noticed that when it hangs, my script has two open connections to mysql. Example result of `ss -tp | grep php`:\r\n<pre>\r\nESTAB      1014   0               127.0.0.1:41755            127.0.0.1:mysql    users:((\"php\",29165,12))\r\nESTAB      0      0               127.0.0.1:41754            127.0.0.1:mysql    users:((\"php\",29165,7))\r\n</pre>\r\n\r\nWhen it does not hang, the script has only one connection to mysql (even though i'm 100% sure that PDO is connected since i run a query at the beginning of the script):\r\n<pre>\r\nESTAB      0      0               127.0.0.1:41730            127.0.0.1:mysql    users:((\"php\",29137,7))\r\n</pre>\r\n\r\nWhen i completely eliminate the other mysql connection from my script, it never hangs.\r\n\r\nDo you have any recommendation on how to aleviate this problem?"},"comment":{"url":"https://api.github.com/repos/bullsoft/php-binlog/issues/comments/124238430","html_url":"https://github.com/bullsoft/php-binlog/issues/5#issuecomment-124238430","issue_url":"https://api.github.com/repos/bullsoft/php-binlog/issues/5","id":124238430,"user":{"login":"ghola","id":932205,"avatar_url":"https://avatars.githubusercontent.com/u/932205?v=3","gravatar_id":"","url":"https://api.github.com/users/ghola","html_url":"https://github.com/ghola","followers_url":"https://api.github.com/users/ghola/followers","following_url":"https://api.github.com/users/ghola/following{/other_user}","gists_url":"https://api.github.com/users/ghola/gists{/gist_id}","starred_url":"https://api.github.com/users/ghola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghola/subscriptions","organizations_url":"https://api.github.com/users/ghola/orgs","repos_url":"https://api.github.com/users/ghola/repos","events_url":"https://api.github.com/users/ghola/events{/privacy}","received_events_url":"https://api.github.com/users/ghola/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T20:58:22Z","updated_at":"2015-07-23T20:58:22Z","body":"Simple recipe for producing hangs. Use the following php script:\r\n```\r\n$handle = binlog_connect(\"mysql://root:123@127.0.0.1:3306\");\r\nbinlog_set_position($handle, 0);\r\n$event = binlog_wait_for_next_event($handle);\r\nexit();\r\n```\r\n\r\nCreate a bash script with the following contents:\r\n```\r\nwhile :\r\n    do\r\n       php test.php\r\n       ((i++))\r\n       echo $i\r\ndone\r\n```\r\n\r\nRun the bash script for a while. At some point the numbering will stop which means the script is hung. As you can see, the hanging appears only when using binlog_set_position. You can try with any other position instead of 0.\r\n\r\nUsing this setup, from time to time you might be lucky to also see the following error:\r\n```\r\nterminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<asio::system_error> >'\r\n  what():  write: Broken pipe\r\n```"}}