branch-2.1: [Audit](fix) fix audit log lost for npe #44145 (#45189)

Cherry-picked from #44145

Co-authored-by: shee <13843187+qzsee@users.noreply.github.com>
Co-authored-by: garenshi <garenshi@tencent.com>
This commit is contained in:
github-actions[bot]
2024-12-09 18:32:14 +08:00
committed by GitHub
parent b2637e4bda
commit f3dbd4800f

View File

@ -241,7 +241,7 @@ public class AuditLogHelper {
auditEventBuilder.setStmt(origStmt);
}
if (!Env.getCurrentEnv().isMaster()) {
if (ctx.executor.isForwardToMaster()) {
if (ctx.executor != null && ctx.executor.isForwardToMaster()) {
auditEventBuilder.setState(ctx.executor.getProxyStatus());
int proxyStatusCode = ctx.executor.getProxyStatusCode();
if (proxyStatusCode != 0) {