@jacobvosmaer cache:clear gets triggered before db:migrate . I am suggesting to trigger cache:clear when db:migrate runs. Possibly patch release material.
@jacobvosmaerKamil commented: I think that this is causing the problems: https://gitlab.com/gitlab-org/gitlab-ce/commit/2e4a673cbc1a43532e8aa096e4ab5ca034b804f7. We don't invalidate the cache after doing migrations.
In compilation stage, that means that nothing is going to be executed and the code block is being stored for executing during convergence stage
Now we are in convergence stage and reconfigure is running chef-zero
Remote file is being executed and source placed to targed file if there are changes(checksum is running first)
All resources that are being executed via notify are queued to the end of the convergence run
bash resource in the definition is now being executed and the last command in that block is run db:migrate
because this action notifies service restart with :immediately that means that all dependent services will run right after the migration. This means, unicorn and sidekiq restarts will be run.
Now is the time to run cache:clear as this was the next item in the notify queue.
As far as this problem is considered, the run is done.
Lol, after writing it out this way, I think I know what happens and where it goes wrong. Because we are triggering cache:clear when gitlab.yml changes at this line, the run gets queued before db:migrate. Since chef doesn't queue the same service twice, this will sometimes run cache:clear before db:migrate, and other times in the correct order!
So we have cache:clear that gets triggered either when there is a change in gitlab.yml file, or during the upgrade(or both).
cache:clear in upgrade should take precedence I think.
Problem is, we cannot just add :immediately to the trigger in version file change because it will trigger before db:migrate.
Only way to ensure the order is to add :immediately to both db:migrate and cache:clear.
There is another way and that is to tie any db:migrate event with cache:clear. That might be a better solution. Basically what I've suggested at the beginning.
If I do this and set :immediately then the 2 notifications will be different for chef. Downside is that it will be run twice, first on gitlab.yml trigger and then on db:migrate. So it will be slow(ish).