Unverified Commit e9f312e0 authored by Chen Tianjie's avatar Chen Tianjie Committed by GitHub
Browse files

Change stat_client_qbuf_limit_disconnections to atomic. (#12711)

In #12476 server.stat_client_qbuf_limit_disconnections was added. It is written in readQueryFromClient, which may be called by multiple threads when io-threads and io-threads-do-reads are turned on. Somehow we missed to make it an atomic variable.
parent 8d675950
...@@ -2706,7 +2706,7 @@ void readQueryFromClient(connection *conn) { ...@@ -2706,7 +2706,7 @@ void readQueryFromClient(connection *conn) {
sdsfree(ci); sdsfree(ci);
sdsfree(bytes); sdsfree(bytes);
freeClientAsync(c); freeClientAsync(c);
server.stat_client_qbuf_limit_disconnections++; atomicIncr(server.stat_client_qbuf_limit_disconnections, 1);
goto done; goto done;
} }
......
...@@ -2599,7 +2599,7 @@ void resetServerStats(void) { ...@@ -2599,7 +2599,7 @@ void resetServerStats(void) {
atomicSet(server.stat_total_reads_processed, 0); atomicSet(server.stat_total_reads_processed, 0);
server.stat_io_writes_processed = 0; server.stat_io_writes_processed = 0;
atomicSet(server.stat_total_writes_processed, 0); atomicSet(server.stat_total_writes_processed, 0);
server.stat_client_qbuf_limit_disconnections = 0; atomicSet(server.stat_client_qbuf_limit_disconnections, 0);
server.stat_client_outbuf_limit_disconnections = 0; server.stat_client_outbuf_limit_disconnections = 0;
for (j = 0; j < STATS_METRIC_COUNT; j++) { for (j = 0; j < STATS_METRIC_COUNT; j++) {
server.inst_metric[j].idx = 0; server.inst_metric[j].idx = 0;
...@@ -5831,12 +5831,14 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) { ...@@ -5831,12 +5831,14 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
(long long) elapsedUs(server.stat_last_eviction_exceeded_time): 0; (long long) elapsedUs(server.stat_last_eviction_exceeded_time): 0;
long long current_active_defrag_time = server.stat_last_active_defrag_time ? long long current_active_defrag_time = server.stat_last_active_defrag_time ?
(long long) elapsedUs(server.stat_last_active_defrag_time): 0; (long long) elapsedUs(server.stat_last_active_defrag_time): 0;
long long stat_client_qbuf_limit_disconnections;
atomicGet(server.stat_total_reads_processed, stat_total_reads_processed); atomicGet(server.stat_total_reads_processed, stat_total_reads_processed);
atomicGet(server.stat_total_writes_processed, stat_total_writes_processed); atomicGet(server.stat_total_writes_processed, stat_total_writes_processed);
atomicGet(server.stat_net_input_bytes, stat_net_input_bytes); atomicGet(server.stat_net_input_bytes, stat_net_input_bytes);
atomicGet(server.stat_net_output_bytes, stat_net_output_bytes); atomicGet(server.stat_net_output_bytes, stat_net_output_bytes);
atomicGet(server.stat_net_repl_input_bytes, stat_net_repl_input_bytes); atomicGet(server.stat_net_repl_input_bytes, stat_net_repl_input_bytes);
atomicGet(server.stat_net_repl_output_bytes, stat_net_repl_output_bytes); atomicGet(server.stat_net_repl_output_bytes, stat_net_repl_output_bytes);
atomicGet(server.stat_client_qbuf_limit_disconnections, stat_client_qbuf_limit_disconnections);
if (sections++) info = sdscat(info,"\r\n"); if (sections++) info = sdscat(info,"\r\n");
info = sdscatprintf(info, "# Stats\r\n" FMTARGS( info = sdscatprintf(info, "# Stats\r\n" FMTARGS(
...@@ -5888,7 +5890,7 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) { ...@@ -5888,7 +5890,7 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
"total_writes_processed:%lld\r\n", stat_total_writes_processed, "total_writes_processed:%lld\r\n", stat_total_writes_processed,
"io_threaded_reads_processed:%lld\r\n", server.stat_io_reads_processed, "io_threaded_reads_processed:%lld\r\n", server.stat_io_reads_processed,
"io_threaded_writes_processed:%lld\r\n", server.stat_io_writes_processed, "io_threaded_writes_processed:%lld\r\n", server.stat_io_writes_processed,
"client_query_buffer_limit_disconnections:%lld\r\n", server.stat_client_qbuf_limit_disconnections, "client_query_buffer_limit_disconnections:%lld\r\n", stat_client_qbuf_limit_disconnections,
"client_output_buffer_limit_disconnections:%lld\r\n", server.stat_client_outbuf_limit_disconnections, "client_output_buffer_limit_disconnections:%lld\r\n", server.stat_client_outbuf_limit_disconnections,
"reply_buffer_shrinks:%lld\r\n", server.stat_reply_buffer_shrinks, "reply_buffer_shrinks:%lld\r\n", server.stat_reply_buffer_shrinks,
"reply_buffer_expands:%lld\r\n", server.stat_reply_buffer_expands, "reply_buffer_expands:%lld\r\n", server.stat_reply_buffer_expands,
......
...@@ -1707,7 +1707,7 @@ struct redisServer { ...@@ -1707,7 +1707,7 @@ struct redisServer {
long long stat_io_writes_processed; /* Number of write events processed by IO / Main threads */ long long stat_io_writes_processed; /* Number of write events processed by IO / Main threads */
redisAtomic long long stat_total_reads_processed; /* Total number of read events processed */ redisAtomic long long stat_total_reads_processed; /* Total number of read events processed */
redisAtomic long long stat_total_writes_processed; /* Total number of write events processed */ redisAtomic long long stat_total_writes_processed; /* Total number of write events processed */
long long stat_client_qbuf_limit_disconnections; /* Total number of clients reached query buf length limit */ redisAtomic long long stat_client_qbuf_limit_disconnections; /* Total number of clients reached query buf length limit */
long long stat_client_outbuf_limit_disconnections; /* Total number of clients reached output buf length limit */ long long stat_client_outbuf_limit_disconnections; /* Total number of clients reached output buf length limit */
/* The following two are used to track instantaneous metrics, like /* The following two are used to track instantaneous metrics, like
* number of operations per second, network traffic. */ * number of operations per second, network traffic. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment