Undefined column 'boomarks.post_id' after update

After updating my discourse installation from 2.9.0.beta9 to 2.9.0.beta11, the installation completely froze as all calls listing topics suddenly return column bookmarks.post_id does not exist

I’ve tracked down the commit dropping this column to f8939bd294ff6822a61fb653b44a4df351321f54 which drops the column from the database. The issue also occurs in safe mode so I do not think a plugin is at fault.

Stacktrace:

app/models/topic_list.rb:84:in `topics'
app/serializers/suggested_topics_mixin.rb:17:in `include_suggested_topics?'
(eval):6:in `_fast_attributes'
app/controllers/topics_controller.rb:1199:in `block (2 levels) in perform_show_response'
app/controllers/topics_controller.rb:1194:in `perform_show_response'
app/controllers/topics_controller.rb:169:in `show'
app/controllers/application_controller.rb:413:in `block in with_resolved_locale'
app/controllers/application_controller.rb:413:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:366:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:202:in `call'
Failed to handle exception in exception app middleware : ActiveRecord::StatementInvalid : PG::UndefinedColumn: ERROR:  column bookmarks.post_id does not exist
LINE 1: ...marks"."bookmarkable_type" FROM "bookmarks" WHERE "bookmarks...

Any help is appreciated

1 Like

I’ve fixed it for now by adding back the column to the database but I think that the root cause should be fixed instead :grimacing:

Am happy to drop the column again if you need further diagnostics

2 Likes

I am very confused, this has been an ignored column for quite a while.

@martin needed to remove it, it is not longer something we use.

Do you have a custom setup? Are there any special plugins involved? Was the error a “transitional” thing that happened when the migration ran? (I would expect this error possibly during live update from the web interface under outlier conditions)

1 Like

Faced the same issue while updating today. Adding back the post_id column helped fix it.

Steps:

  1. enter the discourse container
./launcher enter app
  1. Enter psql
sudo -u postgres psql discourse
  1. Add back the post_id column in the bookmarks table
ALTER TABLE bookmarks ADD COLUMN post_id int;
2 Likes

I’m using the default docker setup with a few plugins, but I could reproduce it in safe mode. Also, the stack traces do not contain any obvious references to plugins.

Updated using a full rebuild without any errors during the migration. Also tried re-running the migrations which reported no changes.

1 Like

I’m confused…

Can you try

  1. Removing the column again
  2. Restarting your container ./launcher restart app

Does the error persist?

Adding the column should not be needed.

1 Like

I’ve already tried restarting when first encountering the error. Just to verify, I did it again and the error persists. Might a theme component be causing issues? The topic-list-preview theme component was one of the similarities I’ve identified between our instance and krita-artists.org mentioned here: Oops. The software powering this discussion forum encountered an unexpected problem - #10 by raghukamath

2 Likes

A theme component is very unlikely to trigger this, what is the full list of plugins you use?

Would you mind trying one more time?

1 Like

I found the issue :partying_face: It was a plugin issue after all :sweat_smile:

Previous versions of the Topic List Previews Theme Component were distributed as a plugin and then split up into a plugin and a theme component. During this initial split users were instructed to load the plugin from a new branch. However, as time went on, the branch got abandoned and was no longer maintained. After switching to the maintained fork, everything works again.

6 Likes