TheEssem / mastodon

Chuckya, a glitch-soc fork used on wetdry.world

Home Page:https://wetdry.world/@chuckya

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Notifications return HTTP 500: column notifications.filtered does not exist

StephanStanisic opened this issue · comments

Steps to reproduce the problem

  1. Open mastodon
  2. Click notifications
  3. Error 500 happens and no notifications are displayed

Expected behaviour

Notifications are shown :)

Actual behaviour

No notifications are shown :(

Detailed description

I'm running mastodon in docker and since I've last updated notifications have been broken. Whenever I open the notifications tab, it returns with a 500:

image

The response in devtools seems to be the generic 500 page.

image

When I look into the logs, it seems there are some issues with the database:

web_1        | F, [2024-05-07T11:47:58.005251 #20] FATAL -- : [892d8943-8d90-4ddc-9e5e-5ecbcb796395]                           
web_1        | [892d8943-8d90-4ddc-9e5e-5ecbcb796395] ActiveRecord::StatementInvalid (PG::UndefinedColumn: ERROR:  column notifications.filtered does not exist                                                                                               
web_1        | LINE 1: ...s"."id" = "notifications"."from_account_id" WHERE "notificat...                                      
web_1        |                                                              ^                                                  
web_1        | ):                                                                                                              
web_1        | [892d8943-8d90-4ddc-9e5e-5ecbcb796395]                                                                          
db_1         | 2024-05-07 12:14:01.899 UTC [532] ERROR:  relation "notification_policies" does not exist at character 523
db_1         | 2024-05-07 12:14:01.899 UTC [532] STATEMENT:  SELECT a.attname, format_type(a.atttypid, a.atttypmod),
db_1         |         pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
db_1         |         c.collname, col_description(a.attrelid, a.attnum) AS comment,
db_1         |         attidentity AS identity,
db_1         |         attgenerated as attgenerated
db_1         |    FROM pg_attribute a
db_1         |    LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
db_1         |    LEFT JOIN pg_type t ON a.atttypid = t.oid
db_1         |    LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
db_1         |   WHERE a.attrelid = '"notification_policies"'::regclass
db_1         |     AND a.attnum > 0 AND NOT a.attisdropped
db_1         |   ORDER BY a.attnum
db_1         | 

I do have backups, so I can roll back but I'm a bit hesitant that that'll just bork federation. Some migration must have gone wrong somewhere, does anyone know where to look?

Mastodon instance

fedi.steph.tools

Mastodon version

v4.3.0-nightly.2024-05-07+chuckya

Technical details

docker-compose.yml
version: '3'
services:
  db:
    restart: always
    image: 'postgres:14-alpine'
    shm_size: 256mb
    networks:
      - internal_network
    healthcheck:
      test:
        - CMD
        - pg_isready
        - '-U'
        - postgres
    volumes:
      - './postgres14:/var/lib/postgresql/data'
    environment:
      - POSTGRES_PASSWORD=xxx
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
  redis:
    restart: always
    image: 'redis:7-alpine'
    networks:
      - internal_network
    healthcheck:
      test:
        - CMD
        - redis-cli
        - ping
    volumes:
      - './redis:/data'
  web:
    image: 'ghcr.io/theessem/mastodon:edge'
    restart: always
    env_file: .env.production
    command: bundle exec puma -C config/puma.rb
    networks:
      - external_network
      - internal_network
      - nginx-proxy
    healthcheck:
      test:
        - CMD-SHELL
        - 'wget -q --spider --proxy=off localhost:3000/health || exit 1'
    environment:
      - VIRTUAL_HOST=xxx
      - VIRTUAL_PORT=3000
      - LETSENCRYPT_HOST=xxx
    depends_on:
      - db
      - redis
    volumes:
      - './public/system:/mastodon/public/system'
  streaming:
    image: 'ghcr.io/theessem/mastodon-streaming:edge'
    restart: always
    env_file: .env.production
    command: node ./streaming
    networks:
      - external_network
      - internal_network
    healthcheck:
      test:
        - CMD-SHELL
        - >-
          wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health ||
          exit 1
    depends_on:
      - db
      - redis
networks:
  external_network: null
  internal_network:
    internal: true
  nginx-proxy:
    external: true                                                                                                                                                                                                                                                             
.env.production
# Generated with mastodon:setup on 2023-12-24 17:47:21 UTC

LOCAL_DOMAIN=xxx
SINGLE_USER_MODE=false
SECRET_KEY_BASE=xxx
OTP_SECRET=xxx
VAPID_PRIVATE_KEY=xxx
VAPID_PUBLIC_KEY=xxx

# I've added these since the last upgrade by running docker-compose run web bin/rails db:encryption:init
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=xxx
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=xxx
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=xxx

DB_HOST=db
DB_PORT=5432
DB_NAME=postgres
DB_USER=postgres
DB_PASS=xxx
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=
SMTP_SERVER=xxx
SMTP_PORT=465
SMTP_LOGIN=xxx
SMTP_PASSWORD=xxx
SMTP_FROM_ADDRESS=xxx

MAX_TOOT_CHARS=42069
MAX_PINNED_TOOTS=69
MAX_BIO_CHARS=42069
MAX_PROFILE_FIELDS=69
MAX_DISPLAY_NAME_CHARS=420
MAX_POLL_OPTIONS=69
MAX_POLL_OPTION_CHARS=42069

MAX_IMAGE_SIZE=838860800
MAX_VIDEO_SIZE=4194304000

MAX_EMOJI_SIZE=26214400
MAX_REMOTE_EMOJI_SIZE=26214400

The notification_policies table was introduced a couple of months ago with this migration. I'd suggest trying to run the migrations again.

Ah, it seems I'm just quite the dummy: I never ran the migration in the first place. Sorry! Running RAILS_ENV=production bundle exec rails db:migrate got everything working again. Thanks for the help!