payload: {"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/dm/pulls/comments/332903182","pull_request_review_id":299266020,"id":332903182,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMzMjkwMzE4Mg==","diff_hunk":"@@ -11,61 +11,59 @@\n // See the License for the specific language governing permissions and\n // limitations under the License.\n \n-package baseconn\n+package conn\n \n import (\n \t\"database/sql\"\n \n-\t\"go.uber.org/zap\"\n-\n \ttcontext \"github.com/pingcap/dm/pkg/context\"\n \t\"github.com/pingcap/dm/pkg/log\"\n \t\"github.com/pingcap/dm/pkg/retry\"\n \t\"github.com/pingcap/dm/pkg/terror\"\n \t\"github.com/pingcap/dm/pkg/utils\"\n+\n+\t\"go.uber.org/zap\"\n )\n \n // BaseConn wraps a connection to DB\n+// For Syncer and Loader Unit, they both have different amount of connections due to config\n+// Currently we have some types of connections exist\n+// Syncer:","path":"pkg/conn/baseconn.go","position":24,"original_position":24,"commit_id":"5953333db77058290a77396510f023603084574c","original_commit_id":"5953333db77058290a77396510f023603084574c","user":{"login":"csuzhangxc","id":3183039,"node_id":"MDQ6VXNlcjMxODMwMzk=","avatar_url":"https://avatars0.githubusercontent.com/u/3183039?v=4","gravatar_id":"","url":"https://api.github.com/users/csuzhangxc","html_url":"https://github.com/csuzhangxc","followers_url":"https://api.github.com/users/csuzhangxc/followers","following_url":"https://api.github.com/users/csuzhangxc/following{/other_user}","gists_url":"https://api.github.com/users/csuzhangxc/gists{/gist_id}","starred_url":"https://api.github.com/users/csuzhangxc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csuzhangxc/subscriptions","organizations_url":"https://api.github.com/users/csuzhangxc/orgs","repos_url":"https://api.github.com/users/csuzhangxc/repos","events_url":"https://api.github.com/users/csuzhangxc/events{/privacy}","received_events_url":"https://api.github.com/users/csuzhangxc/received_events","type":"User","site_admin":false},"body":"Is `fromDB` should be documented here?","created_at":"2019-10-09T09:03:37Z","updated_at":"2019-10-09T09:06:50Z","html_url":"https://github.com/pingcap/dm/pull/266#discussion_r332903182","pull_request_url":"https://api.github.com/repos/pingcap/dm/pulls/266","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/dm/pulls/comments/332903182"},"html":{"href":"https://github.com/pingcap/dm/pull/266#discussion_r332903182"},"pull_request":{"href":"https://api.github.com/repos/pingcap/dm/pulls/266"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/dm/pulls/266","id":313232883,"node_id":"MDExOlB1bGxSZXF1ZXN0MzEzMjMyODgz","html_url":"https://github.com/pingcap/dm/pull/266","diff_url":"https://github.com/pingcap/dm/pull/266.diff","patch_url":"https://github.com/pingcap/dm/pull/266.patch","issue_url":"https://api.github.com/repos/pingcap/dm/issues/266","number":266,"state":"open","locked":false,"title":"dm-worker: refine conn","user":{"login":"3pointer","id":5906259,"node_id":"MDQ6VXNlcjU5MDYyNTk=","avatar_url":"https://avatars3.githubusercontent.com/u/5906259?v=4","gravatar_id":"","url":"https://api.github.com/users/3pointer","html_url":"https://github.com/3pointer","followers_url":"https://api.github.com/users/3pointer/followers","following_url":"https://api.github.com/users/3pointer/following{/other_user}","gists_url":"https://api.github.com/users/3pointer/gists{/gist_id}","starred_url":"https://api.github.com/users/3pointer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3pointer/subscriptions","organizations_url":"https://api.github.com/users/3pointer/orgs","repos_url":"https://api.github.com/users/3pointer/repos","events_url":"https://api.github.com/users/3pointer/events{/privacy}","received_events_url":"https://api.github.com/users/3pointer/received_events","type":"User","site_admin":false},"body":"<!--\r\nThank you for contributing to DM! Please read MD's [CONTRIBUTING](https://github.com/pingcap/dm/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.\r\n-->\r\n\r\n### What problem does this PR solve? <!--add issue link with summary if exists-->\r\nOptimize Database connections in dm-worker units, after unify DB operations\r\n\r\n### What is changed and how it works?\r\n1. one worker use one individual connection\r\n2. same functional connection comes from one DB object\r\n3. define some package for DB object and connections, all DB object generate in `conn.DBProvider.Apply`\r\n4. split upstream DB connection and downstream(worker) DB connection, because they have totally different DB operations, it's better use `*sql.DB` in upstream, and use individual connection for each worker in downstream.\r\n\r\n### Check List <!--REMOVE the items that are not applicable-->\r\n\r\nTests <!-- At least one of them must be included. -->\r\n\r\n - Unit test\r\n - Integration test\r\n - Manual test (add detailed scripts or steps below)\r\n - No code\r\n\r\nCode changes\r\n\r\n - Has exported function/method change\r\n - Has exported variable/fields change\r\n - Has interface methods change\r\n - Has persistent data change\r\n\r\nSide effects\r\n\r\n - Possible performance regression\r\n - Increased code complexity\r\n - Breaking backward compatibility\r\n\r\nRelated changes\r\n\r\n - Need to cherry-pick to the release branch\r\n - Need to update the documentation\r\n - Need to update the `dm/dm-ansible`\r\n - Need to be included in the release note\r\n","created_at":"2019-09-02T11:50:36Z","updated_at":"2019-10-09T09:06:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abe290eff4455773e94d8cc3a782e3cd6435361a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1195099890,"node_id":"MDU6TGFiZWwxMTk1MDk5ODkw","url":"https://api.github.com/repos/pingcap/dm/labels/priority/normal","name":"priority/normal","color":"FF7F50","default":false},{"id":1540156461,"node_id":"MDU6TGFiZWwxNTQwMTU2NDYx","url":"https://api.github.com/repos/pingcap/dm/labels/should-cherry-pick-1.0","name":"should-cherry-pick-1.0","color":"d93f0b","default":false},{"id":1196629689,"node_id":"MDU6TGFiZWwxMTk2NjI5Njg5","url":"https://api.github.com/repos/pingcap/dm/labels/status/PTAL","name":"status/PTAL","color":"2cbe4e","default":false},{"id":1196631541,"node_id":"MDU6TGFiZWwxMTk2NjMxNTQx","url":"https://api.github.com/repos/pingcap/dm/labels/type/enhancement","name":"type/enhancement","color":"f2dc8c","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/dm/pulls/266/commits","review_comments_url":"https://api.github.com/repos/pingcap/dm/pulls/266/comments","review_comment_url":"https://api.github.com/repos/pingcap/dm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/dm/issues/266/comments","statuses_url":"https://api.github.com/repos/pingcap/dm/statuses/5953333db77058290a77396510f023603084574c","head":{"label":"3pointer:refine_conn","ref":"refine_conn","sha":"5953333db77058290a77396510f023603084574c","user":{"login":"3pointer","id":5906259,"node_id":"MDQ6VXNlcjU5MDYyNTk=","avatar_url":"https://avatars3.githubusercontent.com/u/5906259?v=4","gravatar_id":"","url":"https://api.github.com/users/3pointer","html_url":"https://github.com/3pointer","followers_url":"https://api.github.com/users/3pointer/followers","following_url":"https://api.github.com/users/3pointer/following{/other_user}","gists_url":"https://api.github.com/users/3pointer/gists{/gist_id}","starred_url":"https://api.github.com/users/3pointer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3pointer/subscriptions","organizations_url":"https://api.github.com/users/3pointer/orgs","repos_url":"https://api.github.com/users/3pointer/repos","events_url":"https://api.github.com/users/3pointer/events{/privacy}","received_events_url":"https://api.github.com/users/3pointer/received_events","type":"User","site_admin":false},"repo":{"id":196565273,"node_id":"MDEwOlJlcG9zaXRvcnkxOTY1NjUyNzM=","name":"dm","full_name":"3pointer/dm","private":false,"owner":{"login":"3pointer","id":5906259,"node_id":"MDQ6VXNlcjU5MDYyNTk=","avatar_url":"https://avatars3.githubusercontent.com/u/5906259?v=4","gravatar_id":"","url":"https://api.github.com/users/3pointer","html_url":"https://github.com/3pointer","followers_url":"https://api.github.com/users/3pointer/followers","following_url":"https://api.github.com/users/3pointer/following{/other_user}","gists_url":"https://api.github.com/users/3pointer/gists{/gist_id}","starred_url":"https://api.github.com/users/3pointer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3pointer/subscriptions","organizations_url":"https://api.github.com/users/3pointer/orgs","repos_url":"https://api.github.com/users/3pointer/repos","events_url":"https://api.github.com/users/3pointer/events{/privacy}","received_events_url":"https://api.github.com/users/3pointer/received_events","type":"User","site_admin":false},"html_url":"https://github.com/3pointer/dm","description":"Data Migration Platform","fork":true,"url":"https://api.github.com/repos/3pointer/dm","forks_url":"https://api.github.com/repos/3pointer/dm/forks","keys_url":"https://api.github.com/repos/3pointer/dm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/3pointer/dm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/3pointer/dm/teams","hooks_url":"https://api.github.com/repos/3pointer/dm/hooks","issue_events_url":"https://api.github.com/repos/3pointer/dm/issues/events{/number}","events_url":"https://api.github.com/repos/3pointer/dm/events","assignees_url":"https://api.github.com/repos/3pointer/dm/assignees{/user}","branches_url":"https://api.github.com/repos/3pointer/dm/branches{/branch}","tags_url":"https://api.github.com/repos/3pointer/dm/tags","blobs_url":"https://api.github.com/repos/3pointer/dm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/3pointer/dm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/3pointer/dm/git/refs{/sha}","trees_url":"https://api.github.com/repos/3pointer/dm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/3pointer/dm/statuses/{sha}","languages_url":"https://api.github.com/repos/3pointer/dm/languages","stargazers_url":"https://api.github.com/repos/3pointer/dm/stargazers","contributors_url":"https://api.github.com/repos/3pointer/dm/contributors","subscribers_url":"https://api.github.com/repos/3pointer/dm/subscribers","subscription_url":"https://api.github.com/repos/3pointer/dm/subscription","commits_url":"https://api.github.com/repos/3pointer/dm/commits{/sha}","git_commits_url":"https://api.github.com/repos/3pointer/dm/git/commits{/sha}","comments_url":"https://api.github.com/repos/3pointer/dm/comments{/number}","issue_comment_url":"https://api.github.com/repos/3pointer/dm/issues/comments{/number}","contents_url":"https://api.github.com/repos/3pointer/dm/contents/{+path}","compare_url":"https://api.github.com/repos/3pointer/dm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/3pointer/dm/merges","archive_url":"https://api.github.com/repos/3pointer/dm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/3pointer/dm/downloads","issues_url":"https://api.github.com/repos/3pointer/dm/issues{/number}","pulls_url":"https://api.github.com/repos/3pointer/dm/pulls{/number}","milestones_url":"https://api.github.com/repos/3pointer/dm/milestones{/number}","notifications_url":"https://api.github.com/repos/3pointer/dm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/3pointer/dm/labels{/name}","releases_url":"https://api.github.com/repos/3pointer/dm/releases{/id}","deployments_url":"https://api.github.com/repos/3pointer/dm/deployments","created_at":"2019-07-12T11:09:20Z","updated_at":"2019-07-19T10:47:00Z","pushed_at":"2019-10-08T05:03:02Z","git_url":"git://github.com/3pointer/dm.git","ssh_url":"git@github.com:3pointer/dm.git","clone_url":"https://github.com/3pointer/dm.git","svn_url":"https://github.com/3pointer/dm","homepage":"","size":7436,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"ce5e03815c28789877c6941e98da2161a2dd1dbb","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":165957180,"node_id":"MDEwOlJlcG9zaXRvcnkxNjU5NTcxODA=","name":"dm","full_name":"pingcap/dm","private":false,"owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pingcap/dm","description":"Data Migration Platform","fork":false,"url":"https://api.github.com/repos/pingcap/dm","forks_url":"https://api.github.com/repos/pingcap/dm/forks","keys_url":"https://api.github.com/repos/pingcap/dm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/dm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/dm/teams","hooks_url":"https://api.github.com/repos/pingcap/dm/hooks","issue_events_url":"https://api.github.com/repos/pingcap/dm/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/dm/events","assignees_url":"https://api.github.com/repos/pingcap/dm/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/dm/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/dm/tags","blobs_url":"https://api.github.com/repos/pingcap/dm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/dm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/dm/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/dm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/dm/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/dm/languages","stargazers_url":"https://api.github.com/repos/pingcap/dm/stargazers","contributors_url":"https://api.github.com/repos/pingcap/dm/contributors","subscribers_url":"https://api.github.com/repos/pingcap/dm/subscribers","subscription_url":"https://api.github.com/repos/pingcap/dm/subscription","commits_url":"https://api.github.com/repos/pingcap/dm/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/dm/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/dm/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/dm/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/dm/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/dm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/dm/merges","archive_url":"https://api.github.com/repos/pingcap/dm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/dm/downloads","issues_url":"https://api.github.com/repos/pingcap/dm/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/dm/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/dm/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/dm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/dm/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/dm/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/dm/deployments","created_at":"2019-01-16T02:13:45Z","updated_at":"2019-10-09T03:37:58Z","pushed_at":"2019-10-09T05:34:04Z","git_url":"git://github.com/pingcap/dm.git","ssh_url":"git@github.com:pingcap/dm.git","clone_url":"https://github.com/pingcap/dm.git","svn_url":"https://github.com/pingcap/dm","homepage":"","size":7376,"stargazers_count":262,"watchers_count":262,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":82,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":51,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":82,"open_issues":51,"watchers":262,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/dm/pulls/266"},"html":{"href":"https://github.com/pingcap/dm/pull/266"},"issue":{"href":"https://api.github.com/repos/pingcap/dm/issues/266"},"comments":{"href":"https://api.github.com/repos/pingcap/dm/issues/266/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/dm/pulls/266/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/dm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/dm/pulls/266/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/dm/statuses/5953333db77058290a77396510f023603084574c"}},"author_association":"CONTRIBUTOR"}}
other: {"actor":{"display_login":"csuzhangxc"}}