Skip to content

Draft: POC: Reproducing schema_cache - dependent failures for gitlab-com/gl-infra/production#8264

Simon Tomlinson requested to merge run-tests-with-old-schema into master

What does this MR do and why?

Describe in detail what your merge request does and why.

This is a POC of injecting a stale schema cache to surface issues with schema cache inconsistencies.

It is set up to catch the error from gitlab-com/gl-infra/production#8264 (closed)

It persists a schema cache from before running post-migrations, then runs those post migrations. Then we run rspec and observe a failure.

I generated the yml files here with the following commands:

git co HEAD~2 # Checkout the commit before our commit-to-test. Would usually be HEAD~1 but I have an extra commit with the spec changes
bin/rails db:reset db:test:prepare # Get the database state from that commit
git co - # Go back to head
bin/rails db:migrate:status | grep down # Notice that we're missing both up and down migrations for the current commit
env SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails db:migrate # Run just the up migrations, similarly to how it happens in production
bin/rails db:schema:cache:dump # Dump the schema cache, it will be injected in specs
bin/rails db:migrate # Run post-deployment migrations now that we have the previous cache state
bin/rspec spec/models/plan_limits_spec.rb # Observe failures related to expecting the old column to still exist
## Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports