{"action":"created","issue":{"url":"https://api.github.com/repos/cockroachdb/cockroach/issues/12501","repository_url":"https://api.github.com/repos/cockroachdb/cockroach","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/12501/labels{/name}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/12501/comments","events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/12501/events","html_url":"https://github.com/cockroachdb/cockroach/pull/12501","id":196722008,"number":12501,"title":"sql: add drain mode to LeaseManager","user":{"login":"asubiotto","id":10560359,"avatar_url":"https://avatars.githubusercontent.com/u/10560359?v=3","gravatar_id":"","url":"https://api.github.com/users/asubiotto","html_url":"https://github.com/asubiotto","followers_url":"https://api.github.com/users/asubiotto/followers","following_url":"https://api.github.com/users/asubiotto/following{/other_user}","gists_url":"https://api.github.com/users/asubiotto/gists{/gist_id}","starred_url":"https://api.github.com/users/asubiotto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asubiotto/subscriptions","organizations_url":"https://api.github.com/users/asubiotto/orgs","repos_url":"https://api.github.com/users/asubiotto/repos","events_url":"https://api.github.com/users/asubiotto/events{/privacy}","received_events_url":"https://api.github.com/users/asubiotto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-20T16:46:52Z","updated_at":"2016-12-20T17:04:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/12501","html_url":"https://github.com/cockroachdb/cockroach/pull/12501","diff_url":"https://github.com/cockroachdb/cockroach/pull/12501.diff","patch_url":"https://github.com/cockroachdb/cockroach/pull/12501.patch"},"body":"Fixes #9493 by deleting all unreferenced table descriptor leases on\r\nclean shutdown. Leases whose refcount drops to 0 while in this drain\r\nmode are also deleted.\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/cockroachdb/cockroach/12501)\n<!-- Reviewable:end -->\n"},"comment":{"url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments/268298563","html_url":"https://github.com/cockroachdb/cockroach/pull/12501#issuecomment-268298563","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/12501","id":268298563,"user":{"login":"tamird","id":1535036,"avatar_url":"https://avatars.githubusercontent.com/u/1535036?v=3","gravatar_id":"","url":"https://api.github.com/users/tamird","html_url":"https://github.com/tamird","followers_url":"https://api.github.com/users/tamird/followers","following_url":"https://api.github.com/users/tamird/following{/other_user}","gists_url":"https://api.github.com/users/tamird/gists{/gist_id}","starred_url":"https://api.github.com/users/tamird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamird/subscriptions","organizations_url":"https://api.github.com/users/tamird/orgs","repos_url":"https://api.github.com/users/tamird/repos","events_url":"https://api.github.com/users/tamird/events{/privacy}","received_events_url":"https://api.github.com/users/tamird/received_events","type":"User","site_admin":false},"created_at":"2016-12-20T17:04:39Z","updated_at":"2016-12-20T17:04:39Z","body":"\n\n\n\nReviewed 3 of 4 files at r1.\nReview status: 3 of 4 files reviewed at latest revision, 2 unresolved discussions.\n\n---\n\n*[pkg/server/server.go, line 755 at r1](https://reviewable.io:443/reviews/cockroachdb/cockroach/12501#-KZS8_z-wdY0VDffXFjY:-KZS8_z-wdY0VDffXFjZ:b54ywxe) ([raw file](https://github.com/cockroachdb/cockroach/blob/7a58c3eec696e84a2bfb97b065fb0e3c914bafaa/pkg/server/server.go#L755)):*\n> ```Go\n> \tfor _, mode := range modes {\n> \t\tvar err error\n> \t\tswitch {\n> ```\n\ndrive by, but why isn't this\n```\nswitch mode {\ncase serverpb.DrainMode_CLIENT:\n  if err := s.pgServer.SetDraining(setTo); err != nil {\n    return err\n  }\n  s.leaseMgr.SetDraining(setTo)\ncase serverpb.DrainMode_LEASES:\n  s.nodeLivenessPauseHeartbeat(setTo)\n  if err := s.node.SetDraining(setTo); err != nil {\n    return err\n  }\ndefault:\n  return errors.Errorf(\"unknown drain mode %s\", mode) // <-- %s here is intentional, since protobuf enums implement String()\n}\n```\n\n---\n\n*[pkg/sql/lease.go, line 1171 at r1](https://reviewable.io:443/reviews/cockroachdb/cockroach/12501#-KZSB3LcTCfJPH-uZ91P:-KZSB3LdCioaJlKN09Z1:b800qm) ([raw file](https://github.com/cockroachdb/cockroach/blob/7a58c3eec696e84a2bfb97b065fb0e3c914bafaa/pkg/sql/lease.go#L1171)):*\n> ```Go\n> \tfor _, t := range m.tables {\n> \t\tt.mu.Lock()\n> \t\ttoRelease := append([]*LeaseState(nil), t.active.data...)\n> ```\n\nwhy the copy?\n\n---\n\n\n*Comments from [Reviewable](https://reviewable.io:443/reviews/cockroachdb/cockroach/12501)*\n<!-- Sent from Reviewable.io -->\n"}}
{"actor":{"display_login":"tamird"}}