From 855ec9e732c5e25a1dc8b3d48ec1439d8ec2d653 Mon Sep 17 00:00:00 2001 From: Marco Greco Date: Thu, 4 Jun 2020 15:02:02 +0100 Subject: [PATCH] MB-38083 improve scan setup time Change-Id: If6d65aad2df03ac29e6786568e0d6039025ce39e --- secondary/queryport/client/meta_client.go | 8 +++----- secondary/queryport/client/scan_client.go | 6 ++---- secondary/queryport/n1ql/secondary_index.go | 5 ++--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/secondary/queryport/client/meta_client.go b/secondary/queryport/client/meta_client.go index cbe14bbc5..7c62c1474 100644 --- a/secondary/queryport/client/meta_client.go +++ b/secondary/queryport/client/meta_client.go @@ -233,8 +233,7 @@ RETRY: secExprs, desc, isPrimary, scheme, partitionKeys, plan) if needRefresh && refreshCnt == 0 { - fmsg := "GsiClient: Indexer Node List is out-of-date. Require refresh." - logging.Debugf(fmsg) + logging.Debugf("GsiClient: Indexer Node List is out-of-date. Require refresh.") if err := b.updateIndexerList(false); err != nil { logging.Errorf("updateIndexerList(): %v\n", err) return uint64(defnID), err @@ -354,7 +353,7 @@ func (b *metadataClient) GetScanport(defnID uint64, excludes map[common.IndexDef return nil, 0, nil, nil, nil, 0, false } - var replicas [128]uint64 + replicas := make([]uint64, len(currmeta.replicas[common.IndexDefnId(defnID)])) n := 0 for _, replicaID := range currmeta.replicas[common.IndexDefnId(defnID)] { replicas[n] = uint64(replicaID) @@ -417,8 +416,7 @@ func (b *metadataClient) GetScanport(defnID uint64, excludes map[common.IndexDef } } - fmsg := "Scan port %s for index defnID %d of equivalent index defnId %d" - logging.Debugf(fmsg, qp, targetDefnID, defnID) + logging.Debugf("Scan port %s for index defnID %d of equivalent index defnId %d", qp, targetDefnID, defnID) return qp, targetDefnID, in, rt, pid, numPartitions, true } diff --git a/secondary/queryport/client/scan_client.go b/secondary/queryport/client/scan_client.go index 45022ff5e..68c17fed7 100644 --- a/secondary/queryport/client/scan_client.go +++ b/secondary/queryport/client/scan_client.go @@ -1341,8 +1341,7 @@ func (c *GsiScanClient) streamResponse( } else if resp == nil { finish = true - fmsg := "%v req(%v) connection %q received StreamEndResponse" - logging.Tracef(fmsg, c.logPrefix, requestId, laddr) + logging.Tracef("%v req(%v) connection %q received StreamEndResponse", c.logPrefix, requestId, laddr) callb(&protobuf.StreamEndResponse{}) // callback most likely return true cont, healthy = false, true @@ -1376,8 +1375,7 @@ func (c *GsiScanClient) closeStream( return } - fmsg := "%v req(%v) connection %q transmitted protobuf.EndStreamRequest" - logging.Tracef(fmsg, c.logPrefix, requestId, laddr) + logging.Tracef("%v req(%v) connection %q transmitted protobuf.EndStreamRequest", c.logPrefix, requestId, laddr) // flush the connection until stream has ended. for true { diff --git a/secondary/queryport/n1ql/secondary_index.go b/secondary/queryport/n1ql/secondary_index.go index 235674382..3532c77cc 100644 --- a/secondary/queryport/n1ql/secondary_index.go +++ b/secondary/queryport/n1ql/secondary_index.go @@ -1647,8 +1647,7 @@ func makeResponsehandler( atomic.AddInt64(&backfillEntries, 1) } else { - fmsg := "%v response cap:%v len:%v entries:%v\n" - l.Tracef(fmsg, lprefix, cp, ln, skeys.GetLength()) + l.Tracef("%v response cap:%v len:%v entries:%v\n", lprefix, cp, ln, skeys.GetLength()) if primed == false { atomic.AddInt64(&si.gsi.primedur, int64(time.Since(starttm))) primed = true @@ -1808,7 +1807,7 @@ func string2defnID(id string) uint64 { } func vector2ts(vector timestamp.Vector) *qclient.TsConsistency { - if vector == nil { + if vector == nil || len(vector.Entries()) == 0 { return nil } vbnos := make([]uint16, 0, 1024)