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.

Log this at debug level - it should still show up in the Juju logging
before an agent switches to the configured model logging level.
  • Loading branch information...
1 parent cdc788c commit 071b5646959162617d7356b49be8f419e5f8229c @babbageclunk 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.Debugf("duplicate key error patch applied")
+ })
session, err := DialWithTimeout(url, 10*time.Second)
if err == nil {
session.SetSyncTimeout(1 * time.Minute)

0 comments on commit 071b564

Please sign in to comment.