Discourse appears to be broken with Postgres 10

discourse-1.9.0.beta12~git20.14b1736c74-9.1.noarch

== 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)
1 Like

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?

1 Like

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

2 Likes

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

maybe the code should be guarded with somethin like

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

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

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

4 Likes

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.

4 Likes

this could even be a activerecord problem no?

I believe @tgxworld was going to take a look.

4 Likes

opened an issue here: https://github.com/mbleigh/seed-fu/issues/122

2 Likes

There was a similar issue with the sequel gem recently, which was fixed by this commit: http://github.com/jeremyevans/sequel/commit/8370980b12f59d5439344d4de89d4552f05a3d13. Likely the same kind of fix would need to be done on seed-fu.

3 Likes

there is already PR for seed-fu pending https://github.com/mbleigh/seed-fu/pull/121

Just tested it here and the rake tasks complete again.

2 Likes

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

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.

2 Likes

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

JFYI: https://github.com/mbleigh/seed-fu/issues/122#issuecomment-346783243

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.)

1 Like

Seed-fu has been updated with support for PG10

https://github.com/discourse/discourse/commit/c8157f6b0764f616c394b19bbccad843c859b201

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

6 Likes

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

But sure more testing is better.