Is the system variable tidb_general_log global or session?

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 系统变量tidb_general_log是global还是session?

| username: 超7成网友

[TiDB Usage Environment] Production Environment v3.0.12
[TiDB Version] v3.0.12

The documentation I read says that tidb_general_log is global, but when I use the command set global tidb_general_log=on; it gives an error
ERROR 1105 (HY000): Variable ‘tidb_general_log’ is a SESSION variable and can’t be used with SET GLOBAL

When I use set @@tidb_general_log or set tidb_general_log = 1, it takes effect globally on the current server (I create a new connection and see that the variable value has changed, and I understand that the new connection is not the same session).
I’m very confused!!!

| username: h5n1 | Original post link

The image is not visible. Please provide the text you need translated.

| username: Billmay表妹 | Original post link

Uh… Off-topic

You might want to consider upgrading!

| username: 像风一样的男子 | Original post link

Your version is too old. In 4.0, the scope is INSTANCE. In 3.0, it is definitely not global. You should upgrade your version.

| username: TiDBer_小阿飞 | Original post link

The error message indicates that it is a SESSION variable, right? Using set @@tidb_general_log or set tidb_general_log = 1 only affects the current TiDB instance connection. The documentation also states that it is not persisted to the cluster and only affects the current instance connection.


  • Scope: GLOBAL
  • Persisted to the cluster: No, only affects the current TiDB instance connection
| username: 超7成网友 | Original post link

After I set it to 1, I checked the logs and it took effect on the current TiDB instance. If it is at the session level, it should become invalid after I close the client connection, but it is still effective now, so I am confused.

| username: 像风一样的男子 | Original post link

This is instance-level scope.
Instance-level modification:

  • Effective for all sessions of the current TiDB instance;
    The modification will not be persisted and will be invalidated upon restart.
| username: 超7成网友 | Original post link

It should be like this, thank you.
The old version was too frustrating. The documentation was hard to find.

| username: Fly-bird | Original post link

Upgrade it.

| username: Kongdom | Original post link

When reading the documentation, be sure to pay attention to the version.

| username: 大飞哥online | Original post link

Upgrade it.

| username: zhanggame1 | Original post link

You can test it yourself, the version is too old.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.