-
Notifications
You must be signed in to change notification settings - Fork 454
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
Fail if FetchTagged partially retrieves results due to error #2610
Changes from all commits
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 |
---|---|---|
|
@@ -680,12 +680,16 @@ func (s *service) fetchTagged(ctx context.Context, db storage.Database, req *rpc | |
encodedDataResults = make([][][]xio.BlockReader, results.Size()) | ||
} | ||
if err := s.fetchReadEncoded(ctx, db, response, results, nsID, nsIDBytes, callStart, opts, fetchData, encodedDataResults); err != nil { | ||
s.metrics.fetchTagged.ReportError(s.nowFn().Sub(callStart)) | ||
return nil, err | ||
} | ||
|
||
// Step 2: If fetching data read the results of the asynchronuous block readers. | ||
// Step 2: If fetching data read the results of the asynchronous block readers. | ||
if fetchData { | ||
s.fetchReadResults(ctx, response, nsID, encodedDataResults) | ||
if err := s.fetchReadResults(ctx, response, nsID, encodedDataResults); err != nil { | ||
s.metrics.fetchTagged.ReportError(s.nowFn().Sub(callStart)) | ||
return nil, err | ||
} | ||
} | ||
|
||
s.metrics.fetchTagged.ReportSuccess(s.nowFn().Sub(callStart)) | ||
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. nit: maybe worth pulling out the |
||
|
@@ -723,7 +727,6 @@ func (s *service) fetchReadEncoded(ctx context.Context, | |
ctx.RegisterFinalizer(enc) | ||
encodedTags, err := s.encodeTags(enc, tags) | ||
if err != nil { // This is an invariant, should never happen | ||
s.metrics.fetchTagged.ReportError(s.nowFn().Sub(callStart)) | ||
return tterrors.NewInternalError(err) | ||
} | ||
|
||
|
@@ -740,19 +743,20 @@ func (s *service) fetchReadEncoded(ctx context.Context, | |
encoded, err := db.ReadEncoded(ctx, nsID, tsID, | ||
opts.StartInclusive, opts.EndExclusive) | ||
if err != nil { | ||
elem.Err = convert.ToRPCError(err) | ||
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. Are we aware of a reason this was originally written to not fail the batch on any 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. Yeah, that's a good question. @robskillington alluded to the fact that it was modeled after what was done for fetching blocks. but it's actually not necessary in this case. I think that's also corroborated by the fact that no one is actually making used of the embedded error message. I stopped short of removing 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. Got it yeah make sense then how it ended up present but not actually required. Yeah seems like both pros and cons to actually fully removing it. Some niceness in keeping it consistent and having around later if we decide to use it; but also makes current code a bit more confusing since we don't use it. I'd probably vote to either remove it or just leave a comment on the field for future awareness 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. seems worth removing if nobody is using it. odd to have "multiple" error paths. 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. Forgot to mention here that |
||
return convert.ToRPCError(err) | ||
} else { | ||
encodedDataResults[idx] = encoded | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (s *service) fetchReadResults(ctx context.Context, | ||
func (s *service) fetchReadResults( | ||
ctx context.Context, | ||
response *rpc.FetchTaggedResult_, | ||
nsID ident.ID, | ||
encodedDataResults [][][]xio.BlockReader, | ||
) { | ||
) error { | ||
ctx, sp, sampled := ctx.StartSampledTraceSpan(tracepoint.FetchReadResults) | ||
if sampled { | ||
sp.LogFields( | ||
|
@@ -762,19 +766,15 @@ func (s *service) fetchReadResults(ctx context.Context, | |
} | ||
defer sp.Finish() | ||
|
||
for idx, elem := range response.Elements { | ||
if elem.Err != nil { | ||
continue | ||
} | ||
|
||
for idx := range response.Elements { | ||
segments, rpcErr := s.readEncodedResult(ctx, nsID, encodedDataResults[idx]) | ||
if rpcErr != nil { | ||
elem.Err = rpcErr | ||
continue | ||
return rpcErr | ||
} | ||
|
||
response.Elements[idx].Segments = segments | ||
} | ||
return nil | ||
} | ||
|
||
func (s *service) Aggregate(tctx thrift.Context, req *rpc.AggregateQueryRequest) (*rpc.AggregateQueryResult_, error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch... almost tempted to turn on the linter that forces error checking, but that will probably generate huge amounts of noise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in an ideal world we'd have that on I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to do "_ = foo" to get around the linter if you run into that @arnikola for cases where you do really want to ignore the error.