{"action":"created","issue":{"url":"https://api.github.com/repos/Kitsune-/Kitsune/issues/31","labels_url":"https://api.github.com/repos/Kitsune-/Kitsune/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/Kitsune-/Kitsune/issues/31/comments","events_url":"https://api.github.com/repos/Kitsune-/Kitsune/issues/31/events","html_url":"https://github.com/Kitsune-/Kitsune/issues/31","id":62341240,"number":31,"title":"Database connection for each user","user":{"login":"Aimee0","id":9040896,"avatar_url":"https://avatars.githubusercontent.com/u/9040896?v=3","gravatar_id":"","url":"https://api.github.com/users/Aimee0","html_url":"https://github.com/Aimee0","followers_url":"https://api.github.com/users/Aimee0/followers","following_url":"https://api.github.com/users/Aimee0/following{/other_user}","gists_url":"https://api.github.com/users/Aimee0/gists{/gist_id}","starred_url":"https://api.github.com/users/Aimee0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aimee0/subscriptions","organizations_url":"https://api.github.com/users/Aimee0/orgs","repos_url":"https://api.github.com/users/Aimee0/repos","events_url":"https://api.github.com/users/Aimee0/events{/privacy}","received_events_url":"https://api.github.com/users/Aimee0/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Kitsune-/Kitsune/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-03-17T09:23:28Z","updated_at":"2015-03-19T08:42:55Z","closed_at":null,"body":"For every client connection, a database connection is opened.\r\n\r\nAs MySQL installs only by default allow a finite number of connections (**the default is 151**), if more than 150 users are connected **the server will crash**. This is because tracing the code, if the Database class experiences a connection error, it triggers a fatal error (Logger::Fatal) and exits, with no attempt at error recovery.\r\n\r\nA suggested patch would be to lower the amount of MySQL connections used by Kitsune (i.e. by removing the database-link-per-user design). \r\n\r\nProof-of-Concept script (Ruby):\r\n\r\n\trequire \"socket\"\r\n\tbegin\r\n\t\t(1..200).each do\r\n\t\t\tsocket = TCPSocket.new \"localhost\", 9875\r\n\t\t\t# Sending data forces any firewall to actually open the socket\r\n\t\t\tsocket << \"<policy-file-request/>\\0\" \r\n\t\tend\t\r\n\trescue Errno::ECONNREFUSED\r\n\t\tputs \"Server is dead. :(\"\r\n\tend"},"comment":{"url":"https://api.github.com/repos/Kitsune-/Kitsune/issues/comments/83422825","html_url":"https://github.com/Kitsune-/Kitsune/issues/31#issuecomment-83422825","issue_url":"https://api.github.com/repos/Kitsune-/Kitsune/issues/31","id":83422825,"user":{"login":"valid22","id":10195318,"avatar_url":"https://avatars.githubusercontent.com/u/10195318?v=3","gravatar_id":"","url":"https://api.github.com/users/valid22","html_url":"https://github.com/valid22","followers_url":"https://api.github.com/users/valid22/followers","following_url":"https://api.github.com/users/valid22/following{/other_user}","gists_url":"https://api.github.com/users/valid22/gists{/gist_id}","starred_url":"https://api.github.com/users/valid22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valid22/subscriptions","organizations_url":"https://api.github.com/users/valid22/orgs","repos_url":"https://api.github.com/users/valid22/repos","events_url":"https://api.github.com/users/valid22/events{/privacy}","received_events_url":"https://api.github.com/users/valid22/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T08:42:55Z","updated_at":"2015-03-19T08:42:55Z","body":"I meant About MySQL connection corruption. This will stop that over load, so it won't lead to Damange of connection to MySQL at high tarffic."}}