Skip to content

Commit

Permalink
fix: [cp][2.5] use max MvccTs for iterator (milvus-io#37248)
Browse files Browse the repository at this point in the history
issue: milvus-io#37158
pr: milvus-io#37247

Signed-off-by: Patrick Weizhi Xu <[email protected]>
(cherry picked from commit 5ed7230)
  • Loading branch information
PwzXxm authored Oct 30, 2024
1 parent 44c1aa5 commit faf53cc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/proxy/task_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (t *queryTask) PostExecute(ctx context.Context) error {

if t.queryParams.isIterator && t.request.GetGuaranteeTimestamp() == 0 {
// first page for iteration, need to set up sessionTs for iterator
t.result.SessionTs = t.GetGuaranteeTimestamp()
t.result.SessionTs = getMaxMvccTsFromChannels(t.channelsMvcc, t.BeginTs())
}
log.Debug("Query PostExecute done")
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/proxy/task_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ func (t *searchTask) PostExecute(ctx context.Context) error {
t.result.CollectionName = t.request.GetCollectionName()
if t.isIterator && t.request.GetGuaranteeTimestamp() == 0 {
// first page for iteration, need to set up sessionTs for iterator
t.result.SessionTs = t.SearchRequest.GetGuaranteeTimestamp()
t.result.SessionTs = getMaxMvccTsFromChannels(t.queryChannelsTs, t.BeginTs())
}

metrics.ProxyReduceResultLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), metrics.SearchLabel).Observe(float64(tr.RecordSpan().Milliseconds()))
Expand Down
16 changes: 16 additions & 0 deletions internal/proxy/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,22 @@ func parseGuaranteeTs(ts, tMax typeutil.Timestamp) typeutil.Timestamp {
return ts
}

func getMaxMvccTsFromChannels(channelsTs map[string]uint64, beginTs typeutil.Timestamp) typeutil.Timestamp {
maxTs := typeutil.Timestamp(0)
for _, ts := range channelsTs {
if ts > maxTs {
maxTs = ts
}
}

if maxTs == 0 {
log.Warn("no channel ts found, use beginTs instead")
return beginTs
}

return maxTs
}

func validateName(entity string, nameType string) error {
entity = strings.TrimSpace(entity)

Expand Down

0 comments on commit faf53cc

Please sign in to comment.