-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat: Bubble error up to writer if fields are dropped #26998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master-1.x
Are you sure you want to change the base?
Changes from all commits
6ea8c71
cb33dcf
fa5ba4f
724391c
c464b65
d3bf074
c15199b
18e835a
01c5a3f
928b1c6
2044458
281877e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ func ValidateAndCreateFields(mf *MeasurementFields, point models.Point, skipSize | |
| pointSize := point.StringSize() | ||
| iter := point.FieldIterator() | ||
| var fieldsToCreate []*FieldCreate | ||
| var partialWriteError *PartialWriteError | ||
|
|
||
| // We return fieldsToCreate even on error, because other writes | ||
| // in parallel may depend on these previous fields having been | ||
|
|
@@ -41,7 +42,13 @@ func ValidateAndCreateFields(mf *MeasurementFields, point models.Point, skipSize | |
|
|
||
| fieldKey := iter.FieldKey() | ||
| // Skip fields name "time", they are illegal. | ||
| if bytes.Equal(fieldKey, timeBytes) { | ||
| if bytes.Equal(fieldKey, TimeBytes) { | ||
| partialWriteError = &PartialWriteError{ | ||
| Reason: fmt.Sprintf( | ||
| "invalid field name: input field \"%[1]s\" on measurement \"%s\" is invalid. Field \"%[1]s\" has been stripped from point.", | ||
| string(fieldKey), string(point.Name())), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably do not need the cast to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we handle multiple
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we have multiple time fields we want to hit the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, output when you have multiple If you only have time fields (drops the entire point as expected):
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminate the |
||
| Dropped: 0, | ||
| } | ||
| continue | ||
| } | ||
|
|
||
|
|
@@ -70,7 +77,7 @@ func ValidateAndCreateFields(mf *MeasurementFields, point models.Point, skipSize | |
| fieldsToCreate = append(fieldsToCreate, &FieldCreate{point.Name(), f}) | ||
| } | ||
| } | ||
| return fieldsToCreate, nil | ||
| return fieldsToCreate, partialWriteError | ||
| } | ||
|
|
||
| // dataTypeFromModelsFieldType returns the influxql.DataType that corresponds to the | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,7 +88,7 @@ var ( | |
|
|
||
| var ( | ||
| // Static objects to prevent small allocs. | ||
| timeBytes = []byte("time") | ||
| TimeBytes = []byte("time") | ||
| ) | ||
|
|
||
| // A ShardError implements the error interface, and contains extra | ||
|
|
@@ -631,7 +631,7 @@ func (s *Shard) validateSeriesAndFields(points []models.Point, tracker StatsTrac | |
| tags := p.Tags() | ||
|
|
||
| // Drop any series w/ a "time" tag, these are illegal | ||
| if v := tags.Get(timeBytes); v != nil { | ||
| if v := tags.Get(TimeBytes); v != nil { | ||
| dropped++ | ||
| if reason == "" { | ||
| reason = fmt.Sprintf( | ||
|
|
@@ -689,7 +689,7 @@ func (s *Shard) validateSeriesAndFields(points []models.Point, tracker StatsTrac | |
| iter := p.FieldIterator() | ||
| validField := false | ||
| for iter.Next() { | ||
| if bytes.Equal(iter.FieldKey(), timeBytes) { | ||
| if bytes.Equal(iter.FieldKey(), TimeBytes) { | ||
| continue | ||
| } | ||
| validField = true | ||
|
|
@@ -716,13 +716,19 @@ func (s *Shard) validateSeriesAndFields(points []models.Point, tracker StatsTrac | |
| newFields, partialWriteError := ValidateAndCreateFields(mf, p, s.options.Config.SkipFieldSizeValidation) | ||
| createdFieldsToSave = append(createdFieldsToSave, newFields...) | ||
|
|
||
| if partialWriteError != nil { | ||
| if partialWriteError != nil && partialWriteError.Dropped > 0 { | ||
| if reason == "" { | ||
| reason = partialWriteError.Reason | ||
| } | ||
| dropped += partialWriteError.Dropped | ||
| atomic.AddInt64(&s.stats.WritePointsDropped, int64(partialWriteError.Dropped)) | ||
| continue | ||
| // Sometimes we will drop fields like 'time' but not an entire point | ||
| // we want to inform the writer that something occurred. | ||
| } else if partialWriteError != nil && partialWriteError.Dropped <= 0 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the check for |
||
| partialWriteError.Database = s.Database() | ||
| partialWriteError.RetentionPolicy = s.RetentionPolicy() | ||
| err = *partialWriteError | ||
| } | ||
| points[j] = points[i] | ||
| j++ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.