Discourse appears to be broken with Postgres 10

(Darix) #1


== Seed from /srv/www/vhosts/discourse/db/fixtures/003_post_action_types.rb
 - PostActionType {:id=>1, :name_key=>"bookmark", :is_flag=>false, :position=>1}
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column "increment_by" does not exist
LINE 1: ...types_id_seq', (SELECT GREATEST(MAX("id")+(SELECT increment_...
:             SELECT setval('public.post_action_types_id_seq', (SELECT GREATEST(MAX("id")+(SELECT increment_by FROM public.post_action_types_id_seq), (SELECT min_value FROM public.post_action_types_id_seq)) FROM "post_action_types"), false)
(eval):1:in `block (2 levels) in run_file'
/srv/www/vhosts/discourse/lib/tasks/db.rake:26:in `block in <top (required)>'
/usr/bin/rake.ruby2.4:22:in `load'
/usr/bin/rake.ruby2.4:22:in `<top (required)>'
/usr/bin/bundle.ruby2.4:22:in `load'
/usr/bin/bundle.ruby2.4:22:in `<main>'
PG::UndefinedColumn: ERROR:  column "increment_by" does not exist
LINE 1: ...types_id_seq', (SELECT GREATEST(MAX("id")+(SELECT increment_...
(eval):1:in `block (2 levels) in run_file'
/srv/www/vhosts/discourse/lib/tasks/db.rake:26:in `block in <top (required)>'
/usr/bin/rake.ruby2.4:22:in `load'
/usr/bin/rake.ruby2.4:22:in `<top (required)>'
/usr/bin/bundle.ruby2.4:22:in `load'
/usr/bin/bundle.ruby2.4:22:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Beginners Guide to Install Discourse on macOS for Development
How to pg_upgrade on docker postgres?
(Sam Saffron) #2

We are not seeing it in our official install, my guess is that this is somehow postgres 10 related.

What version of pg are you using?

(Darix) #3

oh right good point … i did switch to postgresql 10 after 1.9.0.beta12~git0.7ed522c890-7.1.

(Sam Saffron) #4

Well, we have not yet done the work to get Discourse to work with PG 10, we will get there.

(Darix) #5

maybe the code should be guarded with somethin like

@conn = PG.connect(args)
if @conn.server_version >= 100000
  # error out and exit cleanly

And maybe it should be documented that pg10 isnt supported yet.

(Sam Saffron) #6

I would much rather spending the time getting Discourse to work properly on PG 10

(Darix) #7

sure. :slight_smile:

I just remembered that it was really easy to check the pg version (used it in my script for the last pg security update).

if you need any PG 10 testers feel free to poke me. I was beta testing pg 10 on a less important host for a while and jumped mg production machine on the day after the release.

(Darix) #8

this could even be a activerecord problem no?

(Jeff Atwood) #9

I believe @tgxworld was going to take a look.

(Darix) #10

opened an issue here: postgresql 10 breaks sequence handling · Issue #122 · mbleigh/seed-fu · GitHub

(Ryan Bigg) #11

There was a similar issue with the sequel gem recently, which was fixed by this commit: Make Database#reset_primary_key_sequence work on PostgreSQL 10+ · jeremyevans/sequel@8370980 · GitHub. Likely the same kind of fix would need to be done on seed-fu.

(Darix) #12

there is already PR for seed-fu pending Support PostgreSQL 10 by ppworks · Pull Request #121 · mbleigh/seed-fu · GitHub

Just tested it here and the rake tasks complete again.

(Jeff Atwood) #13

Good to know, can we merge in those updated dependencies @tgxworld?

(Sam Saffron) #14

It is not merged in yet, I actually think we should just pull in the seed fu functionality we need into core, this keeps on breaking rails upgrade after rails upgrade and now after pg upgrades, there is like 50 lines of code we care about in this gem, maybe less.

(Jeff Atwood) #15

Up to you, I would prefer to do the simple / less work thing in this case though.

(Darix) #16

JFYI: postgresql 10 breaks sequence handling · Issue #122 · mbleigh/seed-fu · GitHub

bumping seed-fu would allow you to run on postgresql 10. then you could also remove the warning again. (it was added in the OSX docs e.g.)

(Alan Tan) #17

Seed-fu has been updated with support for PG10

We’ve still yet to test Discourse fully with PG 10 but that will be happening soon.

(Darix) #18

From my experience i can tell you … It works fine :slight_smile:

But sure more testing is better.