This is an automated email from the ASF dual-hosted git repository.

nic443 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c79831cd chore: remove fast return to flush current queue log data 
during shutdown (#12711)
3c79831cd is described below

commit 3c79831cdac55731dc9af27c21ba8cc6eb36be64
Author: Ashish Tiwari <[email protected]>
AuthorDate: Thu Nov 6 13:56:53 2025 +0530

    chore: remove fast return to flush current queue log data during shutdown 
(#12711)
    
    Signed-off-by: Nic <[email protected]>
    Co-authored-by: Nic <[email protected]>
---
 apisix/utils/batch-processor.lua | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/apisix/utils/batch-processor.lua b/apisix/utils/batch-processor.lua
index eb63f2a26..cd2421af6 100644
--- a/apisix/utils/batch-processor.lua
+++ b/apisix/utils/batch-processor.lua
@@ -51,8 +51,14 @@ batch_processor.schema = schema
 local function schedule_func_exec(self, delay, batch)
     local hdl, err = timer_at(delay, execute_func, self, batch)
     if not hdl then
-        core.log.error("failed to create process timer: ", err)
-        return
+        if err == "process exiting" then
+            -- it is allowed to create zero-delay timers even when
+            -- the Nginx worker process starts shutting down
+            timer_at(0, execute_func, self)
+        else
+            core.log.error("failed to create process timer: ", err)
+            return
+        end
     end
 end
 
@@ -78,10 +84,6 @@ end
 
 
 function execute_func(premature, self, batch)
-    if premature then
-        return
-    end
-
     -- In case of "err" and a valid "first_fail" batch processor considers, 
all first_fail-1
     -- entries have been successfully consumed and hence reschedule the job 
for entries with
     -- index first_fail to #entries based on the current retry policy.
@@ -116,10 +118,6 @@ end
 
 
 local function flush_buffer(premature, self)
-    if premature then
-        return
-    end
-
     if now() - self.last_entry_t >= self.inactive_timeout or
        now() - self.first_entry_t >= self.buffer_duration
     then
@@ -140,8 +138,12 @@ end
 function create_buffer_timer(self)
     local hdl, err = timer_at(self.inactive_timeout, flush_buffer, self)
     if not hdl then
-        core.log.error("failed to create buffer timer: ", err)
-        return
+        if err == "process exiting" then
+            timer_at(0, flush_buffer, self)
+        else
+            core.log.error("failed to create buffer timer: ", err)
+            return
+        end
     end
     self.is_timer_running = true
 end

Reply via email to