XWIKI-9758: Race condition when upgrading an instance previously configured with "Upgrade all wikis"

(cherry picked from commit dacc8de2325cb9a8c5dfb4635fe854c203cc5549)