Giter VIP home page Giter VIP logo

Comments (10)

popperur avatar popperur commented on May 26, 2024 2

@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.

fatkodima avatar fatkodima commented on May 26, 2024

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.

popperur avatar popperur commented on May 26, 2024

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.

fatkodima avatar fatkodima commented on May 26, 2024

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.

fatkodima avatar fatkodima commented on May 26, 2024

Were you able to identify the problem?

  1. Do you use schema cache on staging? 2. And is your application eager loaded on staging?

from online_migrations.

fatkodima avatar fatkodima commented on May 26, 2024

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.

popperur avatar popperur commented on May 26, 2024

@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.

popperur avatar popperur commented on May 26, 2024

@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.

fatkodima avatar fatkodima commented on May 26, 2024

Released a new version with this fix.

from online_migrations.

popperur avatar popperur commented on May 26, 2024

Awesome, thank you very much! ❤️

from online_migrations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.