igorkasyanchuk / rails_performance

Monitor performance of you Rails applications (self-hosted and free)
https://www.railsjazz.com/
MIT License
976 stars 53 forks source link

Sidekiq Memory Leak #14

Closed klondaiker closed 3 years ago

klondaiker commented 3 years ago

Disabled rails_performance accumulates many hashes in memory Sidekiq, which are not cleaned up by the garbage collector

{:group=>:db, :duration=>0.09, :sql=>"SELECT \"product_prices\".* FROM \"product_prices\" WHERE \"product_prices\".\"subject_id\" = $1 AND \"product_prices\".\"subject_type\" = $2 AND (\"product_prices\".\"price_cents\" IS NOT NULL) AND \"product_prices\".\"price_kind_id\" = 12630 LIMIT $3", :time=>1606909208}....

I think hashes are accumulating here Thread.current[:rp_current_request].storage

and Sidekiq does not call cleanup after finishing work

igorkasyanchuk commented 3 years ago

Hi @klondaiker , can you do a fix?

haffla commented 3 years ago

I don't see Thread.current being called anywhere in the Sidekiq instrumenter.

igorkasyanchuk commented 3 years ago

@haffla I agree with you. I think even if this issue is real it might happen because of too many records? maybe the duration is too big? or another issue.

I'd this gem enabled for one app in production for 1 month and all was ok, and I'd sidekiq too. And the site is with a good amount of uniq visitors ~800/day and many requests.

igorkasyanchuk commented 3 years ago

cannot reproduce