Add flock to check if database is in processing