Skip to content

Commit

Permalink
fix(batch-processor): we didn't free stale object actually (apache#5700)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacewander authored and bzp2010 committed Dec 30, 2021
1 parent d502158 commit d3adc9b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion apisix/plugins/http-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ local plugin = require("apisix.plugin")
local ngx = ngx
local tostring = tostring
local ipairs = ipairs
local pairs = pairs
local timer_at = ngx.timer.at

local plugin_name = "http-logger"
Expand Down Expand Up @@ -150,7 +151,7 @@ local function remove_stale_objects(premature)
return
end

for key, batch in ipairs(buffers) do
for key, batch in pairs(buffers) do
if #batch.entry_buffer.entries == 0 and #batch.batch_to_process == 0 then
core.log.warn("removing batch processor stale object, conf: ",
core.json.delay_encode(key))
Expand Down
3 changes: 1 addition & 2 deletions apisix/plugins/kafka-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ local plugin = require("apisix.plugin")
local math = math
local pairs = pairs
local type = type
local ipairs = ipairs
local plugin_name = "kafka-logger"
local stale_timer_running = false
local timer_at = ngx.timer.at
Expand Down Expand Up @@ -138,7 +137,7 @@ local function remove_stale_objects(premature)
return
end

for key, batch in ipairs(buffers) do
for key, batch in pairs(buffers) do
if #batch.entry_buffer.entries == 0 and #batch.batch_to_process == 0 then
core.log.warn("removing batch processor stale object, conf: ",
core.json.delay_encode(key))
Expand Down
3 changes: 2 additions & 1 deletion apisix/plugins/sls-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ local tcp = ngx.socket.tcp
local buffers = {}
local tostring = tostring
local ipairs = ipairs
local pairs = pairs
local table = table
local schema = {
type = "object",
Expand Down Expand Up @@ -116,7 +117,7 @@ local function remove_stale_objects(premature)
return
end

for key, batch in ipairs(buffers) do
for key, batch in pairs(buffers) do
if #batch.entry_buffer.entries == 0 and #batch.batch_to_process == 0 then
core.log.warn("removing batch processor stale object, route id:", tostring(key))
buffers[key] = nil
Expand Down
4 changes: 2 additions & 2 deletions apisix/plugins/syslog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local logger_socket = require("resty.logger.socket")
local plugin_name = "syslog"
local ngx = ngx
local buffers = {}
local ipairs = ipairs
local pairs = pairs
local stale_timer_running = false;
local timer_at = ngx.timer.at

Expand Down Expand Up @@ -121,7 +121,7 @@ local function remove_stale_objects(premature)
return
end

for key, batch in ipairs(buffers) do
for key, batch in pairs(buffers) do
if #batch.entry_buffer.entries == 0 and #batch.batch_to_process == 0 then
core.log.warn("removing batch processor stale object, conf: ",
core.json.delay_encode(key))
Expand Down
4 changes: 2 additions & 2 deletions apisix/plugins/tcp-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local tostring = tostring
local buffers = {}
local ngx = ngx
local tcp = ngx.socket.tcp
local ipairs = ipairs
local pairs = pairs
local stale_timer_running = false
local timer_at = ngx.timer.at

Expand Down Expand Up @@ -106,7 +106,7 @@ local function remove_stale_objects(premature)
return
end

for key, batch in ipairs(buffers) do
for key, batch in pairs(buffers) do
if #batch.entry_buffer.entries == 0 and #batch.batch_to_process == 0 then
core.log.warn("removing batch processor stale object, conf: ",
core.json.delay_encode(key))
Expand Down
4 changes: 2 additions & 2 deletions apisix/plugins/udp-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local tostring = tostring
local buffers = {}
local ngx = ngx
local udp = ngx.socket.udp
local ipairs = ipairs
local pairs = pairs
local stale_timer_running = false;
local timer_at = ngx.timer.at

Expand Down Expand Up @@ -90,7 +90,7 @@ local function remove_stale_objects(premature)
return
end

for key, batch in ipairs(buffers) do
for key, batch in pairs(buffers) do
if #batch.entry_buffer.entries == 0 and #batch.batch_to_process == 0 then
core.log.warn("removing batch processor stale object, conf: ",
core.json.delay_encode(key))
Expand Down

0 comments on commit d3adc9b

Please sign in to comment.