隐秘的GC缓存条目意味着什么

时间:2011-01-11 11:01:52

标签: php warnings apc

我不时收到这条奇怪的警告信息。它通常在页面重新加载时消失。那是什么意思。我用Google搜索但无济于事。

Warning: include(): GC cache entry '/.../...class.php' (dev=2049 ino=37120489) was on gc-list for 3840 seconds in /.../...class.php on line 111

1 个答案:

答案 0 :(得分:34)

这个问题肯定来自APC,来自包apc-3.1.6-r1的源代码。将项目插入用户缓存或文件缓存时,将调用此函数。

static void process_pending_removals(apc_cache_t* cache TSRMLS_DC)
{
slot_t** slot;
time_t now;

/* This function scans the list of removed cache entries and deletes any
 * entry whose reference count is zero (indicating that it is no longer
 * being executed) or that has been on the pending list for more than
 * cache->gc_ttl seconds (we issue a warning in the latter case).
 */

if (!cache->header->deleted_list)
    return;

slot = &cache->header->deleted_list;
now = time(0);

while (*slot != NULL) {
    int gc_sec = cache->gc_ttl ? (now - (*slot)->deletion_time) : 0;

    if ((*slot)->value->ref_count <= 0 || gc_sec > cache->gc_ttl) {
        slot_t* dead = *slot;

        if (dead->value->ref_count > 0) {
            switch(dead->value->type) {
                case APC_CACHE_ENTRY_FILE:
                    apc_warning("GC cache entry '%s' (dev=%d ino=%d) was on gc-list for %d seconds" TSRMLS_CC,
                        dead->value->data.file.filename, dead->key.data.file.device, dead->key.data.file.inode, gc_sec);
                    break;
                case APC_CACHE_ENTRY_USER:
                    apc_warning("GC cache entry '%s'was on gc-list for %d seconds" TSRMLS_CC, dead->value->data.user.info, gc_sec);
                    break;
            }
        }
        *slot = dead->next;
        free_slot(dead TSRMLS_CC);
    }
    else {
        slot = &(*slot)->next;
    }
} 
}

来自APC配置(http://cz.php.net/manual/en/apc.configuration.php#ini.apc.gc-ttl

apc.gc_ttl integer

缓存条目可能保留在垃圾收集列表中的秒数。如果服务器进程在执行缓存的源文件时死亡,则此值提供故障保护;如果修改了源文件,则在达到此TTL之前,不会回收为旧版本分配的内存。设置为零可禁用此功能。

我们收到消息“GC缓存条目'%s'(dev =%d ino =%d)在gc-list上为%d秒”或“GC缓存条目'%s'在gc-list上为% d秒“在这种情况下:

(gc_sec > cache->gc_ttl) && (dead->value->ref_count > 0)

第一个条件意味着,项目之后被删除,然后是apc.gc_ttl秒,并且它仍然在垃圾收集器列表中。秒条件意味着,项目仍然被引用。

e.g。当过程意外死亡时,参考不会减少。第一个apc.ttl秒在APC缓存中处于活动状态,然后被删除(此项目没有下一个命中)。现在项目在垃圾收集器列表(GC)上,并且apc.gc_ttl超时正在运行。当apc.gc_ttl小于(now - item_deletion_time)时,会写入警告并完全刷新项目。

尝试检查您的日志(Web服务器,php,系统/内核)是否存在严重错误,例如: php,web server segfault。