Skip to content

A platform for community discussion. Free, open, simple.

DEV: In test, if flush is called and there is no thread, flush inline (#21426)

Samac0673d29e6b
diff --git a/app/models/concerns/cached_counting.rb b/app/models/concerns/cached_counting.rb
index 1e2e84f0c25..1080fce9123 100644
--- a/app/models/concerns/cached_counting.rb
+++ b/app/models/concerns/cached_counting.rb
@@ -83,10 +83,13 @@ module CachedCounting
end
def self.flush
- if @thread
+ if @thread && @thread.alive?
@flush = true
@thread.wakeup
sleep 0.001 while @flush
+ else
+ flush_in_memory
+ flush_to_db
end
end