Internal server error when making polls

I’m getting an internal server error when making topics and posts with polls in them on my instance. The topic/post still gets created but the composer content doesn’t get cleared.

On testing it doesn’t seem to be happening here - I tried on safe mode with only official plugins on in my instance and it’s still happening though.

Which plugin is in charge of creating polls - not seeing one in the list? When I go to safe mode with everything off the poll option disappears all together.

EDIT: Also seems to be working properly on try.discourse with only official plugins available. What reasons would there be for the safe mode behavior there and on my instance to be different?

Anything happening in the logs?

1 Like
ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_polls_on_post_id_and_name"
DETAIL:  Key (post_id, name)=(74475, poll) already exists.
: INSERT INTO "polls" ("post_id", "created_at", "updated_at") VALUES (74475, '2019-05-31 01:11:30.464491', '2019-05-31 01:11:30.464491') RETURNING "id")
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/patches/db/pg.rb:72:in `async_exec_params'
Failed to handle exception in exception app middleware : PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_polls_on_post_id_and_name"
DETAIL:  Key (post_id, name)=(74475, poll) already exists.
: INSERT INTO "polls" ("post_id", "created_at", "updated_at") VALUES (74475, '2019-05-31 01:11:30.464491', '2019-05-31 01:11:30.464491') RETURNING "id"
1 Like

Just realized that polls are part of core and not a plugin. Doesn’t that mean that the poll option should appear in safe-mode with everything off, or am I misunderstanding how safe mode works?

Polls are added through the Poll plugin. It is one of a few plugins that comes bundled with Discourse. You can see those plugins here: discourse/plugins at master · discourse/discourse · GitHub.

To enter safe-mode, but keep the poll plugin enabled, deselect ‘Disable all plugins’ and make sure that ‘Disable unofficial plugins’ is selected when you enter safe-mode.

1 Like

Mmm I tried that. If the error is happening in safe mode with only official plugins does it imply that it has to be one of the official plugins I have causing the error? I’m mainly struggling because I get the error in safe mode with only official plugins on my instance but not on try.discourse.

From looking at the error message you have posted, it seems that the problem is with the post on your site with the id 74475. There are probably two polls in the post with the same name.

You could try finding that post by entering your rails console and then run:

Post.find(74475)

See if there are two polls in the post’s raw field that have the same name.

5 Likes

The cause for this was one of our custom plugins. It’s somehow effecting the site even through safe mode.

3 Likes

Server side changes in plugins cannot be disabled via safe mode.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.