{"action":"created","comment":{"url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/comments/43878529","id":43878529,"diff_hunk":"@@ -133,8 +138,9 @@ def emit_record(tag, record)\n \n     def query(query, con = nil)\n       begin\n-        mysql = get_connection if con.nil?\n-        return mysql.query(query)\n+        con = con.nil? ? get_connection : con\n+        con = con.ping ? con : get_connection","path":"lib/fluent/plugin/in_mysql_replicator.rb","position":50,"original_position":50,"commit_id":"0ff61e7edfc95a4b316146dbd77b4101d2ce09b0","original_commit_id":"0ff61e7edfc95a4b316146dbd77b4101d2ce09b0","user":{"login":"toyama0919","id":734403,"avatar_url":"https://avatars.githubusercontent.com/u/734403?v=3","gravatar_id":"","url":"https://api.github.com/users/toyama0919","html_url":"https://github.com/toyama0919","followers_url":"https://api.github.com/users/toyama0919/followers","following_url":"https://api.github.com/users/toyama0919/following{/other_user}","gists_url":"https://api.github.com/users/toyama0919/gists{/gist_id}","starred_url":"https://api.github.com/users/toyama0919/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toyama0919/subscriptions","organizations_url":"https://api.github.com/users/toyama0919/orgs","repos_url":"https://api.github.com/users/toyama0919/repos","events_url":"https://api.github.com/users/toyama0919/events{/privacy}","received_events_url":"https://api.github.com/users/toyama0919/received_events","type":"User","site_admin":false},"body":">Is this the solution to reconnect on lost connection in the loop?\r\nYes.\r\nIf Mysql server is down,  prepared_con.query is Error and shutdown.\r\nAnd Not reconnect.(re-use connection) \r\n ","created_at":"2015-11-04T13:16:58Z","updated_at":"2015-11-04T13:16:58Z","html_url":"https://github.com/y-ken/fluent-plugin-mysql-replicator/pull/13#discussion_r43878529","pull_request_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/comments/43878529"},"html":{"href":"https://github.com/y-ken/fluent-plugin-mysql-replicator/pull/13#discussion_r43878529"},"pull_request":{"href":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/13","id":49675648,"html_url":"https://github.com/y-ken/fluent-plugin-mysql-replicator/pull/13","diff_url":"https://github.com/y-ken/fluent-plugin-mysql-replicator/pull/13.diff","patch_url":"https://github.com/y-ken/fluent-plugin-mysql-replicator/pull/13.patch","issue_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/issues/13","number":13,"state":"open","locked":false,"title":"fix, use the connection effectively without being connected every time.","user":{"login":"toyama0919","id":734403,"avatar_url":"https://avatars.githubusercontent.com/u/734403?v=3","gravatar_id":"","url":"https://api.github.com/users/toyama0919","html_url":"https://github.com/toyama0919","followers_url":"https://api.github.com/users/toyama0919/followers","following_url":"https://api.github.com/users/toyama0919/following{/other_user}","gists_url":"https://api.github.com/users/toyama0919/gists{/gist_id}","starred_url":"https://api.github.com/users/toyama0919/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toyama0919/subscriptions","organizations_url":"https://api.github.com/users/toyama0919/orgs","repos_url":"https://api.github.com/users/toyama0919/repos","events_url":"https://api.github.com/users/toyama0919/events{/privacy}","received_events_url":"https://api.github.com/users/toyama0919/received_events","type":"User","site_admin":false},"body":"Hello.\r\n\r\nMysqlReplicatorInput connected mysql for every loop.\r\nThis increase connection with every mysql connected.\r\nIt close connection every loop.\r\n\r\nThis merit is below.\r\n\r\n1. Not increase mysql connection.\r\n2. Even if database server failover and IPaddress changes, We can be reconnected.(Example Amazon RDS.)\r\n\r\nthanks.\r\n","created_at":"2015-11-04T11:12:48Z","updated_at":"2015-11-04T13:16:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8cb4d374ef903a8ee541185b0106cb805152abae","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/13/commits","review_comments_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/13/comments","review_comment_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/issues/13/comments","statuses_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/statuses/0ff61e7edfc95a4b316146dbd77b4101d2ce09b0","head":{"label":"toyama0919:master","ref":"master","sha":"0ff61e7edfc95a4b316146dbd77b4101d2ce09b0","user":{"login":"toyama0919","id":734403,"avatar_url":"https://avatars.githubusercontent.com/u/734403?v=3","gravatar_id":"","url":"https://api.github.com/users/toyama0919","html_url":"https://github.com/toyama0919","followers_url":"https://api.github.com/users/toyama0919/followers","following_url":"https://api.github.com/users/toyama0919/following{/other_user}","gists_url":"https://api.github.com/users/toyama0919/gists{/gist_id}","starred_url":"https://api.github.com/users/toyama0919/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toyama0919/subscriptions","organizations_url":"https://api.github.com/users/toyama0919/orgs","repos_url":"https://api.github.com/users/toyama0919/repos","events_url":"https://api.github.com/users/toyama0919/events{/privacy}","received_events_url":"https://api.github.com/users/toyama0919/received_events","type":"User","site_admin":false},"repo":{"id":42427423,"name":"fluent-plugin-mysql-replicator","full_name":"toyama0919/fluent-plugin-mysql-replicator","owner":{"login":"toyama0919","id":734403,"avatar_url":"https://avatars.githubusercontent.com/u/734403?v=3","gravatar_id":"","url":"https://api.github.com/users/toyama0919","html_url":"https://github.com/toyama0919","followers_url":"https://api.github.com/users/toyama0919/followers","following_url":"https://api.github.com/users/toyama0919/following{/other_user}","gists_url":"https://api.github.com/users/toyama0919/gists{/gist_id}","starred_url":"https://api.github.com/users/toyama0919/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toyama0919/subscriptions","organizations_url":"https://api.github.com/users/toyama0919/orgs","repos_url":"https://api.github.com/users/toyama0919/repos","events_url":"https://api.github.com/users/toyama0919/events{/privacy}","received_events_url":"https://api.github.com/users/toyama0919/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/toyama0919/fluent-plugin-mysql-replicator","description":"Fluentd input plugin to track insert/update/delete event from MySQL databases.","fork":true,"url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator","forks_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/forks","keys_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/teams","hooks_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/hooks","issue_events_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/issues/events{/number}","events_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/events","assignees_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/assignees{/user}","branches_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/branches{/branch}","tags_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/tags","blobs_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/git/refs{/sha}","trees_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/statuses/{sha}","languages_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/languages","stargazers_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/stargazers","contributors_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/contributors","subscribers_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/subscribers","subscription_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/subscription","commits_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/commits{/sha}","git_commits_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/git/commits{/sha}","comments_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/comments{/number}","issue_comment_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/issues/comments{/number}","contents_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/contents/{+path}","compare_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/merges","archive_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/downloads","issues_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/issues{/number}","pulls_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/pulls{/number}","milestones_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/milestones{/number}","notifications_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/labels{/name}","releases_url":"https://api.github.com/repos/toyama0919/fluent-plugin-mysql-replicator/releases{/id}","created_at":"2015-09-14T04:34:41Z","updated_at":"2015-09-14T04:34:41Z","pushed_at":"2015-11-04T10:42:49Z","git_url":"git://github.com/toyama0919/fluent-plugin-mysql-replicator.git","ssh_url":"git@github.com:toyama0919/fluent-plugin-mysql-replicator.git","clone_url":"https://github.com/toyama0919/fluent-plugin-mysql-replicator.git","svn_url":"https://github.com/toyama0919/fluent-plugin-mysql-replicator","homepage":"http://rubygems.org/gems/fluent-plugin-mysql-replicator","size":158,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"y-ken:master","ref":"master","sha":"f7871e8d970f592f081d782806505cc27d3f0405","user":{"login":"y-ken","id":1734549,"avatar_url":"https://avatars.githubusercontent.com/u/1734549?v=3","gravatar_id":"","url":"https://api.github.com/users/y-ken","html_url":"https://github.com/y-ken","followers_url":"https://api.github.com/users/y-ken/followers","following_url":"https://api.github.com/users/y-ken/following{/other_user}","gists_url":"https://api.github.com/users/y-ken/gists{/gist_id}","starred_url":"https://api.github.com/users/y-ken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/y-ken/subscriptions","organizations_url":"https://api.github.com/users/y-ken/orgs","repos_url":"https://api.github.com/users/y-ken/repos","events_url":"https://api.github.com/users/y-ken/events{/privacy}","received_events_url":"https://api.github.com/users/y-ken/received_events","type":"User","site_admin":false},"repo":{"id":14682071,"name":"fluent-plugin-mysql-replicator","full_name":"y-ken/fluent-plugin-mysql-replicator","owner":{"login":"y-ken","id":1734549,"avatar_url":"https://avatars.githubusercontent.com/u/1734549?v=3","gravatar_id":"","url":"https://api.github.com/users/y-ken","html_url":"https://github.com/y-ken","followers_url":"https://api.github.com/users/y-ken/followers","following_url":"https://api.github.com/users/y-ken/following{/other_user}","gists_url":"https://api.github.com/users/y-ken/gists{/gist_id}","starred_url":"https://api.github.com/users/y-ken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/y-ken/subscriptions","organizations_url":"https://api.github.com/users/y-ken/orgs","repos_url":"https://api.github.com/users/y-ken/repos","events_url":"https://api.github.com/users/y-ken/events{/privacy}","received_events_url":"https://api.github.com/users/y-ken/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/y-ken/fluent-plugin-mysql-replicator","description":"Fluentd input plugin to track insert/update/delete event from MySQL databases.","fork":false,"url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator","forks_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/forks","keys_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/teams","hooks_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/hooks","issue_events_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/issues/events{/number}","events_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/events","assignees_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/assignees{/user}","branches_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/branches{/branch}","tags_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/tags","blobs_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/git/refs{/sha}","trees_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/statuses/{sha}","languages_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/languages","stargazers_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/stargazers","contributors_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/contributors","subscribers_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/subscribers","subscription_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/subscription","commits_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/commits{/sha}","git_commits_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/git/commits{/sha}","comments_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/comments{/number}","issue_comment_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/issues/comments{/number}","contents_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/contents/{+path}","compare_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/merges","archive_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/downloads","issues_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/issues{/number}","pulls_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls{/number}","milestones_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/milestones{/number}","notifications_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/labels{/name}","releases_url":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/releases{/id}","created_at":"2013-11-25T09:58:30Z","updated_at":"2015-10-22T02:00:37Z","pushed_at":"2015-11-04T11:12:48Z","git_url":"git://github.com/y-ken/fluent-plugin-mysql-replicator.git","ssh_url":"git@github.com:y-ken/fluent-plugin-mysql-replicator.git","clone_url":"https://github.com/y-ken/fluent-plugin-mysql-replicator.git","svn_url":"https://github.com/y-ken/fluent-plugin-mysql-replicator","homepage":"http://rubygems.org/gems/fluent-plugin-mysql-replicator","size":576,"stargazers_count":20,"watchers_count":20,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":4,"forks":12,"open_issues":4,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/13"},"html":{"href":"https://github.com/y-ken/fluent-plugin-mysql-replicator/pull/13"},"issue":{"href":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/issues/13"},"comments":{"href":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/y-ken/fluent-plugin-mysql-replicator/statuses/0ff61e7edfc95a4b316146dbd77b4101d2ce09b0"}}}}