Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `/' for nil:NilClass #394

Closed
thromera opened this issue Sep 17, 2021 · 9 comments
Closed

undefined method `/' for nil:NilClass #394

thromera opened this issue Sep 17, 2021 · 9 comments

Comments

@thromera
Copy link

Hi, thanks for the gem!

There is an issue with the live queries feature on our hand.

PGHero: 2.8.1

Here is the backtrace:

NoMethodError: undefined method `/' for nil:NilClass
  from pghero (2.8.1) app/views/pg_hero/home/_live_queries_table.html.erb:15
  from pghero (2.8.1) app/views/pg_hero/home/_live_queries_table.html.erb:11:in `each'
  from pghero (2.8.1) app/views/pg_hero/home/_live_queries_table.html.erb:11
  from actionview (6.1.4.1) lib/action_view/base.rb:247:in `public_send'
  from actionview (6.1.4.1) lib/action_view/base.rb:247:in `_run'
  from actionview (6.1.4.1) lib/action_view/template.rb:154:in `block in render'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:205:in `instrument'
  from actionview (6.1.4.1) lib/action_view/template.rb:345:in `instrument_render_template'
  from actionview (6.1.4.1) lib/action_view/template.rb:152:in `render'
  from actionview (6.1.4.1) lib/action_view/renderer/partial_renderer.rb:285:in `block in render_partial_template'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `block in instrument'
  from activesupport (6.1.4.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `instrument'
  from actionview (6.1.4.1) lib/action_view/renderer/partial_renderer.rb:280:in `render_partial_template'
  from actionview (6.1.4.1) lib/action_view/renderer/partial_renderer.rb:271:in `render'
  from actionview (6.1.4.1) lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
  from actionview (6.1.4.1) lib/action_view/renderer/renderer.rb:27:in `render_to_object'
  from actionview (6.1.4.1) lib/action_view/renderer/renderer.rb:22:in `render'
  from actionview (6.1.4.1) lib/action_view/helpers/rendering_helper.rb:38:in `block in render'
  from actionview (6.1.4.1) lib/action_view/base.rb:273:in `in_rendering_context'
  from actionview (6.1.4.1) lib/action_view/helpers/rendering_helper.rb:34:in `render'
  from pghero (2.8.1) app/views/pg_hero/home/live_queries.html.erb:6
  from actionview (6.1.4.1) lib/action_view/base.rb:247:in `public_send'
  from actionview (6.1.4.1) lib/action_view/base.rb:247:in `_run'
  from actionview (6.1.4.1) lib/action_view/template.rb:154:in `block in render'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:205:in `instrument'
  from actionview (6.1.4.1) lib/action_view/template.rb:345:in `instrument_render_template'
  from actionview (6.1.4.1) lib/action_view/template.rb:152:in `render'
  from actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:61:in `block (2 levels) in render_template'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `block in instrument'
  from activesupport (6.1.4.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `instrument'
  from actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:56:in `block in render_template'
  from actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:71:in `block in render_with_layout'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `block in instrument'
  from activesupport (6.1.4.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `instrument'
  from actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:70:in `render_with_layout'
  from actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:55:in `render_template'
  from actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:11:in `render'
  from actionview (6.1.4.1) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
  from actionview (6.1.4.1) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
  from actionview (6.1.4.1) lib/action_view/rendering.rb:117:in `block in _render_template'
  from actionview (6.1.4.1) lib/action_view/base.rb:273:in `in_rendering_context'
  from actionview (6.1.4.1) lib/action_view/rendering.rb:116:in `_render_template'
  from actionpack (6.1.4.1) lib/action_controller/metal/streaming.rb:218:in `_render_template'
  from actionview (6.1.4.1) lib/action_view/rendering.rb:103:in `render_to_body'
  from actionpack (6.1.4.1) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
  from actionpack (6.1.4.1) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
  from actionpack (6.1.4.1) lib/abstract_controller/rendering.rb:25:in `render'
  from actionpack (6.1.4.1) lib/action_controller/metal/rendering.rb:36:in `render'
  from actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
  from vendor/ruby-3.0.2/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
  from activesupport (6.1.4.1) lib/active_support/core_ext/benchmark.rb:14:in `ms'
  from actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
  from actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:86:in `cleanup_view_runtime'
  from activerecord (6.1.4.1) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
  from actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:45:in `render'
  from wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:46:in `call'
  from wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
  from wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:30:in `render'
  from actionpack (6.1.4.1) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
  from actionpack (6.1.4.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
  from <internal:kernel>:90:in `tap'
  from actionpack (6.1.4.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
  from actionpack (6.1.4.1) lib/abstract_controller/base.rb:228:in `process_action'
  from ddtrace (0.52.0) lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb:127:in `process_action'
  from actionpack (6.1.4.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
  from actionpack (6.1.4.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
  from activesupport (6.1.4.1) lib/active_support/callbacks.rb:117:in `block in run_callbacks'
  from react-rails (2.6.1) lib/react/rails/controller_lifecycle.rb:31:in `use_react_component_helper'
  from activesupport (6.1.4.1) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
  from marginalia (1.11.1) lib/marginalia.rb:109:in `record_query_comment'
  from activesupport (6.1.4.1) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
  from actiontext (6.1.4.1) lib/action_text/rendering.rb:20:in `with_renderer'
  from actiontext (6.1.4.1) lib/action_text/engine.rb:59:in `block (4 levels) in <class:Engine>'
  from activesupport (6.1.4.1) lib/active_support/callbacks.rb:126:in `instance_exec'
  from activesupport (6.1.4.1) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
  from activesupport (6.1.4.1) lib/active_support/callbacks.rb:137:in `run_callbacks'
  from actionpack (6.1.4.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
  from actionpack (6.1.4.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
  from actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `block in instrument'
  from activesupport (6.1.4.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
  from activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `instrument'
  from actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
  from actionpack (6.1.4.1) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
  from activerecord (6.1.4.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
  from config/initializers/action_controller.rb:29:in `process_action'
  from actionpack (6.1.4.1) lib/abstract_controller/base.rb:165:in `process'
  from actionview (6.1.4.1) lib/action_view/rendering.rb:39:in `process'
  from actionpack (6.1.4.1) lib/action_controller/metal.rb:190:in `dispatch'
  from actionpack (6.1.4.1) lib/action_controller/metal.rb:254:in `dispatch'
  from actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
  from actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:33:in `serve'
  from actionpack (6.1.4.1) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
  from actionpack (6.1.4.1) lib/action_dispatch/routing/mapper.rb:49:in `serve'
  from actionpack (6.1.4.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'
  from actionpack (6.1.4.1) lib/action_dispatch/journey/router.rb:32:in `each'
  from actionpack (6.1.4.1) lib/action_dispatch/journey/router.rb:32:in `serve'
  from actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:842:in `call'
  from railties (6.1.4.1) lib/rails/engine.rb:539:in `call'
  from railties (6.1.4.1) lib/rails/railtie.rb:207:in `public_send'
  from railties (6.1.4.1) lib/rails/railtie.rb:207:in `method_missing'
  from actionpack (6.1.4.1) lib/action_dispatch/routing/mapper.rb:20:in `block in <class:Constraints>'
  from actionpack (6.1.4.1) lib/action_dispatch/routing/mapper.rb:49:in `serve'
  from actionpack (6.1.4.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'
  from actionpack (6.1.4.1) lib/action_dispatch/journey/router.rb:32:in `each'
  from actionpack (6.1.4.1) lib/action_dispatch/journey/router.rb:32:in `serve'
  from actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:842:in `call'
  from warden-jwt_auth (0.5.0) lib/warden/jwt_auth/middleware/token_dispatcher.rb:20:in `call'
  from warden-jwt_auth (0.5.0) lib/warden/jwt_auth/middleware/revocation_manager.rb:21:in `call'
  from rack (2.2.3) lib/rack/builder.rb:244:in `call'
  from warden-jwt_auth (0.5.0) lib/warden/jwt_auth/middleware.rb:23:in `call'
  from rack-attack (6.5.0) lib/rack/attack.rb:113:in `call'
  from omniauth (2.0.4) lib/omniauth/strategy.rb:202:in `call!'
  from omniauth (2.0.4) lib/omniauth/strategy.rb:169:in `call'
  from omniauth (2.0.4) lib/omniauth/builder.rb:45:in `call'
  from warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
  from warden (1.2.9) lib/warden/manager.rb:34:in `catch'
  from warden (1.2.9) lib/warden/manager.rb:34:in `call'
  from rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
  from rack (2.2.3) lib/rack/etag.rb:27:in `call'
  from rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
  from rack (2.2.3) lib/rack/head.rb:12:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
  from rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
  from rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/cookies.rb:689:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
  from activesupport (6.1.4.1) lib/active_support/callbacks.rb:98:in `run_callbacks'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
  from sentry-rails (4.7.2) lib/sentry/rails/rescued_exception_interceptor.rb:12:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
  from ddtrace (0.52.0) lib/ddtrace/contrib/rails/middlewares.rb:18:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
  from railties (6.1.4.1) lib/rails/rack/logger.rb:37:in `call_app'
  from railties (6.1.4.1) lib/rails/rack/logger.rb:26:in `block in call'
  from activesupport (6.1.4.1) lib/active_support/tagged_logging.rb:99:in `block in tagged'
  from activesupport (6.1.4.1) lib/active_support/tagged_logging.rb:37:in `tagged'
  from activesupport (6.1.4.1) lib/active_support/tagged_logging.rb:99:in `tagged'
  from railties (6.1.4.1) lib/rails/rack/logger.rb:26:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
  from request_store (1.5.0) lib/request_store/middleware.rb:19:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/request_id.rb:26:in `call'
  from rack (2.2.3) lib/rack/method_override.rb:24:in `call'
  from rack (2.2.3) lib/rack/runtime.rb:22:in `call'
  from activesupport (6.1.4.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
  from sentry-ruby-core (4.7.2) lib/sentry/rack/capture_exceptions.rb:23:in `block in call'
  from sentry-ruby-core (4.7.2) lib/sentry/hub.rb:56:in `with_scope'
  from sentry-ruby-core (4.7.2) lib/sentry-ruby.rb:176:in `with_scope'
  from sentry-ruby-core (4.7.2) lib/sentry/rack/capture_exceptions.rb:14:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/static.rb:24:in `call'
  from rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/ssl.rb:77:in `call'
  from actionpack (6.1.4.1) lib/action_dispatch/middleware/host_authorization.rb:92:in `call'
  from ddtrace (0.52.0) lib/ddtrace/contrib/rack/middlewares.rb:88:in `call'
  from railties (6.1.4.1) lib/rails/engine.rb:539:in `call'
  from puma (5.4.0) lib/puma/configuration.rb:249:in `call'
  from puma (5.4.0) lib/puma/request.rb:77:in `block in handle_request'
  from puma (5.4.0) lib/puma/thread_pool.rb:340:in `with_force_shutdown'
  from puma (5.4.0) lib/puma/request.rb:76:in `handle_request'
  from puma (5.4.0) lib/puma/server.rb:440:in `process_client'
  from puma (5.4.0) lib/puma/thread_pool.rb:147:in `block in spawn_thread'
  from logging (2.3.0) lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'

Error: ActionView::Template::Error
URL: pghero/primary/live_queries

Let me know if you need any additional information.

Thank you !

@ankane
Copy link
Owner

ankane commented Sep 20, 2021

Hey @Erowlin, it looks like duration_ms is nil, which seems odd. What version of Postgres are you on? Also, if you run the following query on your database, what's it return?

SELECT COUNT(*) FROM pg_stat_activity
WHERE COALESCE(query_start, xact_start) IS NULL AND state <> 'idle' AND datname = current_database();

@thromera
Copy link
Author

Postgres version

PostgreSQL 12.7

SELECT COUNT(*) FROM pg_stat_activity
WHERE COALESCE(query_start, xact_start) IS NULL AND state <> 'idle' AND datname = current_database();

3

@ankane
Copy link
Owner

ankane commented Sep 21, 2021

It'd be good to look at those rows to see if you notice a pattern/difference from other rows in pg_stat_activity. Also, any chance you're running a forked version of Postgres or have custom extensions installed?

@thromera
Copy link
Author

Also, any chance you're running a forked version of Postgres or have custom extensions installed?

AFAIK we run a regular Postgres !

@ankane
Copy link
Owner

ankane commented Oct 13, 2021

If you're able to learn anything about the queries, let me know.

@ankane
Copy link
Owner

ankane commented Nov 9, 2021

Cleaning up issues

@ankane ankane closed this as completed Nov 9, 2021
@tdeo
Copy link

tdeo commented Mar 10, 2022

Hello,

I was investigating this issue which is still happening on our end (I work with @thromera). It seems that the queries causing issues have walsender backend type, which apparently already have a special treatment for showing long running queries:

image

Let me know if you'd like any more information

@ankane
Copy link
Owner

ankane commented Mar 12, 2022

Hey @tdeo, thanks for the additional info. Just pushed a fix, but am still a bit confused about why this doesn't seem to be affecting other users.

@tdeo
Copy link

tdeo commented Mar 12, 2022

Thanks for the fix!
Looks like it would be expected that walsender connections have no start timestamp from The docs.
I could guess there might not be many people connecting their RoR application to their database with a privilege that lets them list replication slots and that could be specific to our setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants