Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🍀 Four kinds of init error #54

Merged
merged 1 commit into from
Sep 29, 2022
Merged

Conversation

duncanjbrown
Copy link
Contributor

@duncanjbrown duncanjbrown commented Sep 28, 2022

4️⃣ error conditions we discovered during recent rollout in Publish and Apply CI pipelines.

  • ActiveRecord::SchemaMigrations table is being considered for dfe-analytics (ignore it)
  • discovering migrations pending on dfe-analytics init
  • discovering missing database connection when database not present, also on init
  • loading models (in init) before connecting to DB

The final example is important because some contexts which lack db connections (eg asset precompilation) also don't provide all necessary eg ENV vars which would be required were we loading the whole app (which this init process does).

So discover early if we have no database (call ActiveRecord::Base.connection). & if anything happens during Fields.check! catch that too. Log lines will tell us if we're bailing for want of a DB or for want of a migration. (There's no point in running check! if migration yet to run).

@duncanjbrown duncanjbrown changed the title Recover from three (!) kinds of init error Recover from four (!) kinds of init error Sep 28, 2022
@duncanjbrown duncanjbrown changed the title Recover from four (!) kinds of init error 🍀 Four kinds of init error Sep 28, 2022
@duncanjbrown duncanjbrown force-pushed the test-migration-recovery branch 2 times, most recently from ba6f618 to 592bdd1 Compare September 29, 2022 07:08
Copy link
Contributor

@misaka misaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

- ActiveRecord::SchemaMigrations and internal_metadata tables are being considered for dfe-analytics (ignore them)
- discovering migrations pending on dfe-analytics init no longer bails
  pre-emptively
- discovering missing database connection when database not present,
  also on init, also no longer bails pre-emptively
- don't eager load unless we've got a database connection

The final example is important because some contexts which lack db
connections (eg asset precompilation) also don't provide all necessary
eg ENV vars which would be required were we loading the whole app (which
this init process does).

So discover early if we have no database (call
ActiveRecord::Base.connection). & if anything happens during
Fields.check! catch that too. Log lines will tell us if we're bailing
for want of a DB or for want of a migration. (There's no point in
running check! if migration yet to run).
@duncanjbrown duncanjbrown force-pushed the test-migration-recovery branch from 592bdd1 to 4e2e86b Compare September 29, 2022 11:01
@duncanjbrown duncanjbrown merged commit cc45022 into main Sep 29, 2022
@duncanjbrown duncanjbrown deleted the test-migration-recovery branch September 29, 2022 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants