Skip to content

Commit

Permalink
Include the patch from Issue 255.
Browse files Browse the repository at this point in the history
This brings in a test which fails without the patch, and passes with the
patch. Still to be tested, manual tcpkill of a socket.
  • Loading branch information
jameinel committed Feb 11, 2018
1 parent c460245 commit 6079041
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_harness

5 changes: 5 additions & 0 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,11 @@ func (cluster *mongoCluster) AcquireSocket(mode Mode, slaveOk bool, syncTimeout
cluster.syncServers()
time.Sleep(100 * time.Millisecond)
continue
} else {
// We've managed to successfully reconnect to the master, we are no longer abnormaly ended
server.Lock()
server.abended = false
server.Unlock()
}
}
return s, nil
Expand Down
1 change: 0 additions & 1 deletion cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,6 @@ func (s *S) TestSecondaryModeWithMongosInsert(c *C) {
c.Assert(result.A, Equals, 1)
}


func (s *S) TestRemovalOfClusterMember(c *C) {
if *fast {
c.Skip("-fast")
Expand Down
2 changes: 1 addition & 1 deletion export_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package mgo

import (
"time"
"net"
"time"
)

func HackPingDelay(newDelay time.Duration) (restore func()) {
Expand Down
2 changes: 1 addition & 1 deletion harness/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ start() {
UP=$(svstat daemons/* | grep ' up ' | grep -v ' [0-3] seconds' | wc -l)
echo "$UP processes up..."
if [ x$COUNT = x$UP ]; then
echo "Running setup.js with mongo..."
echo "Running init.js with mongo..."
mongo --nodb ../harness/mongojs/init.js
exit 0
fi
Expand Down
11 changes: 6 additions & 5 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,23 @@ func (s *S) TestServerRecoversFromAbend(c *C) {
server := cluster.Server("127.0.0.1:40001")
sock, abended, err := server.AcquireSocket(100, time.Second)
c.Assert(err, IsNil)
c.Check(abended, Equals, false)
c.Assert(sock, NotNil)
sock.Close()
sock.Release()
c.Check(abended, Equals, false)
// Forcefully abend this socket
sock.Close()
server.AbendSocket(sock)
// Next acquire notices the connection was abnormally ended
sock, abended, err = server.AcquireSocket(100, time.Second)
c.Assert(err, IsNil)
sock.Release()
c.Check(abended, Equals, true)
sock.Close()
// cluster.AcquireSocket should fix the abended problems
sock, err = cluster.AcquireSocket(mgo.Primary, false, time.Minute, time.Second, nil, 100)
c.Assert(err, IsNil)
sock.Close()
sock.Release()
sock, abended, err = server.AcquireSocket(100, time.Second)
c.Assert(err, IsNil)
c.Check(abended, Equals, false)
sock.Close()
sock.Release()
}

0 comments on commit 6079041

Please sign in to comment.