柴俊 | 1 Feb 06:48
Picon

Re: how to update all values as a daily task with memcached efficiently?


Yeah, really just like use "flush" method. but the exactly method is "flushAll()" for Java MemCacheClient.
jar packages include java_memcached-release_2.6.3.jar

2012/1/31 dormando <dormando <at> rydia.net>
> hi all,the problem is like this:There are 10 millions of key/values  in memcached,and it requires to update all the values at 00:00 every  day. 
> For example,it is a daily task,the value data can not be accumulated .so it should clear up the old data value at a fixed time every day.
>
> Is there any efficient method to handle this problem ? 
>
> THX for your advise.

Call "flush" on all the servers at 00:00. all the values are immediately
invalidated.



--
memcached | 1 Feb 07:37

Re: Issue 183 in memcached: Reclaiming the space of flushed items is needed.


Comment #8 on issue 183 by jhpark...@gmail.com: Reclaiming the space of  
flushed items is needed.
http://code.google.com/p/memcached/issues/detail?id=183

Flush can be done with delay option.
So. "settings.oldest_live <= current_time" condition must be added
in order to find the flushed items.

memcached | 1 Feb 07:47

Re: Issue 183 in memcached: Reclaiming the space of flushed items is needed.


Comment #9 on issue 183 by dorma...@rydia.net: Reclaiming the space of  
flushed items is needed.
http://code.google.com/p/memcached/issues/detail?id=183

What codebase and lines and sections are you referring to here?

If it's a new bug, please open a new bug report with more details

memcached | 1 Feb 08:09

Re: Issue 248 in memcached: undefined reference to `__sync_sub_and_fetch_2'

Updates:
	Status: Fixed

Comment #2 on issue 248 by dorma...@rydia.net: undefined reference to  
`__sync_sub_and_fetch_2'
http://code.google.com/p/memcached/issues/detail?id=248

closing. 1.4.12 will be out any moment now.

memcached | 1 Feb 08:14

Re: Issue 183 in memcached: Reclaiming the space of flushed items is needed.


Comment #10 on issue 183 by jhpark...@gmail.com: Reclaiming the space of  
flushed items is needed.
http://code.google.com/p/memcached/issues/detail?id=183

I have memcached-1.4.10.
In the following do_item_alloc(),
the check condition for invalidated items should be changed to the new code.
Because, flush can be request with delay option.

item *do_item_alloc(char *key, const size_t nkey, const int flags, const  
rel_time_t exptime, const int nbytes) {

     ...

     rel_time_t oldest_live = settings.oldest_live;

     search = tails[id];
     if (search == NULL) {
         it = slabs_alloc(ntotal, id);
     } else if (search->refcount == 0) {
#if 1 // old code
         if ((search->time < oldest_live && oldest_live <= current_time) ||  
// dead by flush
          (search->exptime != 0 && search->exptime < current_time)) {
#else // old code
         if ((search->time < oldest_live) || // dead by flush
          (search->exptime != 0 && search->exptime < current_time)) {
#endif
             STATS_LOCK();
             stats.reclaimed++;
             STATS_UNLOCK();
             itemstats[id].reclaimed++;
             if ((search->it_flags & ITEM_FETCHED) == 0) {
                 STATS_LOCK();
                 stats.expired_unfetched++;
                 STATS_UNLOCK();
                 itemstats[id].expired_unfetched++;
             }
             it = search;
             it->refcount = 1;
             slabs_adjust_mem_requested(it->slabs_clsid, ITEM_ntotal(it),  
ntotal);
             do_item_unlink_nolock(it, hash(ITEM_key(it), it->nkey, 0));
             /* Initialize the item block: */
             it->slabs_clsid = 0;
             it->refcount = 0;
         }
     }

     ...

}

memcached | 1 Feb 08:18

Re: Issue 244 in memcached: Extremely Large Get Requests Fail


Comment #11 on issue 244 by dorma...@rydia.net: Extremely Large Get  
Requests Fail
http://code.google.com/p/memcached/issues/detail?id=244

Any update? :)

memcached | 1 Feb 08:22

Re: Issue 183 in memcached: Reclaiming the space of flushed items is needed.


Comment #11 on issue 183 by jhpark...@gmail.com: Reclaiming the space of  
flushed items is needed.
http://code.google.com/p/memcached/issues/detail?id=183

I have memcached-1.4.10.
In the following do_item_alloc(),
the check condition for invalidated items should be changed to the new code.
Because, flush can be requested with delay option.

item *do_item_alloc(char *key, const size_t nkey, const int flags, const  
rel_time_t exptime, const int nbytes) {

     ...

     rel_time_t oldest_live = settings.oldest_live;

     search = tails[id];
     if (search == NULL) {
         it = slabs_alloc(ntotal, id);
     } else if (search->refcount == 0) {
#if 1 // new code
         if ((search->time < oldest_live && oldest_live <= current_time) ||  
// dead by flush
          (search->exptime != 0 && search->exptime < current_time)) {
#else // old code
         if ((search->time < oldest_live) || // dead by flush
          (search->exptime != 0 && search->exptime < current_time)) {
#endif
             STATS_LOCK();
             stats.reclaimed++;
             STATS_UNLOCK();
             itemstats[id].reclaimed++;
             if ((search->it_flags & ITEM_FETCHED) == 0) {
                 STATS_LOCK();
                 stats.expired_unfetched++;
                 STATS_UNLOCK();
                 itemstats[id].expired_unfetched++;
             }
             it = search;
             it->refcount = 1;
             slabs_adjust_mem_requested(it->slabs_clsid, ITEM_ntotal(it),  
ntotal);
             do_item_unlink_nolock(it, hash(ITEM_key(it), it->nkey, 0));
             /* Initialize the item block: */
             it->slabs_clsid = 0;
             it->refcount = 0;
         }
     }

     ...

}

memcached | 1 Feb 08:26

Re: Issue 183 in memcached: Reclaiming the space of flushed items is needed.


Comment #12 on issue 183 by dorma...@rydia.net: Reclaiming the space of  
flushed items is needed.
http://code.google.com/p/memcached/issues/detail?id=183

Have you looked at 1.4.11? I rewrote that section, and might have fixed the  
bug at the same time.

memcached | 1 Feb 08:37

Re: Issue 183 in memcached: Reclaiming the space of flushed items is needed.


Comment #13 on issue 183 by jhpark...@gmail.com: Reclaiming the space of  
flushed items is needed.
http://code.google.com/p/memcached/issues/detail?id=183

Now, I have looked at 1.4.11 code.

The code still does not have "oldest_live <= current_time" condition.

item *do_item_alloc(char *key, const size_t nkey, const int flags, const  
rel_time_t exptime, const int nbytes) {
     ...
         if ((search->exptime != 0 && search->exptime < current_time)
             || (search->time < oldest_live)) {  // dead by flush
     ...
}

memcached | 1 Feb 08:41

Re: Issue 183 in memcached: Reclaiming the space of flushed items is needed.


Comment #14 on issue 183 by jhpark...@gmail.com: Reclaiming the space of  
flushed items is needed.
http://code.google.com/p/memcached/issues/detail?id=183

One more minor thing..

In do_item_get() function,
following code is used to check whether the fetched item is valid.

     if (it != NULL) {
         if (settings.oldest_live != 0 && settings.oldest_live <=  
current_time &&
             it->time <= settings.oldest_live) {
             do_item_unlink(it, hv);
             do_item_remove(it);
             it = NULL;
             if (was_found) {
                 fprintf(stderr, " -nuked by flush");
             }
         } else if (it->exptime != 0 && it->exptime <= current_time) {
             do_item_unlink(it, hv);
             do_item_remove(it);
             it = NULL;
             if (was_found) {
                 fprintf(stderr, " -nuked by expire");
             }
         } else {
             it->it_flags |= ITEM_FETCHED;
             DEBUG_REFCNT(it, '+');
         }
     }

In the above code,
"it->time <= settings.oldest_live" is used
instead of "it->time < settings.oldest_live".
So, it might be better to use the same condition in the code of  
do_item_alloc().


Gmane