us icon indicating copy to clipboard operation
us copied to clipboard

Last modified timestamp for DBBlob

Open jkawamoto opened this issue 4 years ago • 5 comments

It'd be helpful if DBBlob remembers the last modified timestamp because we need to sync new blob objects among gateways.

Relate to #67.

jkawamoto avatar Aug 11 '20 14:08 jkawamoto

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.

lukechampine avatar Aug 11 '20 17:08 lukechampine

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.

jkawamoto avatar Aug 12 '20 03:08 jkawamoto

This commit doesn't add the last modified timestamp https://github.com/lukechampine/us/commit/4ce2d49a414a84b35f7f2a370f70cd1c594c6be1, and I'll reopen this issue.

jkawamoto avatar Aug 19 '20 00:08 jkawamoto

Since we could implement this by ourselves, I'd close this issue.

jkawamoto avatar Aug 20 '20 19:08 jkawamoto

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.

jkawamoto avatar Oct 16 '20 20:10 jkawamoto