Skip to content

Commit 4e38f71

Browse files
committed
feat: Remove redundant error creation, remove redundant check for Dropped
1 parent 281877e commit 4e38f71

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

tsdb/field_validator.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ func ValidateAndCreateFields(mf *MeasurementFields, point models.Point, skipSize
4343
fieldKey := iter.FieldKey()
4444
// Skip fields name "time", they are illegal.
4545
if bytes.Equal(fieldKey, TimeBytes) {
46-
partialWriteError = &PartialWriteError{
47-
Reason: fmt.Sprintf(
48-
"invalid field name: input field \"%[1]s\" on measurement \"%s\" is invalid. Field \"%[1]s\" has been stripped from point.",
49-
string(fieldKey), string(point.Name())),
50-
Dropped: 0,
46+
if partialWriteError == nil {
47+
partialWriteError = &PartialWriteError{
48+
Reason: fmt.Sprintf(
49+
"invalid field name: input field \"%[1]s\" on measurement \"%s\" is invalid. Field \"%[1]s\" has been stripped from point.",
50+
fieldKey, point.Name()),
51+
Dropped: 0,
52+
}
5153
}
54+
5255
continue
5356
}
5457

tsdb/shard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ func (s *Shard) validateSeriesAndFields(points []models.Point, tracker StatsTrac
725725
continue
726726
// Sometimes we will drop fields like 'time' but not an entire point
727727
// we want to inform the writer that something occurred.
728-
} else if partialWriteError != nil && partialWriteError.Dropped <= 0 {
728+
} else if partialWriteError != nil {
729729
partialWriteError.Database = s.Database()
730730
partialWriteError.RetentionPolicy = s.RetentionPolicy()
731731
err = *partialWriteError

0 commit comments

Comments
 (0)