Permalink
Browse files

Log that the duplicate key error patch is applied

Otherwise the only way we have to check is to try to cause an E11000
error, which is time-consuming and false-negative-prone.
  • Loading branch information...
1 parent cdc788c commit 17abfbbc91fbb6a37e682946a8d423b1f7c4633d @babbageclunk committed Jul 21, 2016
Showing with 7 additions and 0 deletions.
  1. +7 −0 session.go
View
@@ -41,6 +41,7 @@ import (
"sync"
"time"
+ "github.com/juju/loggo"
"gopkg.in/mgo.v2/bson"
)
@@ -144,6 +145,9 @@ type Iter struct {
var (
ErrNotFound = errors.New("not found")
ErrCursor = errors.New("invalid cursor")
+
+ logPatchedOnce sync.Once
+ logger = loggo.GetLogger("mgo")
)
const (
@@ -244,6 +248,9 @@ const (
// http://docs.mongodb.org/manual/reference/connection-string/
//
func Dial(url string) (*Session, error) {
+ logPatchedOnce.Do(func() {
+ logger.Infof("duplicate key error patch applied")
+ })
session, err := DialWithTimeout(url, 10*time.Second)
if err == nil {
session.SetSyncTimeout(1 * time.Minute)

0 comments on commit 17abfbb

Please sign in to comment.