Having 2 ActiveRecord test failures on master: "Errors running test_postgresql" using pg 9.1

Hi all,

I’m working on an ActiveRecord contribution, and I seem to be set up to run tests properly, but I have 2 failures occurring when I run rake test from within /activerecord. I am running PostgreSQL 9.1, so perhaps there is currently a problem running tests against that?

Has anyone else tried running these tests using PostgreSQL 9.1, and if so, do you see the same failures I’m seeing? If this is a 9.1 problem, then I’ll be happy to investigate it as part of the contribution I’m working on, but I would first want to make sure that really is the problem I’m seeing, and it’s not caused by some other thing I’ve messed up with my configuration or process. Here is the failure output…

  1. Failure: test_eager_loading_with_conditions_on_join_model_preloads(EagerAssociationTest) [/Users/FileVault/stevej/Projects/rails/activerecord/test/cases/associations/eager_test.rb:1015]: 4 instead of 2 queries were executed. Queries: SELECT “authors”.* FROM “authors” INNER JOIN “posts” ON “posts”.“author_id” = “authors”.“id” INNER JOIN “comments” ON “comments”.“post_id” = “posts”.“id” WHERE (posts.title like ‘Welcome%’) SELECT COUNT() FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind in (‘v’,‘r’) AND c.relname = $1 AND n.nspname = ANY (current_schemas(false)) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull, a.atttypid, a.atttypmod FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = ‘“author_addresses”’::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum SELECT “author_addresses”. FROM “author_addresses” WHERE “author_addresses”.“id” IN (1). Expected: 2 Actual: 4
  2. Failure: test_custom_primary_key_on_new_record_should_fetch_with_query(HasManyAssociationsTest) [/Users/FileVault/stevej/Projects/rails/activerecord/test/cases/associations/has_many_associations_test.rb:1342]: 2 instead of 1 queries were executed. Queries: SELECT COUNT(*) FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind in (‘v’,‘r’) AND c.relname = $1 AND n.nspname = ANY (current_schemas(false))

SELECT COUNT(*) FROM “essays” WHERE “essays”.“writer_id” = $1 AND “essays”.“writer_type” = $2. Expected: 1 Actual: 2

Thanks,

– S.J.

Hey Steve,

Sad, but true, that sometime our test suite is not always green. You can verify the state of the test suite at Travis-CI website: http://travis-ci.org/#!/rails/rails

Also, according to latest build, the test cases are indeed failing: http://travis-ci.org/#!/rails/rails/builds/1394984 I don’t think anybody is fixing it right now, according to the rails issues list (https://github.com/rails/rails/issues) so good luck :slight_smile:

Thanks,

Prem

Thanks very much for the info and pointers, Prem. Since it’s a PostgreSQL adapter improvement that I’m working on, I’ll give those failing tests some attention as well.

Hey Steve,

I just want to add a comment that this is the first failing build with this particular problem: http://travis-ci.org/#!/rails/rails/builds/1391490. From here you can see the commit.

It’s also worth mention that if you’re working on any other change, you can send it as a separate pull request, no need to include “fixing the build” with it.

Thanks!

A pull request of mine seemed to trigger this problem. Sorry about that.

However, I am able to reproduce the problem with both sqlite3 and postgresql on master (where my patch has been reverted) like this:

activerecord$ ruby -w -I"lib:test" -e ‘[“test/cases/associations/eager_test.rb”, “test/cases/associations/join_model_test.rb”, “test/cases/base_test.rb”].each { |f| load f }’

So I think there are some assumptions in the tests that aren’t true depending on test order or something else. See https://github.com/rails/rails/pull/6416#issuecomment-5871744

Can anyone else reproduce?

A pull request of mine seems to have triggered these failures. Sorry about that.

But I now think the problem is unrelated to my patch since I can reproduce on master (where the patch was reverted) with both sqlite3 and postgres with this command:

ruby -w -I"lib:test" -e ‘[“test/cases/associations/eager_test.rb”, “test/cases/associations/join_model_test.rb”, “test/cases/base_test.rb”].each { |f| load f }’

Can anyone else reproduce this?

See https://github.com/rails/rails/pull/6416#issuecomment-5871744