This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git
The following commit(s) were added to refs/heads/master by this push:
new cc68a0e Fix: Random order kv list (#213)
cc68a0e is described below
commit cc68a0e0cf7b0af32aa46ee590f831e10ec63389
Author: little-cui <[email protected]>
AuthorDate: Thu Aug 26 18:07:27 2021 +0800
Fix: Random order kv list (#213)
---
examples/dev/kie-conf.yaml | 2 +-
server/datasource/etcd/kv/kv_dao.go | 2 ++
server/datasource/mongo/kv/kv_dao.go | 4 +++-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml
index 39a5b03..7d10d4a 100644
--- a/examples/dev/kie-conf.yaml
+++ b/examples/dev/kie-conf.yaml
@@ -6,7 +6,7 @@ db:
# kind=etcd, then is the remote etcd server's advertise-client-urls, e.g.
http://127.0.0.1:2379
# kind=embedded_etcd, then is the embedded etcd server's
advertise-peer-urls, e.g. default=http://127.0.0.1:2380
#uri: mongodb://kie:[email protected]:27017/kie
- uri: http://127.0.0.1:2380
+ uri: http://127.0.0.1:2379
# poolSize: 10
# timeout: 5m
# sslEnabled: false
diff --git a/server/datasource/etcd/kv/kv_dao.go
b/server/datasource/etcd/kv/kv_dao.go
index 48c2eb0..d3f02b0 100644
--- a/server/datasource/etcd/kv/kv_dao.go
+++ b/server/datasource/etcd/kv/kv_dao.go
@@ -274,6 +274,8 @@ func toRegex(opts datasource.FindOptions) (*regexp.Regexp,
error) {
}
func pagingResult(result *model.KVResponse, opts datasource.FindOptions)
*model.KVResponse {
+ datasource.ReverseByUpdateRev(result.Data)
+
if opts.Limit == 0 {
return result
}
diff --git a/server/datasource/mongo/kv/kv_dao.go
b/server/datasource/mongo/kv/kv_dao.go
index 554243e..22d832e 100644
--- a/server/datasource/mongo/kv/kv_dao.go
+++ b/server/datasource/mongo/kv/kv_dao.go
@@ -106,7 +106,9 @@ func findKV(ctx context.Context, domain string, project
string, opts datasource.
filter["labels."+k] = v
}
}
- opt := options.Find()
+ opt := options.Find().SetSort(map[string]interface{}{
+ "update_revision": -1,
+ })
if opts.Limit > 0 {
opt = opt.SetLimit(opts.Limit)
opt = opt.SetSkip(opts.Offset)