Commit e2e7d52
committed
PS-9369: Fix currently processed query comparison in audit_log
https://perconadev.atlassian.net/browse/PS-9369
The audit_log uses stack to keep track of table access operations being
performed in scope of one query. It compares last known table access query
string stored on top of this stack with actual query in audit event being
processed at the moment to decide if new record should be pushed to stack
or it is time to clean records from the stack.
Currently audit_log simply compares char* variables to decide if this is
the same query string. This approach doesn't work. As a result plugin looses
control of the stack size and it starts growing with the time consuming
memory. This issue is not noticable on short term server connections
as memory is freed once connection is closed. At the same time this
leads to extra memory consumption for long running server connections.
The following is done to fix the issue:
- Query is sent along with audit event as MYSQL_LEX_CSTRING structure.
It is not correct to ignore MYSQL_LEX_CSTRING.length comparison as
sometimes MYSQL_LEX_CSTRING.str pointer may be not iniialised
properly. Added string length check to make sure structure contains
any valid string.
- Used strncmp to compare actual strings instead of comparing char*
variables.1 parent a389a41 commit e2e7d52
1 file changed
+15
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
749 | | - | |
| 749 | + | |
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
| |||
977 | 977 | | |
978 | 978 | | |
979 | 979 | | |
980 | | - | |
981 | | - | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
982 | 986 | | |
983 | 987 | | |
984 | 988 | | |
| |||
993 | 997 | | |
994 | 998 | | |
995 | 999 | | |
996 | | - | |
| 1000 | + | |
| 1001 | + | |
997 | 1002 | | |
998 | 1003 | | |
999 | 1004 | | |
| |||
1060 | 1065 | | |
1061 | 1066 | | |
1062 | 1067 | | |
1063 | | - | |
1064 | | - | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
1065 | 1073 | | |
1066 | 1074 | | |
1067 | 1075 | | |
1068 | | - | |
| 1076 | + | |
1069 | 1077 | | |
1070 | 1078 | | |
1071 | 1079 | | |
| |||
0 commit comments