From 58c4878c4fefe68afd7421025355f0dea8e04c76 Mon Sep 17 00:00:00 2001 From: humengyao Date: Mon, 1 Jan 2024 22:04:12 -0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9B=9E=E5=90=886.0.0=E3=80=91?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8Bhw=5Faudi?= =?UTF-8?q?t=5Ffull=E9=9A=8F=E6=9C=BA=E6=8C=82=E5=BA=93=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=90=8E=E7=BB=AD=E6=89=80=E6=9C=89=E7=94=A8=E4=BE=8B=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=EF=BC=8Caudit=E7=89=88=E5=9D=97=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=AE=B5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/process/postmaster/pgaudit.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gausskernel/process/postmaster/pgaudit.cpp b/src/gausskernel/process/postmaster/pgaudit.cpp index f223a4283..7c430fcf9 100755 --- a/src/gausskernel/process/postmaster/pgaudit.cpp +++ b/src/gausskernel/process/postmaster/pgaudit.cpp @@ -1081,11 +1081,15 @@ static void pgaudit_write_file(char* buffer, int count) /* if record time is earlier than current file's create time, * create a new audit file to avoid the confusion caused by system clock change */ FILE* fh = NULL; + LWLockAcquire(AuditIndexFileLock, LW_SHARED); + bool haslock = true; if (g_instance.audit_cxt.audit_indextbl) { AuditIndexItem *cur_item = g_instance.audit_cxt.audit_indextbl->data + g_instance.audit_cxt.audit_indextbl->curidx[t_thrd.audit.cur_thread_idx]; if (curtime < cur_item->ctime) { + LWLockRelease(AuditIndexFileLock); + haslock = false; auditfile_close(SYSAUDITFILE_TYPE); fh = auditfile_open((pg_time_t)time(NULL), "a", true); if (fh != NULL) { @@ -1095,6 +1099,9 @@ static void pgaudit_write_file(char* buffer, int count) } uint32 retry_cnt = 0; + if (haslock) { + LWLockRelease(AuditIndexFileLock); + } retry1: rc = fwrite(buffer, 1, count, t_thrd.audit.sysauditFile);