Delayed columndropper issues

AI-generated summary

Users are experiencing rare but painful issues with Discourse’s delayed column dropping mechanism, particularly when exporting/importing databases or attaching new databases in multisite setups. These issues cause missing triggers or PG::UndefinedColumn errors until the delayed drops execute after an hour. RGJ asks if there’s a way to manually force the columndropper to run, suggesting it would work around the problems. gerhard offers a workaround by tricking the system into thinking the migration ran over an hour ago, and notes that the system is slated to change soon via this PR. codinghorror suggests tgxworld or sam comment, and sam confirms a new system will be introduced in the next few weeks to resolve these issues, with an announcement to follow on Meta. david links to the announcement post: Introducing Post-Deployment Migration.

We’ve ran into a few fights with the delayed column dropping mechanism lately. These are rare issues but they cause a lot of pain, relatively speaking.

The question is : is there any way to manually force the columndropper to run?

Details of the issues in case anyone is interested:

  • run migrations, then within an hour export the database and try to import it elsewhere. The import will fail because the required triggers in the discourse_functions schema will not exist on the new host.
  • import or attach a new database into a multisite. The migrations will run but the columns will not drop, causing PG::UndefinedColumn errors and causing Discourse to step in and clear the activerecord cache. This keeps on happening for one hour until the delayed drops are executed.

Being able to force the delayed drops to run would solve work around all those issues.

You could trick the system into believing that the first migration ran more than one hour ago.

BTW: This is going to change soon: FEATURE: Post deployment migrations. by tgxworld · Pull Request #6406 · discourse/discourse · GitHub

Maybe @tgxworld or @sam could comment, as they have time.

Our plan is to introduce a new system that is not subject to these issues in the next few weeks, we will announce it on meta when ready