Only run the manager.upgrade event if needed.
Make sure there is a database lock before running the upgrade event.