Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update server_audit.cc #2

Closed
wants to merge 1 commit into from
Closed

Conversation

shapled
Copy link

@shapled shapled commented Jun 2, 2023

Fix the crash issue caused by the plugin being stopped after switching from a read lock to a write lock.

Issue #, if available:
If auditing is disabled by another thread just after the read lock is released but before acquiring the write lock, it will cause the instance to crash.

Description of changes:
Check if the logfile object has been released.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Fix the crash issue caused by the plugin being stopped after switching from a read lock to a write lock.
@ottok
Copy link
Contributor

ottok commented Jun 6, 2023

Hi!

Thanks for your contribution!

Seems this 2.patch the contents of them both is exactly as 1.patch:

From be9389a99e416ff25702b6d8c5262dab032ad2f2 Mon Sep 17 00:00:00 2001
From: shapled <49967374+shapled@users.noreply.github.com>
Date: Fri, 2 Jun 2023 15:25:51 +0800
Subject: [PATCH] Update server_audit.cc

Fix the crash issue caused by the plugin being stopped after switching from a read lock to a write lock.
---
 plugin/server_audit/server_audit.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/plugin/server_audit/server_audit.cc b/plugin/server_audit/server_audit.cc
index 6dd78638f37..226c3b3218e 100644
--- a/plugin/server_audit/server_audit.cc
+++ b/plugin/server_audit/server_audit.cc
@@ -1184,7 +1184,8 @@ static int write_log(const char *message, size_t len, int take_lock)
         mysql_prlock_wrlock(&lock_operations);
         allow_rotate= 1;
       }
-      if (!(is_active= (logger_write_r(logfile, allow_rotate, message, len) ==
+      if (logfile &&
+	  !(is_active= (logger_write_r(logfile, allow_rotate, message, len) ==
                         (int) len)))
       {
         ++log_write_failures;

Only difference is that this PR is targeting 5.7 while the other is for 8.0. The contents is however the same.

I will close this and do the review in #1. When #1 get's merged it will be eventually merged/cherry-picked on both branches and there is no need to duplicate submission processes.

@ottok ottok closed this Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants