[CDRIVER-4050] GridFS Bucket File Save stores incorrect uploadDate Created: 01/Jul/21  Updated: 28/Oct/23  Resolved: 04/Aug/21

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.9.0
Fix Version/s: 1.19.0

Type: Bug Priority: Unknown
Reporter: Colby Pike Assignee: Colby Pike
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Minor Change

 Description   

The gridfs_bucket_file_save API is setting uploadDate to the value returned from bson_monotonic_time(), which is incorrect in two ways:

  • bson_append_datetime expects time as milliseconds since the epoch, whereas the monotonic time is returned in microseconds. This is fixed by a simple division (but loses precision).
  • bson_monotonic_time() on POSIX returns the CLOCK_REALTIME clock value, which is relative to "an unspecified point in the past." Which may be the epoch, but can be arbitrary. On my system (and several systems in CI), the return value is relative to the system uptime. This results in an uploadDate only a few hours/days after 1970.


 Comments   
Comment by Colby Pike [ 04/Aug/21 ]

Change will result in different (correct) timestamps on files uploaded with the new driver.

Comment by Githook User [ 04/Aug/21 ]

Author:

{'name': 'vector-of-bool', 'email': 'vectorofbool@gmail.com', 'username': 'vector-of-bool'}

Message: Fix: CDRIVER-4050: Set the correct uploadDate on GridFS files (#818)

  • Fix: CDRIVER-4050: Set the correct uploadDate on GridFS files

Previously used the time from bson_get_monotonic_time(), which is
incorrect on most systems, as it is usually realtive to the system
uptime and is stored as microseconds, whereas uploadDate should be
stored as number of milliseconds since the Unix Epoch.

  • Propagate failure from bson_gettimeofday
  • Make get_real_time_ms a private API (for now)
  • Fix inverted error case and tests on file uploadDate
  • Fix test cases that check file uploadDate to use a more precise time
Generated at Wed Feb 07 21:19:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.