{"id":1205,"date":"2011-06-23T13:51:10","date_gmt":"2011-06-23T18:51:10","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=1205"},"modified":"2011-07-06T09:41:19","modified_gmt":"2011-07-06T14:41:19","slug":"simple-usage-of-a-user-profile-to-limit-concurrent-logins","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2011\/06\/23\/simple-usage-of-a-user-profile-to-limit-concurrent-logins\/","title":{"rendered":"Simple usage of a user profile to limit concurrent logins"},"content":{"rendered":"<p>We had an issue in a development database where a group of developers were not using a connection manager, but trying to manage their own connections.  This did not end well.<\/p>\n<p>To limit our exposure and the impact on other application users, we implemented a simple profile for the problematic user.  A simple test case, where the names and values are changed, is shown below.<\/p>\n<pre lang=\"sql\">\r\nSQL> create profile foo limit sessions_per_user 5;\r\n\r\nProfile created.\r\n\r\nSQL> alter user foo_user profile foo;\r\n\r\nUser altered.\r\n\r\nSQL> alter system set resource_limit = true;\r\n\r\nSystem altered.\r\n\r\nSQL> \r\n<\/pre>\n<p>We then use the python code below to test.<\/p>\n<pre lang=\"python\" line=\"1\">\r\n#!\/home\/oracle\/local\/bin\/python\r\nimport cx_Oracle, time, sys, thread\r\nfrom threading import Thread\r\n\r\n#------------------------------------------------------------------\r\n\r\nclass getTxns(Thread):\r\n   def __init__ (self):\r\n      Thread.__init__(self)\r\n\r\n   def run(self):\r\n     con = cx_Oracle.connect(\"foo_user\",\"foo_user\")\r\n     print \"got connection\"\r\n     time.sleep(10)\r\n\r\n#------------------------------------------------------------------\r\n\r\nthreadList = []\r\n\r\nfor _ in range(7):\r\n  current = getTxns()\r\n  threadList.append(current)\r\n  current.start()\r\n\r\n\r\nfor thisThread in threadList:\r\n  thisThread.join()\r\nprint \"Finished\"\r\n<\/pre>\n<p>The output of a test where we try to open seven connections is shown below&#8230;<\/p>\n<pre lang=\"text\">\r\nemgrid01:oracle:emprod1:\/home\/oracle>.\/foo_user.py\r\ngot connection\r\ngot connection\r\ngot connection\r\ngot connection\r\ngot connection\r\nException in thread Thread-2:\r\nTraceback (most recent call last):\r\n  File \"\/home\/oracle\/local\/lib\/python2.6\/threading.py\", line 525, in __bootstrap_inner\r\n    self.run()\r\n  File \".\/foo_user.py\", line 12, in run\r\n    con = cx_Oracle.connect(\"foo_user\",\"foo_user\")\r\nDatabaseError: ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit\r\n\r\n\r\nException in thread Thread-7:\r\nTraceback (most recent call last):\r\n  File \"\/home\/oracle\/local\/lib\/python2.6\/threading.py\", line 525, in __bootstrap_inner\r\n    self.run()\r\n  File \".\/foo_user.py\", line 12, in run\r\n    con = cx_Oracle.connect(\"foo_user\",\"foo_user\")\r\nDatabaseError: ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We had an issue in a development database where a group of developers were not using a connection manager, but trying to manage their own connections. This did not end well. To limit our exposure and the impact on other&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2011\/06\/23\/simple-usage-of-a-user-profile-to-limit-concurrent-logins\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,24,22,26],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1205"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1205"}],"version-history":[{"count":13,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1205\/revisions"}],"predecessor-version":[{"id":1280,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1205\/revisions\/1280"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1205"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}