wrong number of arguments (4 for 3)
Strange error. Using jRuby 9.1K with Rails version 5.1 and activerecord-jdbcmysql-adapter version 51. Was working perfectly yesterday while I suddenly get this error today:
Caused by:
ArgumentError: wrong number of arguments (4 for 3)
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-jdbc-adapter-51.1-java/lib/arjdbc/mysql/adapter.rb:12:in `initialize'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-jdbc-adapter-51.1-java/lib/arjdbc/jdbc/callbacks.rb:12:in `new'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-jdbc-adapter-51.1-java/lib/arjdbc/jdbc/connection_methods.rb:12:in `jdbc_connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-jdbc-adapter-51.1-java/lib/arjdbc/mysql/connection_methods.rb:91:in `mysql_connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/connection_handling.rb:88:in `connection'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/schema_migration.rb:20:in `table_exists?'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/schema_migration.rb:24:in `create_table'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/migration.rb:1125:in `initialize'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/migration.rb:1007:in `up'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/migration.rb:985:in `migrate'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/Users/simonyu/.rvm/gems/[email protected]/gems/activerecord-5.1.6/lib/active_record/railties/databases.rake:58:in `block in (root)'
/Users/simonyu/.rvm/gems/jruby-9.1.13.0@global/gems/rake-12.3.1/exe/rake:27:in `<main>'
/Users/simonyu/.rvm/gems/[email protected]/bin/jruby_executable_hooks:15:in `<main>'
I am getting the same error on one of my servers. Here is the full stacktrace of rake db:migrate in my case.
rake aborted!
ActiveRecord::JDBCError: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
arjdbc/jdbc/RubyJdbcConnection.java:551:in `initialize'
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/abstract/core.rb:19:in `initialize'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:54:in `initialize'
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/abstract/statement_cache.rb:21:in `initialize'
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/mysql/adapter.rb:35:in `initialize'
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/jdbc/callbacks.rb:12:in `new'
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/jdbc/connection_methods.rb:14:in `jdbc_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/mysql/connection_methods.rb:91:in `mysql_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:809:in `new_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `checkout_new_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:832:in `try_to_checkout_new_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:793:in `acquire_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:521:in `checkout'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:380:in `connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1008:in `retrieve_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:90:in `connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/railties/databases.rake:60:in `block in (root)'
/usr/share/rvm/gems/jruby-9.1.17.0@global/gems/rake-12.3.1/exe/rake:27:in `<main>'
Caused by:
ArgumentError: wrong number of arguments (4 for 3)
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/mysql/adapter.rb:12:in `initialize'
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/jdbc/callbacks.rb:12:in `new'
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/jdbc/connection_methods.rb:12:in `jdbc_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/bundler/gems/activerecord-jdbc-adapter-5fd43b354ffc/lib/arjdbc/mysql/connection_methods.rb:91:in `mysql_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:809:in `new_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `checkout_new_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:832:in `try_to_checkout_new_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:793:in `acquire_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:521:in `checkout'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:380:in `connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1008:in `retrieve_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:90:in `connection'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/usr/share/rvm/gems/jruby-9.1.17.0/gems/activerecord-5.2.1/lib/active_record/railties/databases.rake:60:in `block in (root)'
/usr/share/rvm/gems/jruby-9.1.17.0@global/gems/rake-12.3.1/exe/rake:27:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
@m-andreas in jdbc/connection_methods.rb:12 we have this logic I introduced because not all adapters had been fully converted to AR5. That is no longer true (for release mysql,sqlite3,postgresql) and it can be removed; but I am really confused by rescue ArgumentError is not rescuing your ArgumentError.
I think I am going to just remove this logic now as it is outdated but I am super confused how this could break?
@m-andreas I removed that 4 arg call from all branches and we should not see this error again but I cannot actually observe the reported behavior.
@m-andreas @simonykq can either of you try from 51-stable or 52-stable branch and see if things work?
@m-andreas @simonykq ping. Hoping someone can tell me if latest commit in removing this 4 to 3 arg rescue logic has removed the underlying problem.
Marking fixed via #891. Re-open if you see a problem. A new release should be out soon as we have several fixes stacked up.