fix: [hotfix]Use task timestamp to calculating ttl timestamp (#42925)

Cherry-pick from master
pr: #42920
Related to #42918

Previously the `CollectionTtlTimestamp` could be overflowed when the
guarantee_ts==1, which means using `Eventually` consistency level.

This patch use task timestamp, allocated by scheduler, to generate ttl
timestamp ignore the potential very small timestamp being used.

Also add overflow check for ttl timestamp calculated.

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2025-06-25 10:12:42 +08:00 committed by GitHub
parent a239e76355
commit cfc8577f76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -482,9 +482,13 @@ func (t *queryTask) PreExecute(ctx context.Context) error {
t.GuaranteeTimestamp = t.request.GetGuaranteeTimestamp()
}
if collectionInfo.collectionTTL != 0 {
physicalTime, _ := tsoutil.ParseTS(guaranteeTs)
physicalTime := tsoutil.PhysicalTime(t.GetBase().GetTimestamp())
expireTime := physicalTime.Add(-time.Duration(collectionInfo.collectionTTL))
t.CollectionTtlTimestamps = tsoutil.ComposeTSByTime(expireTime, 0)
// preventing overflow, abort ttl timestamp
if t.CollectionTtlTimestamps > t.GetBase().GetTimestamp() {
t.CollectionTtlTimestamps = 0
}
}
deadline, ok := t.TraceCtx().Deadline()
if ok {

View File

@ -265,9 +265,13 @@ func (t *searchTask) PreExecute(ctx context.Context) error {
}
if collectionInfo.collectionTTL != 0 {
physicalTime, _ := tsoutil.ParseTS(guaranteeTs)
physicalTime := tsoutil.PhysicalTime(t.GetBase().GetTimestamp())
expireTime := physicalTime.Add(-time.Duration(collectionInfo.collectionTTL))
t.CollectionTtlTimestamps = tsoutil.ComposeTSByTime(expireTime, 0)
// preventing overflow, abort ttl timestamp
if t.CollectionTtlTimestamps > t.GetBase().GetTimestamp() {
t.CollectionTtlTimestamps = 0
}
}
t.resultBuf = typeutil.NewConcurrentSet[*internalpb.SearchResults]()