comparison src/http/ngx_http_file_cache.c @ 4340:4533d7684e14

Cache: only complain on long locked entries. There have been multiple reports of cases where a real locked entry was removed, resulting in a segmentation fault later in a worker which locked the entry. It looks like default inactive timeout isn't enough in real life. For now just ignore such locked entries, and move them to the top of the inactive queue to allow processing of other entries.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 12 Dec 2011 10:49:14 +0000
parents 6f97afc238de
children 70ba81827472
comparison
equal deleted inserted replaced
4339:6f97afc238de 4340:4533d7684e14
1111 (void) ngx_hex_dump(p, fcn->key, len); 1111 (void) ngx_hex_dump(p, fcn->key, len);
1112 1112
1113 /* 1113 /*
1114 * abnormally exited workers may leave locked cache entries, 1114 * abnormally exited workers may leave locked cache entries,
1115 * and although it may be safe to remove them completely, 1115 * and although it may be safe to remove them completely,
1116 * we prefer to remove them from inactive queue and rbtree 1116 * we prefer to just move them to the top of the inactive queue
1117 * only, and to allow other leaks
1118 */ 1117 */
1119 1118
1120 ngx_queue_remove(q); 1119 ngx_queue_remove(q);
1121 ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node); 1120 fcn->expire = ngx_time() + cache->inactive;
1121 ngx_queue_insert_head(&cache->sh->queue, &fcn->queue);
1122 1122
1123 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, 1123 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
1124 "ignore long locked inactive cache entry %*s, count:%d", 1124 "ignore long locked inactive cache entry %*s, count:%d",
1125 2 * NGX_HTTP_CACHE_KEY_LEN, key, fcn->count); 1125 2 * NGX_HTTP_CACHE_KEY_LEN, key, fcn->count);
1126 } 1126 }