{"action":"created","issue":{"url":"https://api.github.com/repos/pymssql/pymssql/issues/271","labels_url":"https://api.github.com/repos/pymssql/pymssql/issues/271/labels{/name}","comments_url":"https://api.github.com/repos/pymssql/pymssql/issues/271/comments","events_url":"https://api.github.com/repos/pymssql/pymssql/issues/271/events","html_url":"https://github.com/pymssql/pymssql/issues/271","id":40783010,"number":271,"title":"Segfault on network partitioning","user":{"login":"roginski","id":1906102,"avatar_url":"https://avatars.githubusercontent.com/u/1906102?v=3","gravatar_id":"","url":"https://api.github.com/users/roginski","html_url":"https://github.com/roginski","followers_url":"https://api.github.com/users/roginski/followers","following_url":"https://api.github.com/users/roginski/following{/other_user}","gists_url":"https://api.github.com/users/roginski/gists{/gist_id}","starred_url":"https://api.github.com/users/roginski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roginski/subscriptions","organizations_url":"https://api.github.com/users/roginski/orgs","repos_url":"https://api.github.com/users/roginski/repos","events_url":"https://api.github.com/users/roginski/events{/privacy}","received_events_url":"https://api.github.com/users/roginski/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pymssql/pymssql/labels/bug","name":"bug","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/pymssql/pymssql/milestones/3","html_url":"https://github.com/pymssql/pymssql/milestones/2.2.0","labels_url":"https://api.github.com/repos/pymssql/pymssql/milestones/3/labels","id":594179,"number":3,"title":"2.2.0","description":"","creator":{"login":"msabramo","id":305268,"avatar_url":"https://avatars.githubusercontent.com/u/305268?v=3","gravatar_id":"","url":"https://api.github.com/users/msabramo","html_url":"https://github.com/msabramo","followers_url":"https://api.github.com/users/msabramo/followers","following_url":"https://api.github.com/users/msabramo/following{/other_user}","gists_url":"https://api.github.com/users/msabramo/gists{/gist_id}","starred_url":"https://api.github.com/users/msabramo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msabramo/subscriptions","organizations_url":"https://api.github.com/users/msabramo/orgs","repos_url":"https://api.github.com/users/msabramo/repos","events_url":"https://api.github.com/users/msabramo/events{/privacy}","received_events_url":"https://api.github.com/users/msabramo/received_events","type":"User","site_admin":false},"open_issues":13,"closed_issues":4,"state":"open","created_at":"2014-03-11T18:20:17Z","updated_at":"2015-10-19T00:27:52Z","due_on":"2015-03-31T07:00:00Z","closed_at":null},"comments":22,"created_at":"2014-08-21T08:30:31Z","updated_at":"2016-01-14T16:49:42Z","closed_at":null,"body":"Hello.\r\n\r\nHave an easily-reproduced segfault here. Run this script:\r\n```\r\nimport pymssql\r\nimport time\r\nimport logging\r\n\r\ndef connect():\r\n\treturn pymssql.connect(\r\n\t\tserver='*****', \r\n\t\tuser='*****',\r\n\t\tpassword='*****',\r\n\t\tdatabase='*****', \r\n\t\ttimeout=1)\r\n\r\nconnection = connect()\r\nwhile 1:\r\n\ttry:\r\n\t\tconnection.cursor().execute('select * from MyTable')\r\n\texcept pymssql.DatabaseError as e:\r\n\t\tlogging.exception(e)\r\n\t\ttime.sleep(1)\r\n\t\tcontinue\r\n\r\n\tprint 'ok'\r\n\ttime.sleep(1)\r\n```\r\nThen turn off network on client machine, see this:\r\n```\r\nok\r\nok\r\nok\r\nERROR:root:(20003, 'DB-Lib error message 20003, severity 6:\\nAdaptive Server connection timed out\\n')\r\nTraceback (most recent call last):\r\n  File \"./testdb.py\", line 25, in <module>\r\n    connection.cursor().execute('select * from Tasks')\r\n  File \"pymssql.pyx\", line 384, in pymssql.Cursor.execute (pymssql.c:4289)\r\nOperationalError: (20003, 'DB-Lib error message 20003, severity 6:\\nAdaptive Server connection timed out\\n')\r\nSegmentation fault\r\n```\r\nLooks like segfault caused by using the connection after connection failure. I could live with it if I knew how to work around that. Reconnect on each OperationalError? That's not pretty because it's not only network partitioning that causes OperationalError but many other things according to sources. Any ideas?\r\n"},"comment":{"url":"https://api.github.com/repos/pymssql/pymssql/issues/comments/171698982","html_url":"https://github.com/pymssql/pymssql/issues/271#issuecomment-171698982","issue_url":"https://api.github.com/repos/pymssql/pymssql/issues/271","id":171698982,"user":{"login":"ramiro","id":40661,"avatar_url":"https://avatars.githubusercontent.com/u/40661?v=3","gravatar_id":"","url":"https://api.github.com/users/ramiro","html_url":"https://github.com/ramiro","followers_url":"https://api.github.com/users/ramiro/followers","following_url":"https://api.github.com/users/ramiro/following{/other_user}","gists_url":"https://api.github.com/users/ramiro/gists{/gist_id}","starred_url":"https://api.github.com/users/ramiro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramiro/subscriptions","organizations_url":"https://api.github.com/users/ramiro/orgs","repos_url":"https://api.github.com/users/ramiro/repos","events_url":"https://api.github.com/users/ramiro/events{/privacy}","received_events_url":"https://api.github.com/users/ramiro/received_events","type":"User","site_admin":false},"created_at":"2016-01-14T16:49:42Z","updated_at":"2016-01-14T16:49:42Z","body":"@roginski @DavidRueter @jcrudy \r\n\r\nPlease test PR #373 as it contains a fix (or rather a workaround) to the error condition as seen from pymssql.\r\n\r\nPending your feedback, this together with #147 (already merged) this could mean all the reported segfaults problems are solved."}}