[CDRIVER-765] Seeking issues with GridFS file Created: 28/Jul/15  Updated: 18/Nov/15  Resolved: 23/Sep/15

Status: Closed
Project: C Driver
Component/s: GridFS
Affects Version/s: 1.1.10
Fix Version/s: 1.3.0-beta0

Type: Bug Priority: Major - P3
Reporter: Jose Battig Assignee: Kyle Suarez
Resolution: Done Votes: 0
Labels: Bug, driver, pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Any


Issue Links:
Related
related to CDRIVER-870 Handle GridFS I/O operations beyond e... Closed
Backwards Compatibility: Fully Compatible

 Description   

There's two seek related issues with GridFS fixed by Pull Request https://github.com/mongodb/mongo-c-driver/pull/251/files

1. If system tries to fetch a page with _mongoc_gridfs_file_refresh_page() not available in cursor anymore, it will fail doing so because comparison to detect the range of available pages had < and > signs reverse in this code (diff from PR):

if (file->cursor &&

  • !(file->cursor_range[0] >= n && file->cursor_range[1] <= n)) {
    + !(file->cursor_range[0] <= n && file->cursor_range[1] >= n)) { mongoc_cursor_destroy (file->cursor); file->cursor = NULL; }

2. When reading/writing into GridFSFile, if doing so exactly on blocks matching the chunk size, the proper chunk was not getting flushed to database because the calculation of chunk to flush overflowed into the next chunk because the pos field was pointing to the next byte to be written/read.

The other diffs in the Pull Request try to address that issue by keeping track of "how" the pos field was updated:

a. By direct seeking
b. By movement to next byte by read or write operation

Depending on this state, we calculate number of page to flush by subtracting 1 (or not) to current pos field.



 Comments   
Comment by Githook User [ 22/Sep/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@emptysquare.net'}

Message: Merge pull request #273 from ksuarz/bugfix/flush

CDRIVER-765 fix gridfs flush
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/797f91bef011584a9ec537fcb13d2cb1a256f7f9

Comment by Githook User [ 22/Sep/15 ]

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'ksuarz@gmail.com'}

Message: CDRIVER-765 fix comments and type of page->n

Changed file->n to be an int32_t to match the type in the server.

Set the file's position and current page to zero on creation.

Minor comment fixes.
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/e6057faf8bfb9d4281949241a993bc1861bd3a32

Comment by Githook User [ 22/Sep/15 ]

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'ksuarz@gmail.com'}

Message: CDRIVER-765 comment and style changes
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/f15bafef1a81c7b03df3e5fda96ef775aeddf6bd

Comment by Githook User [ 22/Sep/15 ]

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'ksuarz@gmail.com'}

Message: CDRIVER-765 track gridfs file's chunk number

Added a new field to mongoc_gridfs_file_t that keeps track of the file's
currently-loaded chunk number.
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/214a5ffa4990c07f1c385ead785eb13b4bd3d161

Comment by Githook User [ 22/Sep/15 ]

Author:

{u'username': u'jsbattig', u'name': u'Jose Sebastian Battig', u'email': u'jsbattig@convey.com'}

Message: CDRIVER-765 fix incorrect sign comparison
Branch: 1.3.0-dev
https://github.com/mongodb/mongo-c-driver/commit/a8792fdaf259694c8c32d3e13dcaf028988cfb0f

Generated at Wed Feb 07 21:10:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.