git.iko.soy/distributed-process
on master help sign in
Start work on the updated N.T failure semantics
a962871Edsko de Vries
distributed-process-simplelocalnet/ChangeLog+4
@@ -1,3 +1,7 @@
1+<<date>> Edsko de Vries <edsko@well-typed.com> 0.2.0.6
2+
3+* Use new version of network-transport
4+
12012-08-22 Edsko de Vries <edsko@well-typed.com> 0.2.0.5
52012-08-22 Edsko de Vries <edsko@well-typed.com> 0.2.0.5
2
6
3* Don't assume slaves are still alive in findSlaves
7* Don't assume slaves are still alive in findSlaves
distributed-process-simplelocalnet/distributed-process-simplelocalnet.cabal+5−5
@@ -1,5 +1,5 @@
1Name: distributed-process-simplelocalnet
1Name: distributed-process-simplelocalnet
2−Version: 0.2.0.5
2+Version: 0.2.0.6
3Cabal-Version: >=1.8
3Cabal-Version: >=1.8
4Build-Type: Simple
4Build-Type: Simple
5License: BSD3
5License: BSD3
@@ -32,8 +32,8 @@ Library
32 binary >= 0.5 && < 0.6,
32 binary >= 0.5 && < 0.6,
33 containers >= 0.4 && < 0.6,
33 containers >= 0.4 && < 0.6,
34 transformers >= 0.2 && < 0.4,
34 transformers >= 0.2 && < 0.4,
35− network-transport >= 0.2 && < 0.3,
35+ network-transport >= 0.3 && < 0.4,
36− network-transport-tcp >= 0.2 && < 0.3,
36+ network-transport-tcp >= 0.3 && < 0.4,
37 distributed-process >= 0.2 && < 0.4
37 distributed-process >= 0.2 && < 0.4
38 Exposed-modules: Control.Distributed.Process.Backend.SimpleLocalnet,
38 Exposed-modules: Control.Distributed.Process.Backend.SimpleLocalnet,
39 Control.Distributed.Process.Backend.SimpleLocalnet.Internal.Multicast
39 Control.Distributed.Process.Backend.SimpleLocalnet.Internal.Multicast
@@ -54,8 +54,8 @@ Test-Suite TestSimpleLocalnet
54 binary >= 0.5 && < 0.6,
54 binary >= 0.5 && < 0.6,
55 containers >= 0.4 && < 0.6,
55 containers >= 0.4 && < 0.6,
56 transformers >= 0.2 && < 0.4,
56 transformers >= 0.2 && < 0.4,
57− network-transport >= 0.2 && < 0.3,
57+ network-transport >= 0.3 && < 0.4,
58− network-transport-tcp >= 0.2 && < 0.3,
58+ network-transport-tcp >= 0.3 && < 0.4,
59 distributed-process >= 0.2 && < 0.4
59 distributed-process >= 0.2 && < 0.4
60 Extensions: RankNTypes,
60 Extensions: RankNTypes,
61 DeriveDataTypeable
61 DeriveDataTypeable
distributed-process/ChangeLog+5
@@ -1,3 +1,8 @@
1+<<date>> Edsko de Vries <edsko@well-typed.com> 0.3.2
2+
3+* Improved treatment of network failure, using new failure semantics of
4+Network.Transport.
5+
12012-08-16 Edsko de Vries <edsko@well-typed.com> 0.3.1
62012-08-16 Edsko de Vries <edsko@well-typed.com> 0.3.1
2
7
3* Fix memory leaks
8* Fix memory leaks
distributed-process/distributed-process.cabal+6−6
@@ -1,5 +1,5 @@
1Name: distributed-process
1Name: distributed-process
2−Version: 0.3.1
2+Version: 0.3.2
3Cabal-Version: >=1.8
3Cabal-Version: >=1.8
4Build-Type: Simple
4Build-Type: Simple
5License: BSD3
5License: BSD3
@@ -36,7 +36,7 @@ flag th
36Library
36Library
37 Build-Depends: base >= 4.4 && < 5,
37 Build-Depends: base >= 4.4 && < 5,
38 binary >= 0.5 && < 0.6,
38 binary >= 0.5 && < 0.6,
39− network-transport >= 0.2 && < 0.3,
39+ network-transport >= 0.3 && < 0.4,
40 stm >= 2.3 && < 2.5,
40 stm >= 2.3 && < 2.5,
41 transformers >= 0.2 && < 0.4,
41 transformers >= 0.2 && < 0.4,
42 mtl >= 2.0 && < 2.2,
42 mtl >= 2.0 && < 2.2,
@@ -84,8 +84,8 @@ Test-Suite TestCH
84 random >= 1.0 && < 1.1,
84 random >= 1.0 && < 1.1,
85 ansi-terminal >= 0.5 && < 0.6,
85 ansi-terminal >= 0.5 && < 0.6,
86 distributed-process >= 0.3 && < 0.4,
86 distributed-process >= 0.3 && < 0.4,
87− network-transport >= 0.2 && < 0.3,
87+ network-transport >= 0.3 && < 0.4,
88− network-transport-tcp >= 0.2 && < 0.3,
88+ network-transport-tcp >= 0.3 && < 0.4,
89 binary >= 0.5 && < 0.6,
89 binary >= 0.5 && < 0.6,
90 network >= 2.3 && < 2.4
90 network >= 2.3 && < 2.4
91 Other-modules: TestAuxiliary
91 Other-modules: TestAuxiliary
@@ -104,8 +104,8 @@ Test-Suite TestClosure
104 ansi-terminal >= 0.5 && < 0.6,
104 ansi-terminal >= 0.5 && < 0.6,
105 distributed-static >= 0.2 && < 0.3,
105 distributed-static >= 0.2 && < 0.3,
106 distributed-process >= 0.3 && < 0.4,
106 distributed-process >= 0.3 && < 0.4,
107− network-transport >= 0.2 && < 0.3,
107+ network-transport >= 0.3 && < 0.4,
108− network-transport-tcp >= 0.2 && < 0.3,
108+ network-transport-tcp >= 0.3 && < 0.4,
109 bytestring >= 0.9 && < 0.11,
109 bytestring >= 0.9 && < 0.11,
110 network >= 2.3 && < 2.4
110 network >= 2.3 && < 2.4
111 Other-modules: TestAuxiliary
111 Other-modules: TestAuxiliary
distributed-process/src/Control/Distributed/Process/Node.hs+7−6
@@ -345,23 +345,24 @@ handleIncomingMessages node = go Set.empty Map.empty Map.empty Set.empty
345 (Map.delete cid procs)
345 (Map.delete cid procs)
346 (Map.delete cid chans)
346 (Map.delete cid chans)
347 (Set.delete cid ctrls)
347 (Set.delete cid ctrls)
348− NT.ErrorEvent (NT.TransportError (NT.EventConnectionLost (Just theirAddr) cids) _) -> do
348+ NT.ErrorEvent (NT.TransportError (NT.EventConnectionLost theirAddr) _) -> do
349 -- [Unified table 9, rule node_disconnect]
349 -- [Unified table 9, rule node_disconnect]
350 let nid = NodeIdentifier $ NodeId theirAddr
350 let nid = NodeIdentifier $ NodeId theirAddr
351 writeChan ctrlChan NCMsg
351 writeChan ctrlChan NCMsg
352 { ctrlMsgSender = nid
352 { ctrlMsgSender = nid
353 , ctrlMsgSignal = Died nid DiedDisconnect
353 , ctrlMsgSignal = Died nid DiedDisconnect
354 }
354 }
355+ -- TODO: we should remove the incoming transactions that were lost
356+ -- TODO: and we should remove the outgoing connections for which
357+ -- we have an implicit reconnect
358+ {-
355 let notRemoved k = k `notElem` cids
359 let notRemoved k = k `notElem` cids
356 go (Set.filter notRemoved uninitConns)
360 go (Set.filter notRemoved uninitConns)
357 (Map.filterWithKey (const . notRemoved) procs)
361 (Map.filterWithKey (const . notRemoved) procs)
358 (Map.filterWithKey (const . notRemoved) chans)
362 (Map.filterWithKey (const . notRemoved) chans)
359 (Set.filter notRemoved ctrls)
363 (Set.filter notRemoved ctrls)
360− NT.ErrorEvent (NT.TransportError (NT.EventConnectionLost Nothing _) _) ->
364+ -}
361− -- TODO: We should treat an asymetrical connection loss (incoming
365+ go uninitConns procs chans ctrls
362− -- connection broken, but outgoing connection still potentially ok)
363− -- as a fatal error on the part of the remote node (like (**), above)
364− fail "handleIncomingMessages: TODO"
365 NT.ErrorEvent (NT.TransportError NT.EventEndPointFailed str) ->
366 NT.ErrorEvent (NT.TransportError NT.EventEndPointFailed str) ->
366 fail $ "Cloud Haskell fatal error: end point failed: " ++ str
367 fail $ "Cloud Haskell fatal error: end point failed: " ++ str
367 NT.ErrorEvent (NT.TransportError NT.EventTransportFailed str) ->
368 NT.ErrorEvent (NT.TransportError NT.EventTransportFailed str) ->
network-transport-tcp/ChangeLog+4
@@ -1,3 +1,7 @@
1+<<date>> Edsko de Vries <edsko@well-typed.com> 0.3.0
2+
3+* Implement new disconnection semantics
4+
12012-08-20 Edsko de Vries <edsko@well-typed.com> 0.2.0.3
52012-08-20 Edsko de Vries <edsko@well-typed.com> 0.2.0.3
2
6
3* Allow for colons in hostnames (for IPv6)
7* Allow for colons in hostnames (for IPv6)
network-transport-tcp/network-transport-tcp.cabal+3−3
@@ -1,5 +1,5 @@
1Name: network-transport-tcp
1Name: network-transport-tcp
2−Version: 0.2.0.3
2+Version: 0.3.0
3Cabal-Version: >=1.8
3Cabal-Version: >=1.8
4Build-Type: Simple
4Build-Type: Simple
5License: BSD3
5License: BSD3
@@ -22,7 +22,7 @@ Source-Repository head
22
22
23Library
23Library
24 Build-Depends: base >= 4.3 && < 5,
24 Build-Depends: base >= 4.3 && < 5,
25− network-transport >= 0.2 && < 0.3,
25+ network-transport >= 0.3 && < 0.4,
26 data-accessor >= 0.2 && < 0.3,
26 data-accessor >= 0.2 && < 0.3,
27 containers >= 0.4 && < 0.6,
27 containers >= 0.4 && < 0.6,
28 bytestring >= 0.9 && < 0.11,
28 bytestring >= 0.9 && < 0.11,
@@ -37,7 +37,7 @@ Test-Suite TestTCP
37 Type: exitcode-stdio-1.0
37 Type: exitcode-stdio-1.0
38 Main-Is: TestTCP.hs
38 Main-Is: TestTCP.hs
39 Build-Depends: base >= 4.3 && < 5,
39 Build-Depends: base >= 4.3 && < 5,
40− network-transport >= 0.2 && < 0.3,
40+ network-transport >= 0.3 && < 0.4,
41 data-accessor >= 0.2 && < 0.3,
41 data-accessor >= 0.2 && < 0.3,
42 containers >= 0.4 && < 0.6,
42 containers >= 0.4 && < 0.6,
43 bytestring >= 0.9 && < 0.11,
43 bytestring >= 0.9 && < 0.11,
network-transport-tcp/src/Network/Transport/TCP.hs+2−5
@@ -745,8 +745,7 @@ modifyRemoteState (ourEndPoint, theirEndPoint) match =
745 handleIOException ex vst = do
745 handleIOException ex vst = do
746 tryCloseSocket (remoteSocket vst)
746 tryCloseSocket (remoteSocket vst)
747 putMVar theirState (RemoteEndPointFailed ex)
747 putMVar theirState (RemoteEndPointFailed ex)
748− let incoming = IntSet.elems $ vst ^. remoteIncoming
749− code = EventConnectionLost (Just $ remoteAddress theirEndPoint) incoming
748+ let code = EventConnectionLost (remoteAddress theirEndPoint)
750 err = TransportError code (show ex)
749 err = TransportError code (show ex)
751 writeChan (localChannel ourEndPoint) $ ErrorEvent err
750 writeChan (localChannel ourEndPoint) $ ErrorEvent err
752
751
@@ -1085,9 +1084,7 @@ handleIncomingMessages (ourEndPoint, theirEndPoint) = do
1085 relyViolation (ourEndPoint, theirEndPoint)
1084 relyViolation (ourEndPoint, theirEndPoint)
1086 "handleIncomingMessages:prematureExit"
1085 "handleIncomingMessages:prematureExit"
1087 RemoteEndPointValid vst -> do
1086 RemoteEndPointValid vst -> do
1088− let code = EventConnectionLost
1087+ let code = EventConnectionLost (remoteAddress theirEndPoint)
1089− (Just $ remoteAddress theirEndPoint)
1090− (IntSet.elems $ vst ^. remoteIncoming)
1091 writeChan ourChannel . ErrorEvent $ TransportError code (show err)
1088 writeChan ourChannel . ErrorEvent $ TransportError code (show err)
1092 forM_ (vst ^. pendingCtrlRequests) $ flip putMVar (Left err)
1089 forM_ (vst ^. pendingCtrlRequests) $ flip putMVar (Left err)
1093 return (RemoteEndPointFailed err)
1090 return (RemoteEndPointFailed err)
network-transport-tcp/tests/TestTCP.hs+11−11
@@ -98,11 +98,11 @@ testEarlyDisconnect nextPort = do
98
98
99 -- TEST 1: they connect to us, then drop the connection
99 -- TEST 1: they connect to us, then drop the connection
100 do
100 do
101− ConnectionOpened cid _ addr <- receive endpoint
101+ ConnectionOpened _ _ addr <- receive endpoint
102 True <- return $ addr == theirAddr
102 True <- return $ addr == theirAddr
103
103
104− ErrorEvent (TransportError (EventConnectionLost (Just addr') [cid']) _) <- receive endpoint
104+ ErrorEvent (TransportError (EventConnectionLost addr') _) <- receive endpoint
105− True <- return $ addr' == theirAddr && cid' == cid
105+ True <- return $ addr' == theirAddr
106
106
107 return ()
107 return ()
108
108
@@ -124,8 +124,8 @@ testEarlyDisconnect nextPort = do
124 Received cid' ["pong"] <- receive endpoint
124 Received cid' ["pong"] <- receive endpoint
125 True <- return $ cid == cid'
125 True <- return $ cid == cid'
126
126
127− ErrorEvent (TransportError (EventConnectionLost (Just addr') [cid'']) _) <- receive endpoint
127+ ErrorEvent (TransportError (EventConnectionLost addr') _) <- receive endpoint
128− True <- return $ addr' == theirAddr && cid'' == cid
128+ True <- return $ addr' == theirAddr
129
129
130 return ()
130 return ()
131
131
@@ -235,7 +235,7 @@ testEarlyCloseSocket nextPort = do
235 ConnectionClosed cid'' <- receive endpoint
235 ConnectionClosed cid'' <- receive endpoint
236 True <- return $ cid'' == cid
236 True <- return $ cid'' == cid
237
237
238− ErrorEvent (TransportError (EventConnectionLost (Just addr') []) _) <- receive endpoint
238+ ErrorEvent (TransportError (EventConnectionLost addr') _) <- receive endpoint
239 True <- return $ addr' == theirAddr
239 True <- return $ addr' == theirAddr
240
240
241 return ()
241 return ()
@@ -634,7 +634,7 @@ testReconnect nextPort = do
634
634
635 -- But a send will fail because the server has closed the connection again
635 -- But a send will fail because the server has closed the connection again
636 Left (TransportError SendFailed _) <- send conn1 ["ping"]
636 Left (TransportError SendFailed _) <- send conn1 ["ping"]
637− ErrorEvent (TransportError (EventConnectionLost _ []) _) <- receive endpoint
637+ ErrorEvent (TransportError (EventConnectionLost _) _) <- receive endpoint
638
638
639 -- But a subsequent call to connect should reestablish the connection
639 -- But a subsequent call to connect should reestablish the connection
640 Right conn2 <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
640 Right conn2 <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
@@ -695,7 +695,7 @@ testUnidirectionalError nextPort = do
695
695
696 -- But when we send we find the error
696 -- But when we send we find the error
697 Left (TransportError SendFailed _) <- send conn1 ["ping"]
697 Left (TransportError SendFailed _) <- send conn1 ["ping"]
698− ErrorEvent (TransportError (EventConnectionLost _ []) _) <- receive endpoint
698+ ErrorEvent (TransportError (EventConnectionLost _) _) <- receive endpoint
699
699
700 -- A call to connect should now re-establish the connection
700 -- A call to connect should now re-establish the connection
701 Right conn2 <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
701 Right conn2 <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
@@ -709,7 +709,7 @@ testUnidirectionalError nextPort = do
709 -- We now find the error when we attempt to close the connection
709 -- We now find the error when we attempt to close the connection
710 Nothing <- timeout 500000 $ receive endpoint
710 Nothing <- timeout 500000 $ receive endpoint
711 close conn2
711 close conn2
712− ErrorEvent (TransportError (EventConnectionLost _ []) _) <- receive endpoint
712+ ErrorEvent (TransportError (EventConnectionLost _) _) <- receive endpoint
713 Right conn3 <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
713 Right conn3 <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
714 send conn3 ["ping"]
714 send conn3 ["ping"]
715 takeMVar serverGotPing
715 takeMVar serverGotPing
@@ -721,7 +721,7 @@ testUnidirectionalError nextPort = do
721 -- Now we notice the problem when we try to connect
721 -- Now we notice the problem when we try to connect
722 Nothing <- timeout 500000 $ receive endpoint
722 Nothing <- timeout 500000 $ receive endpoint
723 Left (TransportError ConnectFailed _) <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
723 Left (TransportError ConnectFailed _) <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
724− ErrorEvent (TransportError (EventConnectionLost _ []) _) <- receive endpoint
724+ ErrorEvent (TransportError (EventConnectionLost _) _) <- receive endpoint
725 Right conn4 <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
725 Right conn4 <- connect endpoint theirAddr ReliableOrdered defaultConnectHints
726 send conn4 ["ping"]
726 send conn4 ["ping"]
727 takeMVar serverGotPing
727 takeMVar serverGotPing
@@ -746,7 +746,7 @@ testInvalidCloseConnection nextPort = do
746
746
747 -- At this point the client sends an invalid request, so we terminate the
747 -- At this point the client sends an invalid request, so we terminate the
748 -- connection
748 -- connection
749− ErrorEvent (TransportError (EventConnectionLost _ [_]) _) <- receive endpoint
749+ ErrorEvent (TransportError (EventConnectionLost _) _) <- receive endpoint
750
750
751 putMVar serverDone ()
751 putMVar serverDone ()
752
752
network-transport-tcp/tests/TestTransport.hs+4−4
@@ -606,7 +606,7 @@ testCloseEndPoint transport _ = do
606 send conn ["pong"]
606 send conn ["pong"]
607
607
608 ConnectionClosed cid'' <- receive endpoint ; True <- return $ cid == cid''
608 ConnectionClosed cid'' <- receive endpoint ; True <- return $ cid == cid''
609− ErrorEvent (TransportError (EventConnectionLost (Just addr') []) _) <- receive endpoint ; True <- return $ addr' == theirAddr
609+ ErrorEvent (TransportError (EventConnectionLost addr') _) <- receive endpoint ; True <- return $ addr' == theirAddr
610
610
611 Left (TransportError SendFailed _) <- send conn ["pong2"]
611 Left (TransportError SendFailed _) <- send conn ["pong2"]
612
612
@@ -694,7 +694,7 @@ testCloseTransport newTransport = do
694 evs <- replicateM 3 $ receive endpoint
694 evs <- replicateM 3 $ receive endpoint
695 let expected = [ ConnectionClosed cid1
695 let expected = [ ConnectionClosed cid1
696 , ConnectionClosed cid2
696 , ConnectionClosed cid2
697− , ErrorEvent (TransportError (EventConnectionLost (Just theirAddr2) []) "")
697+ , ErrorEvent (TransportError (EventConnectionLost theirAddr2) "")
698 ]
698 ]
699 True <- return $ any (== expected) (permutations evs)
699 True <- return $ any (== expected) (permutations evs)
700
700
@@ -813,8 +813,8 @@ testSendException newTransport = do
813 -- This will have been as a failure to send by endpoint1, which will
813 -- This will have been as a failure to send by endpoint1, which will
814 -- therefore have closed the socket. In turn this will have caused endpoint2
814 -- therefore have closed the socket. In turn this will have caused endpoint2
815 -- to report that the connection was lost
815 -- to report that the connection was lost
816− ErrorEvent (TransportError (EventConnectionLost _ []) _) <- receive endpoint1
816+ ErrorEvent (TransportError (EventConnectionLost _) _) <- receive endpoint1
817− ErrorEvent (TransportError (EventConnectionLost _ [_]) _) <- receive endpoint2
817+ ErrorEvent (TransportError (EventConnectionLost _) _) <- receive endpoint2
818
818
819 -- A new connection will re-establish the connection
819 -- A new connection will re-establish the connection
820 Right conn2 <- connect endpoint1 (address endpoint2) ReliableOrdered defaultConnectHints
820 Right conn2 <- connect endpoint1 (address endpoint2) ReliableOrdered defaultConnectHints
network-transport/ChangeLog+4
@@ -1,3 +1,7 @@
1+<<date> Edsko de Vries <edsko@well-typed.com> 0.3.0
2+
3+* Clarify disconnection
4+
12012-07-16 Edsko de Vries <edsko@well-typed.com> 0.2.0.2
52012-07-16 Edsko de Vries <edsko@well-typed.com> 0.2.0.2
2
6
3* Base 4.6 compatible test suites
7* Base 4.6 compatible test suites
network-transport/network-transport.cabal+1−1
@@ -1,5 +1,5 @@
1Name: network-transport
1Name: network-transport
2−Version: 0.2.0.2
2+Version: 0.3.0
3Cabal-Version: >=1.6
3Cabal-Version: >=1.6
4Build-Type: Simple
4Build-Type: Simple
5License: BSD3
5License: BSD3
network-transport/src/Network/Transport.hs+31−4
@@ -230,8 +230,35 @@ data EventErrorCode =
230 EventEndPointFailed
230 EventEndPointFailed
231 -- | Transport-wide fatal error
231 -- | Transport-wide fatal error
232 | EventTransportFailed
232 | EventTransportFailed
233− -- | Some incoming connections were closed abruptly.
233+ -- | We lost connection to another endpoint
234− -- If an endpoint address is specified, then all connections to and
234+ --
235− -- from that endpoint are now lost
235+ -- Although "Network.Transport" provides multiple independent lightweight
236+ -- connections between endpoints, those connections cannot /fail/
237+ -- independently: once one connection has failed, /all/ connections, in
238+ -- both directions, must now be considered to have failed; they fail as a
239+ -- "bundle" of connections, with only a single "bundle" of connections per
240+ -- endpoint at any point in time.
241+ --
242+ -- That is, suppose there are multiple connections in either direction
243+ -- between A and B, and A receives a notification that it has lost
244+ -- connection to B. Then A should not be able to send any further messages
245+ -- to B on existing connections.
246+ --
247+ -- Although B may not realize /immediately/ that its connection to A has
248+ -- been broken, messages sent by B on existing connections should not be
249+ -- delivered, and B must eventually get an EventConnectionLost message,
250+ -- too.
251+ --
252+ -- Moreover, this event must be posted before A has successfully
253+ -- reconnected (in other words, if B notices a reconnection attempt from A,
254+ -- it must post the EventConnectionLost before acknowledging the connection
255+ -- from A) so that B will not receive events about new connections or
256+ -- incoming messages from A without realizing that it got disconnected.
257+ --
258+ -- If B attempts to establish another connection to A before it realized
259+ -- that it got disconnected from A then it's okay for this connection
260+ -- attempt to fail, and the EventConnectionLost to be posted at that point,
261+ -- or for the EventConnectionLost to be posted and for the new connection
262+ -- to be considered the first connection of the "new bundle".
236− | EventConnectionLost (Maybe EndPointAddress) [ConnectionId]
263+ | EventConnectionLost EndPointAddress
237 deriving (Show, Typeable, Eq)
264 deriving (Show, Typeable, Eq)