Skip to content

NoMethodError: undefined method 'ntuples' for nil with PG#async_exec #3507

Closed
@agrobbin

Description

@agrobbin

Current behaviour

I'm having trouble tracking down the root cause here, but we've occasionally seen exceptions in CI from ddtrace's PG instrumentation:

NoMethodError: undefined method `ntuples' for nil
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/contrib/pg/instrumentation.rb:177:in `annotate_span_with_result!'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/contrib/pg/instrumentation.rb:136:in `block in trace'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/trace_operation.rb:199:in `block in measure'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/span_operation.rb:150:in `measure'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/trace_operation.rb:199:in `measure'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/tracer.rb:385:in `start_span'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/tracer.rb:159:in `block in trace'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/context.rb:45:in `activate!'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/tracer.rb:158:in `trace'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing.rb:18:in `trace'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/contrib/pg/instrumentation.rb:105:in `trace'
    vendor/bundle/ruby/3.3.0/gems/ddtrace-1.19.0/lib/datadog/tracing/contrib/pg/instrumentation.rb:51:in `async_exec'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:55:in `block (2 levels) in raw_execute'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:1028:in `block in with_raw_connection'
    vendor/bundle/ruby/3.3.0/gems/activesupport-7.1.3.2/lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:1000:in `with_raw_connection'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:54:in `block in raw_execute'
    vendor/bundle/ruby/3.3.0/gems/activesupport-7.1.3.2/lib/active_support/notifications/instrumenter.rb:58:in `instrument'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:1143:in `log'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:53:in `raw_execute'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:521:in `internal_execute'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:101:in `begin_db_transaction'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:373:in `materialize!'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:449:in `block in begin_transaction'
    vendor/bundle/ruby/3.3.0/gems/activesupport-7.1.3.2/lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:416:in `begin_transaction'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:352:in `begin_transaction'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/test_fixtures.rb:149:in `block in setup_fixtures'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/test_fixtures.rb:148:in `each'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/test_fixtures.rb:148:in `setup_fixtures'
    vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/test_fixtures.rb:10:in `before_setup'

We've been unable to track down the specific cause, as it's not consistent, nor reproducible.

Our tracing configuration is:

I, [2024-03-06T02:18:00.036801 #3827]  INFO -- ddtrace: [ddtrace] DATADOG CONFIGURATION - PROFILING - {"profiling_enabled":false}
I, [2024-03-06T02:18:00.037976 #3827]  INFO -- ddtrace: [ddtrace] DATADOG CONFIGURATION - CORE - {"date":"2024-03-06T02:18:00+00:00","os_name":"x86_64-pc-linux","version":"1.19.0","lang":"ruby","lang_version":"3.3.0","env":null,"service":"atlas-rails","dd_version":null,"debug":false,"tags":null,"runtime_metrics_enabled":true,"vm":"ruby-3.3.0","health_metrics_enabled":false}
I, [2024-03-06T02:18:01.072878 #3827]  INFO -- ddtrace: [ddtrace] DATADOG CONFIGURATION - TRACING - {"enabled":true,"agent_url":null,"analytics_enabled":false,"sample_rate":null,"sampling_rules":null,"integrations_loaded":"[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]","partial_flushing_enabled":false,"priority_sampling_enabled":false,"integration_rails_analytics_enabled":"","integration_rails_analytics_sample_rate":"1.0","integration_rails_enabled":"true","integration_rails_service_name":"","integration_rails_distributed_tracing":"true","integration_rails_request_queuing":"exclude_request","integration_rails_exception_controller":"","integration_rails_middleware":"true","integration_rails_middleware_names":"false","integration_rails_template_base_path":"views/","integration_active_record_analytics_enabled":"false","integration_active_record_analytics_sample_rate":"1.0","integration_activ

I'm not sure why the startup log was truncated, but hopefully that is helpful. I wish I could provide more detail beyond this, but am not sure where to look for more detail.

Expected behaviour

The PG instrumentation shouldn't raise an exception.

Environment

  • ddtrace version: v1.19.0
  • Configuration block (Datadog.configure ...):
  • Ruby version: v3.3.0
  • Operating system: Ubuntu 22.04.4
  • Relevant library versions: Rails 7.1.3.2

Metadata

Metadata

Assignees

Labels

bugInvolves a bugcommunityWas opened by a community member

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions