Get a lock before writing to a data file.
Get a lock before regenerating a sparse index.