You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2021/04/12 16:36:53 UTC

[servicecomb-service-center] branch test updated (2244b4b -> 0a08cb7)

This is an automated email from the ASF dual-hosted git repository.

littlecui pushed a change to branch test
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git.


 discard 2244b4b  SCB-2176 Fix: failed to connect mongo
     new 0a08cb7  SCB-2176 Fix: failed to connect mongo

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (2244b4b)
            \
             N -- N -- N   refs/heads/test (0a08cb7)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 datasource/mongo/client/errortypes.go | 2 --
 1 file changed, 2 deletions(-)

[servicecomb-service-center] 01/01: SCB-2176 Fix: failed to connect mongo

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

littlecui pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git

commit 0a08cb742de77c9f493630b83a50a122c6e8bcf1
Author: little-cui <su...@qq.com>
AuthorDate: Tue Apr 13 00:36:12 2021 +0800

    SCB-2176 Fix: failed to connect mongo
---
 datasource/mongo/client/errortypes.go | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/datasource/mongo/client/errortypes.go b/datasource/mongo/client/errortypes.go
index 64dd599..f1ae1a4 100644
--- a/datasource/mongo/client/errortypes.go
+++ b/datasource/mongo/client/errortypes.go
@@ -16,26 +16,17 @@
 package client
 
 import (
-	"go.mongodb.org/mongo-driver/mongo"
+	"strings"
 )
 
 const (
-	DuplicateKey = 11000
-
 	MsgDBExists  = "already exists"
 	MsgDuplicate = "duplicate key error collection"
 )
 
 func IsDuplicateKey(err error) bool {
 	if err != nil {
-		we, ok := err.(mongo.WriteException)
-		if ok {
-			for _, wr := range we.WriteErrors {
-				if wr.Code == DuplicateKey {
-					return true
-				}
-			}
-		}
+		return strings.Contains(err.Error(), MsgDuplicate)
 	}
 	return false
 }