diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..9f4fa6d20 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +_harness + diff --git a/cluster.go b/cluster.go index 087da61e5..ac461d5b9 100644 --- a/cluster.go +++ b/cluster.go @@ -682,6 +682,7 @@ func (cluster *mongoCluster) AcquireSocket(mode Mode, slaveOk bool, syncTimeout 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() diff --git a/export_test.go b/export_test.go index 5c6c0f70b..998c7a2dd 100644 --- a/export_test.go +++ b/export_test.go @@ -1,8 +1,8 @@ package mgo import ( - "time" "net" + "time" ) func HackPingDelay(newDelay time.Duration) (restore func()) { diff --git a/harness/setup.sh b/harness/setup.sh index e5db78a78..25ba562ec 100755 --- a/harness/setup.sh +++ b/harness/setup.sh @@ -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 diff --git a/server_test.go b/server_test.go index b171898d4..1d21ef08b 100644 --- a/server_test.go +++ b/server_test.go @@ -30,7 +30,7 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/mgo.v2" + "github.com/globalsign/mgo" ) func (s *S) TestServerRecoversFromAbend(c *C) { @@ -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() }