[CDRIVER-2002] Given mongoc_gridfs_file_readv() returning -1 (failure), mongoc_gridfs_file_error() doesn't indicate error condition Created: 25/Jan/17 Updated: 03/May/17 Resolved: 28/Mar/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | GridFS |
| Affects Version/s: | 1.5.3 |
| Fix Version/s: | 1.7.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Arseny Vakhrushev | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Description |
|
There is a case when mongoc_gridfs_file_readv() returns -1 (failure), but the subsequent call to mongoc_gridfs_file_error() returns false indicating that there is no actual error. This seems to contradict with what the manual states about mongoc_gridfs_file_readv():
Interestingly, but for mongoc_gridfs_file_writev(), it states that errno will be set:
Not sure how potential database failures will be propagated via errno, but at least I can't blame this one for now albeit it looks a bit inconsistent. Please see the example below.
The output:
|
| Comments |
| Comment by Githook User [ 28/Mar/17 ] |
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: |
| Comment by Arseny Vakhrushev [ 29/Jan/17 ] |
|
That one piece of code looks like the culprit indeed. But please note, the same underlying low-level condition (absence of a chunk) may lead to a high-level EOF condition (returned value is 0 instead of -1). I achieved that by playing with seeking back and forth through the contents of an invalid file. It doesn't imply anything. It just might be a hint that something else is failing... |
| Comment by A. Jesse Jiryu Davis [ 25/Jan/17 ] |
|
Thanks, I think the problem is here, where we check if the mongoc_cursor_next has returned true (we got the first chunk) or false (we didn't): The code assumes that if it returns false, then cursor->error is set, so we can copy it to file->error. But if the cursor simply retrieves no chunks, it returns false and has no error info. The original "errno"-based error reporting for some functions is absurd and inconsistent but it's what we have right now. There is a ticket In the future we may choose to implement a second, better-thought-out GridFS API for the C Driver. |