{"action":"created","issue":{"url":"https://api.github.com/repos/ManageIQ/manageiq-schema/issues/201","repository_url":"https://api.github.com/repos/ManageIQ/manageiq-schema","labels_url":"https://api.github.com/repos/ManageIQ/manageiq-schema/issues/201/labels{/name}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq-schema/issues/201/comments","events_url":"https://api.github.com/repos/ManageIQ/manageiq-schema/issues/201/events","html_url":"https://github.com/ManageIQ/manageiq-schema/pull/201","id":323304198,"number":201,"title":"Optimize migration which creates task for each job","user":{"login":"yrudman","id":6556758,"avatar_url":"https://avatars0.githubusercontent.com/u/6556758?v=4","gravatar_id":"","url":"https://api.github.com/users/yrudman","html_url":"https://github.com/yrudman","followers_url":"https://api.github.com/users/yrudman/followers","following_url":"https://api.github.com/users/yrudman/following{/other_user}","gists_url":"https://api.github.com/users/yrudman/gists{/gist_id}","starred_url":"https://api.github.com/users/yrudman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yrudman/subscriptions","organizations_url":"https://api.github.com/users/yrudman/orgs","repos_url":"https://api.github.com/users/yrudman/repos","events_url":"https://api.github.com/users/yrudman/events{/privacy}","received_events_url":"https://api.github.com/users/yrudman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"Fryguy","id":52120,"avatar_url":"https://avatars3.githubusercontent.com/u/52120?v=4","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false},"assignees":[{"login":"Fryguy","id":52120,"avatar_url":"https://avatars3.githubusercontent.com/u/52120?v=4","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-05-15T17:02:18Z","updated_at":"2018-05-22T14:45:16Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq-schema/pulls/201","html_url":"https://github.com/ManageIQ/manageiq-schema/pull/201","diff_url":"https://github.com/ManageIQ/manageiq-schema/pull/201.diff","patch_url":"https://github.com/ManageIQ/manageiq-schema/pull/201.patch"},"body":"There are several long running migrations observed on client's DB (`Job.count` around 1.3 millions)  : \r\n`CreateTaskForEachJobAndTransferAttributes`        - 4863 seconds\r\n`CopyAgentIdToMiqServerIdInJobsTable`                  -  168 seconds\r\n`CopyServerIdFromJobsToMiqTask`                           - 1645\r\n\r\nIn UI (Task management screen) we show only tasks for the last 6 days, so there is no need to do anything with jobs/task older than 7 days.\r\n\r\nThis PR:  changed exiting `CreateTaskForEachJobAndTransferAttributes` by:\r\n- deleting finished `Job` older than 7 days first and creating task for each job after that.\r\n- deleting finished `MiqTask` older than 7 days. This change will no speed-up migration, it is just clen-up and done t be consistent with `Job` deletion. \r\n\r\non the same client's DB deleting old records from `Job` table took 16 seconds:\r\n```\r\n>> Job.where(\"updated_on < ?\", t).where(\"state = 'finished'\").delete_all\r\n  SQL (16330.1ms)  DELETE FROM \"jobs\" WHERE (updated_on < '2018-04-14 16:05:23.679929') AND (state = 'finished')\r\n=> 1232220\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq-schema/issues/comments/391017487","html_url":"https://github.com/ManageIQ/manageiq-schema/pull/201#issuecomment-391017487","issue_url":"https://api.github.com/repos/ManageIQ/manageiq-schema/issues/201","id":391017487,"user":{"login":"miq-bot","id":7806257,"avatar_url":"https://avatars1.githubusercontent.com/u/7806257?v=4","gravatar_id":"","url":"https://api.github.com/users/miq-bot","html_url":"https://github.com/miq-bot","followers_url":"https://api.github.com/users/miq-bot/followers","following_url":"https://api.github.com/users/miq-bot/following{/other_user}","gists_url":"https://api.github.com/users/miq-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/miq-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miq-bot/subscriptions","organizations_url":"https://api.github.com/users/miq-bot/orgs","repos_url":"https://api.github.com/users/miq-bot/repos","events_url":"https://api.github.com/users/miq-bot/events{/privacy}","received_events_url":"https://api.github.com/users/miq-bot/received_events","type":"User","site_admin":false},"created_at":"2018-05-22T14:45:16Z","updated_at":"2018-05-22T14:45:16Z","author_association":"MEMBER","body":"<rubocop />Checked commits https://github.com/yrudman/manageiq-schema/compare/ae01ec8eb89b4768eed58b420eb31982c05ff2a3~...191be8757a5dba7b0193fd0ce76768a1fbf4918a with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0\n2 files checked, 0 offenses detected\nEverything looks fine. :cookie:\n"}}
{"actor":{"display_login":"miq-bot"}}