-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(*): prevent queues from growing without bounds (#10046) This commit implements an upper limit on the number of batches that may be waiting on a queue for processing. Once the limit has been reached, the oldest batch is dropped from the queue and an error message is logged. The maximum number of batches that can be waiting on a queue is configured through the max_queued_batches parameter of the queue, which defaults to 100 and can be globally overriden with the max_queued_batches parameter in kong.conf KAG-303 This reverts commit 218cc0a. * fix(*): need to actually wait for queue to be processed 2.8 uses the ngx native timers that behave slightly differently when sleep(0) is invoked
- Loading branch information
1 parent
b81a511
commit 1a869fc
Showing
7 changed files
with
105 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
local BatchQueue = require "kong.tools.batch_queue" | ||
|
||
describe("batch queue", function() | ||
|
||
it("observes the limit parameter", function() | ||
local count = 0 | ||
local last | ||
local function process(entries) | ||
count = count + #entries | ||
last = entries[#entries] | ||
return true | ||
end | ||
|
||
local q = BatchQueue.new("batch-queue-unit-test", process, {max_queued_batches=2, batch_max_size=100, process_delay=0}) | ||
|
||
q:add(1) | ||
q:flush() | ||
q:add(2) | ||
q:flush() | ||
q:add(3) | ||
q:flush() | ||
|
||
-- run scheduled timer tasks | ||
ngx.sleep(1) | ||
|
||
assert.equal(2, count) | ||
assert.equal(3, last) | ||
end) | ||
end) |
1a869fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker image avaialble kong/kong:2.8.x-apk
Artifacts availabe https://github.com/Kong/kong/actions/runs/4122516846
1a869fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker image avaialble kong/kong:2.8.x-deb
Artifacts availabe https://github.com/Kong/kong/actions/runs/4122516846
1a869fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker image avaialble kong/kong:2.8.x-rpm
Artifacts availabe https://github.com/Kong/kong/actions/runs/4122516846