Skip to content

Commit

Permalink
Fix querynode panic when binlog ts wrong
Browse files Browse the repository at this point in the history
Signed-off-by: xige-16 <xi.ge@zilliz.com>
  • Loading branch information
xige-16 committed Jul 17, 2023
1 parent ad9271c commit 8cb09ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/core/src/storage/DataCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class DataCodec {

void
SetTimestamps(Timestamp start_timestamp, Timestamp end_timestamp) {
assert(start_timestamp <= end_timestamp);
// if milvus version <= 2.2.5
// assert(start_timestamp <= end_timestamp) condition may not be satisfied
time_range_ = std::make_pair(start_timestamp, end_timestamp);
}

Expand Down
17 changes: 13 additions & 4 deletions internal/storage/data_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,17 @@ func (insertCodec *InsertCodec) Serialize(partitionID UniqueID, segmentID Unique
rowNum := int64(timeFieldData.RowNum())

ts := timeFieldData.(*Int64FieldData).Data
startTs := ts[0]
endTs := ts[len(ts)-1]
var startTs, endTs Timestamp
startTs, endTs = math.MaxUint64, 0
for _, t := range ts {
if uint64(t) > endTs {
endTs = uint64(t)
}

if uint64(t) < startTs {
startTs = uint64(t)
}
}

// sort insert data by rowID
dataSorter := &DataSorter{
Expand Down Expand Up @@ -440,7 +449,7 @@ func (insertCodec *InsertCodec) Serialize(partitionID UniqueID, segmentID Unique
return nil, err
}

eventWriter.SetEventTimestamp(typeutil.Timestamp(startTs), typeutil.Timestamp(endTs))
eventWriter.SetEventTimestamp(startTs, endTs)
switch field.DataType {
case schemapb.DataType_Bool:
err = eventWriter.AddBoolToPayload(singleData.(*BoolFieldData).Data)
Expand Down Expand Up @@ -550,7 +559,7 @@ func (insertCodec *InsertCodec) Serialize(partitionID UniqueID, segmentID Unique
if err != nil {
return nil, err
}
writer.SetEventTimeStamp(typeutil.Timestamp(startTs), typeutil.Timestamp(endTs))
writer.SetEventTimeStamp(startTs, endTs)

err = writer.Finish()
if err != nil {
Expand Down

0 comments on commit 8cb09ab

Please sign in to comment.