us
us copied to clipboard
Last modified timestamp for DBBlob
It'd be helpful if DBBlob remembers the last modified timestamp because we need to sync new blob objects among gateways.
Relate to #67.
I guess there's a broader question here of how much metadata should be attached to blobs. MetaFile
has Mode
, for example, but blobs aren't necessarily files, so should they have a Mode
or not?
Timestamp tracking could certainly be handled by a custom wrapper around MetaDB
, but I realize that this is annoying, especially if a timestamp is the only piece of metadata you're missing. Let's revisit this once we know exactly what metadata you need to store for each blob.
We need the last modified timestamp and addresses where the blob is stored. Addresses seem to be retrievable with shards. So, the timestamp is the missing one for us.
Perhaps, we can store other metadata such as mode in a blob if we need it. However, since timestamp is needed to synchronize metadata between clients and referred frequently, it'd be useful if it's stored as a part of blob metadata.
This commit doesn't add the last modified timestamp https://github.com/lukechampine/us/commit/4ce2d49a414a84b35f7f2a370f70cd1c594c6be1, and I'll reopen this issue.
Since we could implement this by ourselves, I'd close this issue.
I found AddMetadata
and Metadata
don't work to store the last modified timestamp of a blob. The problem is AddBlob
and AddMetadata
(and Blob
and Metadata
) aren't executed in the same transaction. As a result, if two goroutines add a blob each at the same time, the last modified timestamp stored in the DB can be associated with the other blob. It can also happen that one goroutine read and another goroutine write a blob, the reader can get the newest blob with the previous time samp.