@@ -51,6 +51,10 @@ const (
51
51
MaxLogFileSize = 4096 // MB
52
52
// MaxTxnEntrySize is the max value of TxnEntrySizeLimit.
53
53
MaxTxnEntrySizeLimit = 120 * 1024 * 1024 // 120MB
54
+ // MaxPluginAuditLogBufferSize is the max buffer size for plugin audit log.
55
+ MaxPluginAuditLogBufferSize = 100 * 1024 * 1024
56
+ // MaxPluginAuditLogFlushInterval is the max time interval to flush plugin audit log.
57
+ MaxPluginAuditLogFlushInterval = 3600
54
58
// DefTxnEntrySizeLimit is the default value of TxnEntrySizeLimit.
55
59
DefTxnEntrySizeLimit = 6 * 1024 * 1024
56
60
// DefTxnTotalSizeLimit is the default value of TxnTxnTotalSizeLimit.
@@ -94,6 +98,10 @@ const (
94
98
DefMemoryUsageAlarmRatio = 0.8
95
99
// DefTempDir is the default temporary directory path for TiDB.
96
100
DefTempDir = "/tmp/tidb"
101
+ // DefPluginAuditLogBufferSize is the default buffer size for plugin audit log.
102
+ DefPluginAuditLogBufferSize = 0
103
+ // DefPluginAuditLogFlushInterval is the default time interval to flush plugin audit log.
104
+ DefPluginAuditLogFlushInterval = 30
97
105
// DefAuthTokenRefreshInterval is the default time interval to refresh tidb auth token.
98
106
DefAuthTokenRefreshInterval = time .Hour
99
107
// EnvVarKeyspaceName is the system env name for keyspace name.
@@ -562,6 +570,10 @@ type Instance struct {
562
570
EnableCollectExecutionInfo AtomicBool `toml:"tidb_enable_collect_execution_info" json:"tidb_enable_collect_execution_info"`
563
571
PluginDir string `toml:"plugin_dir" json:"plugin_dir"`
564
572
PluginLoad string `toml:"plugin_load" json:"plugin_load"`
573
+ // PluginAuditLogBufferSize is the buffer size (in bytes) of plugin audit log, default is 0(buffer disabled)
574
+ PluginAuditLogBufferSize int `toml:"plugin_audit_log_buffer_size" json:"plugin_audit_log_buffer_size"`
575
+ // PluginAuditLogFlushInterval is the flush interval (in seconds) of plugin audit log, it works only when PluginAuditLogBufferSize is greater than 0.
576
+ PluginAuditLogFlushInterval int `toml:"plugin_audit_log_flush_interval" json:"plugin_audit_log_flush_interval"`
565
577
// MaxConnections is the maximum permitted number of simultaneous client connections.
566
578
MaxConnections uint32 `toml:"max_connections" json:"max_connections"`
567
579
TiDBEnableDDL AtomicBool `toml:"tidb_enable_ddl" json:"tidb_enable_ddl"`
@@ -1005,6 +1017,8 @@ var defaultConf = Config{
1005
1017
EnableCollectExecutionInfo : * NewAtomicBool (true ),
1006
1018
PluginDir : "/data/deploy/plugin" ,
1007
1019
PluginLoad : "" ,
1020
+ PluginAuditLogBufferSize : 0 ,
1021
+ PluginAuditLogFlushInterval : 30 ,
1008
1022
MaxConnections : 0 ,
1009
1023
TiDBEnableDDL : * NewAtomicBool (true ),
1010
1024
TiDBEnableStatsOwner : * NewAtomicBool (true ),
@@ -1388,7 +1402,12 @@ func (c *Config) Valid() error {
1388
1402
if c .TableColumnCountLimit < DefTableColumnCountLimit || c .TableColumnCountLimit > DefMaxOfTableColumnCountLimit {
1389
1403
return fmt .Errorf ("table-column-limit should be [%d, %d]" , DefIndexLimit , DefMaxOfTableColumnCountLimit )
1390
1404
}
1391
-
1405
+ if c .Instance .PluginAuditLogBufferSize < 0 || c .Instance .PluginAuditLogBufferSize > MaxPluginAuditLogBufferSize {
1406
+ return fmt .Errorf ("plugin-audit-log-buffer-size should be [%d, %d]" , 0 , MaxPluginAuditLogBufferSize )
1407
+ }
1408
+ if c .Instance .PluginAuditLogFlushInterval <= 0 || c .Instance .PluginAuditLogFlushInterval > MaxPluginAuditLogFlushInterval {
1409
+ return fmt .Errorf ("plugin-audit-log-flush-interval should be [%d, %d]" , 1 , MaxPluginAuditLogFlushInterval )
1410
+ }
1392
1411
// txn-local-latches
1393
1412
if err := c .TxnLocalLatches .Valid (); err != nil {
1394
1413
return err
0 commit comments