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/14 08:05:37 UTC

[servicecomb-service-center] branch master updated: fix heartbeat trigger update event problem (#946)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new cce8cb2  fix heartbeat trigger update event problem (#946)
cce8cb2 is described below

commit cce8cb24d3f379684bf9679b862e476ac58be6d8
Author: panqian <pq...@163.com>
AuthorDate: Wed Apr 14 16:05:26 2021 +0800

    fix heartbeat trigger update event problem (#946)
---
 datasource/mongo/sd/listwatch_inner.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/datasource/mongo/sd/listwatch_inner.go b/datasource/mongo/sd/listwatch_inner.go
index 9ae8f4f..da4612e 100644
--- a/datasource/mongo/sd/listwatch_inner.go
+++ b/datasource/mongo/sd/listwatch_inner.go
@@ -71,8 +71,13 @@ func (lw *mongoListWatch) DoWatch(ctx context.Context, f func(*sdcommon.ListWatc
 	if resumeToken != nil {
 		csOptions.SetResumeAfter(resumeToken)
 	}
-
-	resp, err := client.GetMongoClient().Watch(ctx, lw.Key, md.Pipeline{}, csOptions)
+	pipline := md.Pipeline{}
+	if lw.Key == instance {
+		// ignore instance refresh_time change event for avoid meaningless instance push.
+		match := bson.D{{"updateDescription.updatedFields.refresh_time", bson.D{{"$exists", false}}}}
+		pipline = md.Pipeline{{{"$match", match}}}
+	}
+	resp, err := client.GetMongoClient().Watch(ctx, lw.Key, pipline, csOptions)
 
 	if err != nil {
 		log.Error(fmt.Sprintf("watch table %s failed", lw.Key), err)