Comments (10)
@fatkodima thank you for the reply and sorry for the delayed response.
Do you use schema cache on staging? 2. And is your application eager loaded on staging?
We don't use schema cache in production, and yes, the app is eager loaded on boot (config.eager_load = true
)
Today I will give a try with your changes, I'll let you know how it went!
from online_migrations.
Can you describe the steps to reproduce the issue? That behavior is a little weird, since columns
are cached in the model class - https://github.com/rails/rails/blob/4345e84587f4a6a92214a23ca3d85a403d9087df/activerecord/lib/active_record/model_schema.rb#L420-L423 and should be already loaded after the finalize_column_rename
was ran.
from online_migrations.
I haven't been able to reproduce it locally, unfortunately. This issue happened on our staging server when we executed various API test calls after the finalize_column_rename
migration. I tried to replicate the environment we have up there, but something is clearly different because I don't get the error what occurred there.
Sentry logged another similar error, but call stack didn't contain schema_cache.rb
in that case:
ActiveRecord::StatementInvalid
PG::UndefinedTable: ERROR: relation "organizations_column_rename" does not exist
LINE 5: WHERE indrelid = '"organizations_column_rename"'::...
^
PG::UndefinedTable
ERROR: relation "organizations_column_rename" does not exist
LINE 5: WHERE indrelid = '"organizations_column_rename"'::...
^
Crashed in non-app: activerecord (7.0.4.2) lib/active_record/connection_adapters/postgresql/database_statements.rb in exec
app/controllers/api_controller/base.rb in current_organization at line 64
app/controllers/api_controller/base.rb in append_info_to_payload at line 91
Called from: actionpack (7.0.4.2) lib/action_controller/metal/instrumentation.rb in ensure in block in process_action
lib/middleware/rewriter/middleware.rb in thread_safe_call at line 41
lib/middleware/rewriter/middleware.rb in call at line 25
Called from: sentry-rails (5.8.0) lib/sentry/rails/rescued_exception_interceptor.rb in call
lib/middleware/gcp_trace_middleware.rb in call at line 12
Called from: rack (2.2.6.2) lib/rack/method_override.rb in call
I could not run further tests yet because we did a rollback.
We didn't add the self.ignored_columns
(mentioned in #26) yet, but I guess that wouldn't help here because the table name is the problem here.
Please let me know if you have some further ideas. Otherwise, we'll retry the migration soon, hopefully I'll gather more info.
from online_migrations.
Thank you for the follow up!
It will definitely help if you could figure out the reproduction steps. But in either case, I will try to dive into it to find what would cause it.
from online_migrations.
Were you able to identify the problem?
- Do you use schema cache on staging? 2. And is your application eager loaded on staging?
from online_migrations.
So the problem is with caching, as you mentioned, I am 99% sure for this case.
What happened on staging: In rails, unless you are using schema cache, model's metadata (primary key, columns etc) is retrieved lazily on the first access of the model. The renamed_columns
was cached on the first access to some other model (not Organization
, in your case), probably User
when authenticating. And Organization
was not loaded yet. Then you ran finalize_column_rename
, which removed the VIEW and tried to access Organization
for the first time. Cached renamed_columns
still thinks that there is a VIEW there, but there isn't this time. So bam 💥
from online_migrations.
@fatkodima could you create a new build from these changes? I run into some issues with testing the pinned commit from github in our GCP environment.
from online_migrations.
@fatkodima UPDATE: I actually managed to make the pinned commit working, and it seems the changes fix the issue! 🙏Could you create a release from it? I'll run one more test with the final version.
from online_migrations.
Released a new version with this fix.
from online_migrations.
Awesome, thank you very much! ❤️
from online_migrations.
Related Issues (20)
- Error at renaming a column if config.active_record.enumerate_columns_in_select_statements is set to true HOT 5
- `add_not_null_constraint` does not quote column name in check constraint expression HOT 1
- `add_reference_concurrently` does not properly check for existence of foreign keys HOT 2
- `CommandChecker` seems to fail on indexes using expressions rather than columns HOT 3
- Difference in results between update_columns_in_batches and update_column_in_batches HOT 4
- Running more than one migration on same table HOT 2
- Attempting to update `pg_catalog` when changing type of not null column w/o a default HOT 5
- Ability to run custom cast logic in column type change HOT 7
- understanding background migrations HOT 3
- `finalize_column_type_change` fails with JSONB indexes
- Copying index when a JSONB index is present on a table is still broken HOT 6
- Dropping support for older ruby/rails HOT 1
- Index name too long error on finalize_column_type_change migration HOT 9
- Question on 'Adding multiple foreign keys': why does adding multiple FKeys block reads on all involved tables? HOT 7
- `add_reference_concurrently` doesn't check for mismatching reference column types
- Clarity on lock retry behaviour inside and outside transactions HOT 4
- Bad background migration behaviour when backfilling primary key id's HOT 2
- Clean up does not remove temporary indexes created HOT 4
- Should "Adding a foreign key" recommend two migrations? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from online_migrations.