On Thu, Nov 16, 2023 at 2:25 PM Josh (joshofclubs52) <[email protected]>
wrote:
> One thing that may help is that I notice the app is leaving a lot of
> transactions in the "idle" / COMMIT state. I know that usually isn't a good
> indicator, but the number of those continues to climb.
>
If the application is opening connections with "BEGIN" but never issuing a
"COMMIT", that is quite odd. Sequel uses a block-based approach to
transactions, so this shouldn't happen unless something is going seriously
wrong, or you are calling something like Process.exec inside the block.
> On Thursday, November 16, 2023 at 5:23:30 PM UTC-5 Josh (joshofclubs52)
> wrote:
>
>> I am running into an issue on a padrino API utilizing Sequel 5.19.0.
>> The last year and a half we have noticed the memory in our ECS services
>> going up and up to above 100%. We have been mitigating this with simply
>> recycling the containers. But RDS shows that each time this is happening,
>> the DB connections are going up as well and it is causing a lot of issues
>> as we are scaling.
>>
>> In the application, the database is connected via:
>> ```
>> connection_pool_size = ENV['SEQUEL_POOL_SIZE'] || 4
>>
>> Sequel::Model.db = Sequel.connect(config, :max_connections =>
>> connection_pool_size, :loggers => [logger], :after_connect=>proc{|c| c.
>> execute("SET application_name TO '#{svc_name}-#{SecureRandom.uuid}'")})
>> ```
>>
>> Before it was
>> ```
>> Sequel.connect(config, :loggers => [logger])
>> ```
>>
>> I'm not sure that change is what causing the behavior but the timeline
>> would be "roughly" around then. Its hard to say for sure when this actually
>> began.
>>
>> Is there anything that stands out in the above that would lead to a
>> connections exceeding the pool size and/or causing the memory leak?
>>
>
To make sure you aren't leaking Database objects, you should make sure that
you only call Sequel.connect at application startup, and assign the value
to a constant. If you are calling Sequel.connect at runtime, that could
easily be the source of your problem.
If you can put together a self contained reproducible example that shows
such a leak, I will definitely take a look.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/CADGZSSeE7LUgXqQ7pYLwk3FhO21n92-B4rbB7SCUZZ%2B6DW50MA%40mail.gmail.com.