What does this ActiveRecord error: "Cannot expire connection, it is not currently leased." mean?

143 Views Asked by At

Stack:

  • ActiveRecord / Rails 7
  • Sidekiq Enterprise
  • makara
  • Amazon RDS Proxy to manage connection pooling for a Rails application.

Occasionally, we get the following error raised

ActiveRecord::ActiveRecordErrorvendor/bundle/ruby/2.7.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/abstract_adapter.rb:260
Cannot expire connection, it is not currently leased.

From what I understand this happens when the application is trying to return a connection to the pool, but it isn't clear how this is handled internally by Rails.

This also consistently happens only to the app running background jobs on Sidekiq, but not to other web applications.

Also looked up the source and reverting the changes back to non-proxied connection pools on RDS Proxy. The issue seems consistent.

0

There are 0 best solutions below