lib/td/logger/td_logger.rb in td-logger-0.3.7 vs lib/td/logger/td_logger.rb in td-logger-0.3.8
- old
+ new
@@ -62,10 +62,12 @@
@cond = ConditionVariable.new
@map = {} # (db,table) => buffer:String
@queue = []
@chunk_limit = 8*1024*1024
+ @queue_limit = 50
+
@flush_interval = 10
@max_flush_interval = 300
@retry_wait = 1.0
@retry_limit = 12
@@ -177,9 +179,14 @@
end
key = [db, table]
@mutex.synchronize do
+ if @queue.length > @queue_limit
+ @logger.error("TreasureDataLogger: queue length exceeds limit. can't add new event log: #{msg.inspect}")
+ return false
+ end
+
buffer = (@map[key] ||= '')
buffer << data
if buffer.size > @chunk_limit