jruby / activerecord-jdbc-adapter

JRuby's ActiveRecord adapter using JDBC.
BSD 2-Clause "Simplified" License
462 stars 387 forks source link

Rails 5.1 Breaks postgres adapter #780

Closed mattclar closed 6 years ago

mattclar commented 7 years ago

I get this error on startup of my server after upgrading to rails 5.1 I presume its from an activerecord change somewhere

web_1 | Bundler::GemRequireError: There was an error while trying to load the gem 'activerecord-jdbcpostgresql-adapter'.
web_1 | Gem Load Error is: uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnDefinition
web_1 | Backtrace for gem load error is:
web_1 | /usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-395443eef4db/lib/arjdbc/postgresql/adapter.rb:1527:in `<class:PostgreSQLAdapter>'
web_1 | /usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-395443eef4db/lib/arjdbc/postgresql/adapter.rb:1490:in `<module:ConnectionAdapters>'
web_1 | /usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-395443eef4db/lib/arjdbc/postgresql/adapter.rb:1478:in `<main>'
web_1 | /usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-395443eef4db/lib/arjdbc/postgresql.rb:1:in `<main>'
web_1 | /usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-395443eef4db/lib/arjdbc/postgresql.rb:2:in `<main>'
web_1 | /usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-395443eef4db/activerecord-jdbcpostgresql-adapter/lib/activerecord-jdbcpostgresql-adapter.rb:1:in `require'
web_1 | /usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-395443eef4db/activerecord-jdbcpostgresql-adapter/lib/activerecord-jdbcpostgresql-adapter.rb:1:in `block in (root)'
web_1 | /usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-395443eef4db/activerecord-jdbcpostgresql-adapter/lib/activerecord-jdbcpostgresql-adapter.rb:3:in `each'
web_1 | /usr/local/bundle/bundler/gems/activerecord-jdbc-adapter-395443eef4db/activerecord-jdbcpostgresql-adapter/lib/activerecord-jdbcpostgresql-adapter.rb:3:in `block in (root)'
web_1 | /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler/runtime.rb:1:in `each'
web_1 | /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler/runtime.rb:1:in `(root)'
web_1 | /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler/runtime.rb:91:in `require'
web_1 | /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in `<main>'
web_1 | /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `require'
web_1 | /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in `block in require'
web_1 | /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler.rb:106:in `tap'
web_1 | /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler.rb:106:in `require'
web_1 | /usr/src/app/config/application.rb:9:in `(root)'
web_1 | /usr/local/bundle/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:1:in `(root)'
web_1 | /usr/local/bundle/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:128:in `perform'
web_1 | /usr/local/bundle/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:125:in `perform'
web_1 | /usr/local/bundle/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
web_1 | /usr/local/bundle/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `<main>'
web_1 | bin/rails:4:in `require'
web_1 | bin/rails:4:in `<main>'
web_1 | Bundler Error Backtrace:
web_1 | 
web_1 |   block in require at /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler/runtime.rb:95
web_1 |               each at org/jruby/RubyArray.java:1733
web_1 |   block in require at /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler/runtime.rb:86
web_1 |               each at org/jruby/RubyArray.java:1733
web_1 |            require at /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler/runtime.rb:75
web_1 |            require at /opt/jruby/lib/ruby/gems/shared/gems/bundler-1.13.7/lib/bundler.rb:106
web_1 |             <main> at /usr/src/app/config/application.rb:9
web_1 |            require at org/jruby/RubyKernel.java:961
web_1 |    block in (root) at /usr/local/bundle/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:1
web_1 |                tap at org/jruby/RubyKernel.java:1747
web_1 |            perform at /usr/local/bundle/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:128
web_1 |            perform at /usr/local/bundle/gems/railties-5.1.0.rc1/lib/rails/commands/server/server_command.rb:125
web_1 |                run at /usr/local/bundle/gems/thor-0.19.4/lib/thor/command.rb:27
web_1 |     invoke_command at /usr/local/bundle/gems/thor-0.19.4/lib/thor/invocation.rb:126
web_1 |           dispatch at /usr/local/bundle/gems/thor-0.19.4/lib/thor.rb:369
web_1 |            perform at /usr/local/bundle/gems/railties-5.1.0.rc1/lib/rails/command/base.rb:63
web_1 |             <main> at /usr/local/bundle/gems/railties-5.1.0.rc1/lib/rails/command.rb:44
web_1 |            require at org/jruby/RubyKernel.java:961
web_1 |             <main> at bin/rails:4
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/43534123-rails-5-1-breaks-postgres-adapter?utm_campaign=plugin&utm_content=tracker%2F136963&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F136963&utm_medium=issues&utm_source=github).
kares commented 7 years ago

well ar 5.0 (still) isnt really supported/tested much ... as far as I know. thus not sure if there was smt to break :) but thanks for the report. recommend you try take a look at it yourself as there isnt much activity besides patch merging/maintenance around here.

bencarsal commented 7 years ago

I change this line in file arjdbc/jdbc.rb, please review this: https://github.com/jruby/activerecord-jdbc-adapter/compare/rails-5...bencarsal:patch-1

keithrbennett commented 7 years ago

@kares Can you help me understand why this is not a serious issue? I may be missing something, but doesn't it make JRuby unusable with Rails 5.1 and Postgres?

kares commented 7 years ago

@keithrbennett simply because there's no one to do it (personally trying to do maintenance of the stable line and some house-keeping/perf.work on master when I have time, the rest of JRuby team already tried doing the AR 5.x update but did not yet deliver fully) ... there are attempts but its a task that needs focused men power (AR-JDBC supports a lot of adapters and also accumulated some debt). have tried asking for support to speed things up (personally have no need to chase the Rails 5.x dragon yet) but no one cared much.

simply said this is OSS. its a bit demotivating explaining this over-and-over (esp. when someone expects volunteers to have a certain sense of "seriousness") and communicating false hopes over private e-mail with occasional "supporters" that always go silent :disappointed_relieved:

keithrbennett commented 7 years ago

Firstly, thank you for the time and effort you've contributed. It's totally understandable that you have your own life and priorities, and are already contributing heavily, and no one can fault you for that. I was not complaining, I was just confused because I inferred that you believed that the issue was not important. Now I understand that you are not questioning the importance but just explaining that there is not enough manpower to address the issue. Thanks also for the explanation.

rsov commented 7 years ago

I'm just curious as to why the rails team feels the need to change everything on each revision. Like sure, I read the rails doctrine and agree with their "Progress over stability" moto. However in the real world its painful that they change everything.

The as400 system at my workplace has been around longer than I've been alive but since everything is backwards compatible, we don't have to worry about updates breaking stuff. Trying to explain to our boss why it takes us so much time and effort to upgrade rails is always an uphill battle

fmluizao commented 6 years ago

How can I help to support rails 5? I'm willing to help, but don't want to mess with java if possible =P

enebo commented 6 years ago

This is sort of represented by our new label and targetted milestone but I left it open to resolve when 51.0 is released.

Dee-2015 commented 6 years ago

Could it be that RoR 5.1 doesn't work with postgresl > 10 ? I found this page due to the fact that my rspecs starting to fail with a PG 10 database. They work fine with PG 9.5.10 version.

rdubya commented 6 years ago

The original issue is happening because the gem isn't compatible with Rails 5.1 yet. It should be fixed with this commit: https://github.com/jruby/activerecord-jdbc-adapter/commit/3ad4910a5c065f73e49bca074e5ac4a05978a4c9

kares commented 6 years ago

@rdubya feel free to close it - if you feel like there isn't much value here for the (pending) 5.1 work here

rdubya commented 6 years ago

Sounds good. I'll close it for now, it should be fixed with the 51 release.

abevoelker commented 6 years ago

I'm still encountering this issue; I see there are 51.0 versions released for gems activerecord-jdbc-adapter, activerecord-jdbcmysql-adapter and activerecord-jdbcsqlite3-adapter, but activerecord-jdbcpostgresql-adapter is still on 50.0 - would it be possible to get a 51.0 release for the Postgres adapter, or is something else holding it up? Thank you!

enebo commented 6 years ago

@abevoelker there was a lot of broken tests from 50 to 51 on postgresql. I think several of those have been fixed now so we should consider that even if it is not perfect.

risinglf commented 6 years ago

@rdubya @enebo this issue still persists, right @abevoelker ?

Why the 51 gem is not yet available?

Thanks a lot for your work

michaeldbarry commented 6 years ago

@rdubya ++ for the patch ... it almost worked for me but I was also getting a

NameError: undefined local variable or method `max_identifier_length' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

error. I just

alias_method :max_identifier_length, :table_alias_length

in lib/arjdbc/postgresql/adapter.rb and all seems wll.

rdubya commented 6 years ago

@risinglf I'm currently (slowly) trying to patch up some more issues with 50 that I'm going to port over to 51 and then we'll likely be able to release a 51.0 for postgres.

@michaeldbarry I haven't seen that issue, what version of rails and adapter gem are you using? Could you make a new issue for it so I can keep track of it a little easier?

bgmat commented 6 years ago

Hi, I'm getting a similar error, when trying to run rake db:migrate (rails 5.1.5, jRuby 9.1.16.0). Bundler::GemRequireError: There was an error while trying to load the gem 'activerecord-jdbcpostgresql-adapter'. Gem Load Error is: uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Rails51Point

Is this the same issue?

rdubya commented 6 years ago

Hi @bgmat, we still haven't released a version of the postgres adapter that works with 5.1 yet, we are hopefully getting close though.

n-rodriguez commented 6 years ago

Hi there! Any news?