fix(spannerlib): gracefully handle missing stats for single statements - #887
fix(spannerlib): gracefully handle missing stats for single statements#887surbhigarg92 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the nextBatch method in spannerlib/api/rows.go to unconditionally read statistics, and modifies readStats to return nil instead of an internal error when there are no more result sets. The feedback suggests returning rows.backend.Err() instead of nil unconditionally when NextResultSet() returns false, in order to avoid swallowing underlying errors.
| if !rows.backend.NextResultSet() { | ||
| return status.Error(codes.Internal, "stats results not found") | ||
| return nil | ||
| } |
There was a problem hiding this comment.
When rows.backend.NextResultSet() returns false, it can be either because there are no more result sets or because an error occurred during the operation. Returning nil unconditionally will swallow any such errors. Instead, return rows.backend.Err() to correctly propagate any underlying errors while still returning nil when there are no more result sets.
| if !rows.backend.NextResultSet() { | |
| return status.Error(codes.Internal, "stats results not found") | |
| return nil | |
| } | |
| if !rows.backend.NextResultSet() { | |
| return rows.backend.Err() | |
| } |
da65612 to
37e5c84
Compare
In
readStats, normal (non-profiled) single-statement queries do notreturn a trailing stats result set. The previous implementation returned
a "stats results not found" error, which disrupted normal execution.
This fix returns
nilinstead, allowing the EOF auto-close logic tocomplete successfully without phantom errors.