Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Tries to explain a command which is not a query #5430

Closed
dbroeglin opened this Issue Mar 14, 2012 · 6 comments

Comments

Projects
None yet
4 participants

Under : rails (= 3.2.2) with database adapter pg (0.13.2) I sometimes get :

1.9.3-p125 :033 > OpenErp::Partner.all
   (0.5ms)  SET search_path TO public 
  OpenErp::Partner Load (548.2ms)  SELECT "res_partner".* FROM "res_partner" 
  EXPLAIN (1.8ms)  EXPLAIN SET search_path TO public
PG::Error: ERROR:  syntax error at or near "SET"
LINE 1: EXPLAIN SET search_path TO public
                ^
: EXPLAIN SET search_path TO public
ActiveRecord::StatementInvalid: PG::Error: ERROR:  syntax error at or near "SET"
LINE 1: EXPLAIN SET search_path TO public

This usually happens on a slow network which explains why those very small requests may take longer than the EXPLAIN threshold. However, those requests cannot be "explained" so Rails should probably not try to do an EXPLAIN on them.

Contributor

kennyj commented Mar 14, 2012

I guess that a payload name for schema_search_path should be SCHEMA.
I think that I fixed this issue.

Please review the above commit

Contributor

kennyj commented Mar 14, 2012

Anyway, I'll send a PR, because this is potentially problem even if the PR isn't a solution for your problem :-)

Yes this makes sense. I tested it against your version with an artificially lowered config.active_record.auto_explain_threshold_in_seconds to reproduce the issue systematically and your commit solves the issue.

Thanks a lot!

Le 14 mars 2012 à 18:09, kennyj a écrit :

I guess that a payload name for schema_search_path should be SCHEMA.
I think that I fixed this issue.

Please test it :)


Reply to this email directly or view it on GitHub:
#5430 (comment)

@tenderlove tenderlove added a commit that referenced this issue Mar 15, 2012

@tenderlove tenderlove Merge pull request #5437 from kennyj/fix_5430
Fix GH #5430. A Payload name for schema_search_path should be SCHEMA.
f961ec4
Contributor

kennyj commented Mar 15, 2012

I'm closing this issue, because the above fix is merged.

@kennyj kennyj closed this Mar 15, 2012

@tenderlove tenderlove added a commit that referenced this issue Mar 15, 2012

@tenderlove tenderlove Merge pull request #5437 from kennyj/fix_5430
Fix GH #5430. A Payload name for schema_search_path should be SCHEMA.
bd3e1ed
Contributor

dlee commented Sep 6, 2012

We might need to get a proper fix for this, since I'm getting a similar error with SHOW, not SET:

 PG::Error: ERROR:  syntax error at or near "SHOW"
LINE 1: EXPLAIN SHOW search_path;
               ^
: EXPLAIN SHOW search_path;
 vendor/bundle/ruby/1.9.1/bundler/gems/rails-79cd8b1cf6ee/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in `async_exec'

It is the same root problem (trying to EXPLAIN the unexplainable), right?

Contributor

josevalim commented Sep 6, 2012

Yeah, pull request like above please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment