Merge lp:~james-w/storm/ssl-disconnect-error into lp:storm

Proposed by James Westby on 2013-10-02
Status: Needs review
Proposed branch: lp:~james-w/storm/ssl-disconnect-error
Merge into: lp:storm
Diff against target: 40 lines (+12/-1)
2 files modified
storm/databases/postgres.py (+1/-0)
tests/databases/postgres.py (+11/-1)
To merge this branch: bzr merge lp:~james-w/storm/ssl-disconnect-error
Reviewer Review Type Date Requested Status
Storm Developers 2013-10-02 Pending
Review via email: mp+188933@code.launchpad.net

Commit message

Close the connection if there is a SSL connection closed error.

Description of the change

Hi,

We're seeing "OperationalError: SSL connection has been closed unexpectedly"
which is fatal to the connection, so add it to the list of disconnection errors.

Thanks,

James

To post a comment you must log in.

Unmerged revisions

466. By James Westby on 2013-10-02

Close the connection if there is a SSL connection closed error.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storm/databases/postgres.py'
2--- storm/databases/postgres.py 2012-04-04 23:44:02 +0000
3+++ storm/databases/postgres.py 2013-10-02 21:35:37 +0000
4@@ -316,6 +316,7 @@
5 return True
6 msg = str(exc)
7 return (
8+ "SSL connection has been closed unexpectedly" in msg or
9 "SSL SYSCALL error" in msg or
10 "EOF detected" in msg or
11 "connection already closed" in msg or
12
13=== modified file 'tests/databases/postgres.py'
14--- tests/databases/postgres.py 2012-06-12 10:00:51 +0000
15+++ tests/databases/postgres.py 2013-10-02 21:35:37 +0000
16@@ -28,7 +28,8 @@
17 from storm.variables import DateTimeVariable, RawStrVariable
18 from storm.variables import ListVariable, IntVariable, Variable
19 from storm.properties import Int
20-from storm.exceptions import DisconnectionError
21+from storm.exceptions import (
22+ DisconnectionError, OperationalError)
23 from storm.expr import (Union, Select, Insert, Update, Alias, SQLRaw, State,
24 Sequence, Like, Column, COLUMN)
25 from storm.tracer import install_tracer, TimeoutError
26@@ -579,6 +580,15 @@
27 exc = ProgrammingError("SSL SYSCALL error: Connection timed out")
28 self.assertTrue(self.connection.is_disconnection_error(exc))
29
30+ def test_is_disconnection_error_with_ssl_connection_closed(self):
31+ """
32+ If the underlying driver raises a OperationalError with 'SSL
33+ connection has been closed unexpectedly', we consider the connection
34+ dead and mark it as needing reconnection.
35+ """
36+ exc = OperationalError("SSL connection has been closed unexpectedly")
37+ self.assertTrue(self.connection.is_disconnection_error(exc))
38+
39
40 _max_prepared_transactions = None
41

Subscribers

People subscribed via source and target branches

to status/vote changes: