artemp/trac2github — Issue #785: Shape plugin keeps stale references to deleted files
Author: artemp
Created: 2011-10-09 20:50:57+00:00
State: open
Labels: Core_Library

Mapnik (trunk) seems to keep shapefiles open once it finishes with them which causes stale data to be rendered if the file is deleted and replaced with another one with the same name in the meantime. lsof confirms it:

{{{
# After rendering isocronas.shp:
sigym@sigym-staging2:~$ md5sum /var/local/sigym/ctxs/propag_luis_k1c2dk/isocronas.shp
7649e466bc4a8ff01d370de569a1fa87 /var/local/sigym/ctxs/propag_luis_k1c2dk/isocronas.shp
# set ISOCRONAS_INODE to the inode of this file retrieved with stat
sigym@sigym-staging2:~$ lsof | grep $ISOCRONAS_INODE
apache2 6614 sigym mem REG 202,6 68204 3132969133 /var/local/sigym/ctxs/propag_luis_k1c2dk/isocronas.shp
# some process modifies isocronas.shp...
md5sum /var/local/sigym/ctxs/propag_luis_k1c2dk/isocronas.shp
285b592e4f0130750e99e8ba88057107 /var/local/sigym/ctxs/propag_luis_k1c2dk/isocronas.shp
sigym@sigym-staging2:~$ lsof | grep $ISOCRONAS_INODE
apache2 6614 sigym DEL REG 202,6 3132969133 /var/local/sigym/ctxs/propag_luis_k1c2dk/isocronas.shp
# notice how apache2 still refers to the old and deleted file
}}}

If apache is restarted then the correct shapefile is rendered. This regression was introduced somewhen after r2344 but I can't find the exact revision. Any clues?