Glance cache uses LRU strategy for cache pruning. It does so by keeping track of the last accessed time on cached images. While the xattr driver uses the last accessed time reported by the underlying filesystem, the sqlite driver keeps track of its own last accessed time. The sqlite driver doesn't set [1] the last accessed time the very first time an image is added to cache. It updates [2] the last accessed time for every subsequent access of the image from cache. This behavior makes the newly cached images susceptible to cache pruning over older images because they don't have a last accessed time set[3]. So, whenever the pruner runs, it'll prune the newly cached images first and then look for older images.
This bug may reduce Glance image download performance under certain traffic patterns as images will be served from Swift instead of image cache.
[1] https://github.com/openstack/glance/blob/bb59c33ffcc6e1cde23c93bb25d38846e84c2cb9/glance/image_cache/drivers/sqlite.py#L324
[2] https://github.com/openstack/glance/blob/bb59c33ffcc6e1cde23c93bb25d38846e84c2cb9/glance/image_cache/drivers/sqlite.py#L376
[3] https://github.com/openstack/glance/blob/bb59c33ffcc6e1cde23c93bb25d38846e84c2cb9/glance/image_cache/drivers/sqlite.py#L280-L281
Fix proposed to branch: master /review. openstack. org/169219
Review: https:/