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

Moneta pool busy-loops with ttl option #197

Closed
simmons opened this issue Jan 29, 2021 · 2 comments · Fixed by #198
Closed

Moneta pool busy-loops with ttl option #197

simmons opened this issue Jan 29, 2021 · 2 comments · Fixed by #198

Comments

@simmons
Copy link

simmons commented Jan 29, 2021

I'm using Moneta 1.4.1, and noticed that when using Moneta::Pool with the ttl option, the pool management thread will start busy-looping after the ttl interval, thus using 100% of a CPU core. I'm using Moneta with the Redis adapter, and I've seen this behavior in Ruby version 2.7.0p0, 2.7.2p137, and 3.0.0p0.

With the moneta and redis gems installed, and a Redis server running, I can reproduce this with the following script:

#!/usr/bin/env ruby
require 'moneta'
cache = Moneta.build do
  use(:Pool, min: 2, max: 4, ttl: 5, timeout: 2) do
    adapter :Redis, url: "redis://127.0.0.1:6379", expires: 300
  end
end
# Query the cache (It doesn't matter if this exists or not.)
puts cache[42].inspect
# Sleep 15 seconds. After 5 seconds, busy-loop will start.
sleep(15)
@asppsa
Copy link
Collaborator

asppsa commented Jan 30, 2021

Thanks very much for this report, and also for the repro. I'll take a look at this as a matter of urgency.

@asppsa
Copy link
Collaborator

asppsa commented Feb 14, 2021

@simmons I believe I have the issue fixed in #198 - I'm just trying to sort out the broken CI situation before I merge. In the meantime though, you might want to try out that branch for yourself to see if it fixes the issue for you.

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

Successfully merging a pull request may close this issue.

2 participants