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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 1d8b3a0bcc6 branch-2.1: [fix](audit) fix the delay in loading audit 
log #46175 (#46193)
1d8b3a0bcc6 is described below

commit 1d8b3a0bcc6da15b025f70de3b10843275d98a1c
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Dec 31 22:56:12 2024 +0800

    branch-2.1: [fix](audit) fix the delay in loading audit log #46175 (#46193)
    
    Cherry-picked from #46175
    
    Co-authored-by: shee <13843187+qz...@users.noreply.github.com>
---
 .../src/main/java/org/apache/doris/plugin/audit/AuditLoader.java  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoader.java 
b/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoader.java
index ee78496cfcb..283ba3c2224 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoader.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoader.java
@@ -178,8 +178,8 @@ public class AuditLoader extends Plugin implements 
AuditPlugin {
     public synchronized void loadIfNecessary(boolean force) {
         long currentTime = System.currentTimeMillis();
 
-        if (force || auditLogBuffer.length() >= 
GlobalVariable.auditPluginMaxBatchBytes
-                || currentTime - lastLoadTimeAuditLog >= 
GlobalVariable.auditPluginMaxBatchInternalSec * 1000) {
+        if (auditLogBuffer.length() != 0 && (force || auditLogBuffer.length() 
>= GlobalVariable.auditPluginMaxBatchBytes
+                || currentTime - lastLoadTimeAuditLog >= 
GlobalVariable.auditPluginMaxBatchInternalSec * 1000)) {
             // begin to load
             try {
                 String token = "";
@@ -227,9 +227,9 @@ public class AuditLoader extends Plugin implements 
AuditPlugin {
                     AuditEvent event = auditEventQueue.poll(5, 
TimeUnit.SECONDS);
                     if (event != null) {
                         assembleAudit(event);
-                        // process all audit logs
-                        loadIfNecessary(false);
                     }
+                    // process all audit logs
+                    loadIfNecessary(false);
                 } catch (InterruptedException ie) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("encounter exception when loading current 
audit batch", ie);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to