Use a filelock to prevent running flush_queue concurrently