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

TiDB panics when using both the plugins 'Audit Log' and 'Extends Audit Log' simultaneously #43918

Closed
aytrack opened this issue May 17, 2023 · 1 comment · Fixed by #43921
Closed
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. feature/developing the related feature is in development severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented May 17, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. deploy a enterprise tidb cluster with audit log plugin
  2. enable audit log plugin and extends audit log
select audit_log_create_filter('all', '{}');
select audit_log_create_rule('%@%', 'all');
set global tidb_audit_enabled = 1;

insert into mysql.tidb_audit_table_access (user, db, tbl, access_type) values ('test', '.*', '.*', ''), ('^qa$', '.*', '.*', '');
flush tidb plugins audit;
create user test;
  1. connet the tidb cluster with user test and execute sql
use test

2. What did you expect to see? (Required)

both old and new audit log should record correctlly.

3. What did you see instead (Required)

tidb panic. If grant the privileges to the user, it will works.

mysql> use test;
ERROR 1105 (HY000): runtime error: invalid memory address or nil pointer dereference

tidb log

[2023/05/17 09:33:13.475 +00:00] [ERROR] [conn.go:1057] ["connection running loop panic"] [conn=4494121837139070629] [lastSQL="Use test"] [err="runtime error: invalid memory address or nil pointer dereference"] [stack="github.com/pingcap/tidb/server.(*clientConn).Run.func1
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/server/conn.go:1060
runtime.gopanic
	/usr/local/go/src/runtime/panic.go:884
runtime.panicmem
	/usr/local/go/src/runtime/panic.go:260
runtime.sigpanic
	/usr/local/go/src/runtime/signal_unix.go:837
github.com/pingcap/tidb/server.(*stmtEventInfo).ensureStmtContextOriginalSQL
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/server/extension.go:239
github.com/pingcap/tidb/server.(*stmtEventInfo).SQLDigest
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/server/extension.go:170
github.com/pingcap/tidb/extension/enterprise/audit.newStmtEventEntry.func1
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/extension/enterprise/audit/entry.go:388
github.com/pingcap/tidb/extension/enterprise/audit.(*LogEntry).Log
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/extension/enterprise/audit/entry.go:470
github.com/pingcap/tidb/extension/enterprise/audit.(*LogManager).GetSessionHandler.func2
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/extension/enterprise/audit/manager.go:659
github.com/pingcap/tidb/extension.(*SessionExtensions).OnStmtEvent
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/extension/session.go:145
github.com/pingcap/tidb/server.(*clientConn).onExtensionStmtEnd
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/server/extension.go:99
github.com/pingcap/tidb/server.(*clientConn).dispatch
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/server/conn.go:1343
github.com/pingcap/tidb/server.(*clientConn).Run
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/server/conn.go:1138
github.com/pingcap/tidb/server.(*Server).onConn
	/home/jenkins/agent/workspace/build-tidb-release-7.1/tidb/server/server.go:677"]
[2023/05/17 09:36:25.598 +00:00] [INFO] [domain.go:2634] ["refreshServerIDTTL succeed"] [serverID=2043690] ["lease id"=54ca882879068c09]

4. What is your TiDB version? (Required)

+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.1.0
Edition: Enterprise
Git Commit Hash: 6d29491cec48777cf80f3fa24cf70b3ae9d1cd87
Git Branch: heads/refs/tags/v7.1.0
UTC Build Time: 2023-05-16 13:11:57
GoVersion: go1.20.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/sql-infra SIG: SQL Infra severity/major labels May 17, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels May 17, 2023
@VelocityLight VelocityLight added affects-7.1 This bug affects the 7.1.x(LTS) versions. and removed may-affects-7.1 labels May 17, 2023
@lcwangchao lcwangchao removed may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 labels May 17, 2023
@lcwangchao
Copy link
Collaborator

This bug is introduced by #42651

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. feature/developing the related feature is in development severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants