Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 开启tidb_general_log时,什么情况下不记录SQL语句
[TiDB Usage Environment] Production Environment
[TiDB Version] 5.4.1
[Encountered Issue] Seeking advice: When enabling a specific tidb-server, under what circumstances or what kind of SQL statements are not recorded in the general_log?
[Reproduction Path]
The DBA accesses the Zabbix service using a script, and Zabbix connects to a specific tidb-server instance to store and manipulate its metadata. Specifically, the script accesses the Zabbix service API to indirectly delete certain records from a table. However, even though tidb_general_log is enabled on that tidb-server, the delete from statement for the specific table is not recorded, only the select statement is recorded.
Explanation: General logic:
(1) The script first performs a fuzzy query on a certain field (the SELECT someid… FROM t LIKE … statement is recorded in the general_log entry):
select xid, name, ipset from t where ipset like ‘%$ip%’;
(2) Then it deletes based on the primary key value of the queried table (not recorded in the general_log entry).
This step involves the Zabbix server sending and executing a delete operation on the tidb-server.
[Issue Phenomenon and Impact]
The main concern is the confusion regarding tidb-server. It is noted that there is a condition for recording general_log, where the InRestrictedSQL variable must be false. However, this path seems too complex to quickly deduce directly from the tidb code. Therefore, seeking advice on under what circumstances SQL statements are not recorded in the enabled general_log.
[Attachments]
Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.