Comment #10 on issue 183 by [email protected]: 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;
        }
    }

    ...

}

Reply via email to