Commit a015870 1 parent d325c22 commit a015870 Copy full SHA for a015870
File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,10 @@ import (
27
27
28
28
"github.com/juju/errors"
29
29
"github.com/juju/loggo"
30
+ "github.com/juju/retry"
30
31
jc "github.com/juju/testing/checkers"
31
32
"github.com/juju/utils"
33
+ "github.com/juju/utils/clock"
32
34
"github.com/juju/version"
33
35
gc "gopkg.in/check.v1"
34
36
"gopkg.in/mgo.v2"
@@ -485,7 +487,23 @@ func (s *MgoSuite) TearDownSuite(c *gc.C) {
485
487
486
488
// Dial returns a new connection to the MongoDB server.
487
489
func (inst * MgoInstance ) Dial () (* mgo.Session , error ) {
488
- return mgo .DialWithInfo (inst .DialInfo ())
490
+ var session * mgo.Session
491
+ err := retry .Call (retry.CallArgs {
492
+ Func : func () error {
493
+ var err error
494
+ session , err = mgo .DialWithInfo (inst .DialInfo ())
495
+ return err
496
+ },
497
+ // Only interested in retrying the intermittent
498
+ // 'unexpected message'.
499
+ IsFatalError : func (err error ) bool {
500
+ return ! strings .HasSuffix (err .Error (), "unexpected message" )
501
+ },
502
+ Delay : time .Millisecond ,
503
+ Clock : clock .WallClock ,
504
+ Attempts : 5 ,
505
+ })
506
+ return session , err
489
507
}
490
508
491
509
// DialInfo returns information suitable for dialling the
You can’t perform that action at this time.
0 commit comments