tag proposal

Dustin Sallings dustin at spy.net
Fri Nov 2 22:44:01 UTC 2007


On Nov 2, 2007, at 16:17 , Brian Beuning wrote:

>> Firstly, I think there are two new commands to implement tags:
>> 1) add_tag (key, tag_name)
>> 2) invalidate_tag (tag_name)
> It took me a little while to figure out that add_tag() does not  
> need to talk
> with all nodes of the cache but it seems like invalidate_tag() does  
> need to talk to all nodes.
> What is going to happen if one or more nodes are behind a network  
> partition
> type failure?
> (The Ethernet cable on a server is unplugged but memcached is still
> running.)
> They could not be notified to increment their tag generation number  
> so when
> the partition is fixed and the machines become accessible, those  
> nodes have stale data.

	It has been pointed out that mass invalidation would not be an  
atomic operation.  Perhaps it should be stated more clearly on the  
packaging.  :)

>> [It's unclear whether it's worth the effort to ever release a tag  
>> once
> it's been added.
>>  If we assume that tags live forever, we don't have to refcount  
>> them and a
> few things get easier. Any opinions?]
>
> I think the list agreed releasing tags is good.

	Right, there were good arguments for this.

> A unified way to handle this is to let a tag age out of the cache  
> using the
> LRU and timeout mechanisms already in place.  The only twist is  
> that accessing a key is also considered accessing all the tags  
> associated with that key for LRU purposes.  Given this rule, a tag  
> should never get flushed until after all the keys using the tag are  
> flushed.
> (When a tag has just one key left using the tag and the key has not  
> been accessed, there is sort of a race as to which will age out  
> first.  This is a tricky case to get right.)

	We didn't actually consider placing the tags *in* the cache, but it  
would be possible.  Every object has a reference count, so you could  
just keep the reference count high enough to avoid LRU (perhaps the  
count would be equal to the things doing the referencing).

> Are the key and tag names one or two namespaces?  That is can you  
> have a tag
> and key with the same name?
> I suggest making it one namespace for simplicity.

	The original thought was that they were completely orthogonal, so  
no, there wouldn't be any implicit correlation between an key and a  
tag with the same name.

-- 
Dustin Sallings




More information about the memcached mailing list