diff options
author | Sergei Golubchik <serg@mariadb.org> | 2019-05-04 13:11:25 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2019-05-07 18:40:36 +0200 |
commit | 15c79c41e435758392a1474fccf45978fec1e45c (patch) | |
tree | 434cf1c13283cb5abd236b8b8068127cec06b6ba /include | |
parent | 3d7e06d4ab1c108d61ac7dd4d09287580d77add5 (diff) | |
download | mariadb-git-15c79c41e435758392a1474fccf45978fec1e45c.tar.gz |
MDEV-17845 Extreme high open file limit used
SHOW STATUS LIKE 'Open_files' was showing 18446744073709551615
my_file_opened used statistic_increment/statistic_decrement,
so one-off errors were normal and expected. But they confused
monitoring tools, so let's move my_file_opened to use atomics.
Diffstat (limited to 'include')
-rw-r--r-- | include/my_pthread.h | 22 | ||||
-rw-r--r-- | include/my_sys.h | 3 |
2 files changed, 24 insertions, 1 deletions
diff --git a/include/my_pthread.h b/include/my_pthread.h index 264125a8fe3..ecb758bdc1d 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -23,6 +23,8 @@ #define ETIME ETIMEDOUT /* For FreeBSD */ #endif +#include <my_atomic.h> + #ifdef __cplusplus #define EXTERNC extern "C" extern "C" { @@ -803,6 +805,26 @@ extern uint thd_lib_detected; #define statistic_sub(V,C,L) (V)-=(C) #endif /* SAFE_STATISTICS */ +static inline void thread_safe_increment32(int32 *value) +{ + (void) my_atomic_add32_explicit(value, 1, MY_MEMORY_ORDER_RELAXED); +} + +static inline void thread_safe_decrement32(int32 *value) +{ + (void) my_atomic_add32_explicit(value, -1, MY_MEMORY_ORDER_RELAXED); +} + +static inline void thread_safe_increment64(int64 *value) +{ + (void) my_atomic_add64_explicit(value, 1, MY_MEMORY_ORDER_RELAXED); +} + +static inline void thread_safe_decrement64(int64 *value) +{ + (void) my_atomic_add64_explicit(value, -1, MY_MEMORY_ORDER_RELAXED); +} + /* No locking needed, the counter is owned by the thread */ diff --git a/include/my_sys.h b/include/my_sys.h index ddaceff8708..bc9cf903361 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -261,10 +261,11 @@ extern ulonglong my_collation_statistics_get_use_count(uint id); extern const char *my_collation_get_tailoring(uint id); /* statistics */ -extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; +extern ulong my_stream_opened, my_tmp_file_created; extern ulong my_file_total_opened; extern ulong my_sync_count; extern uint mysys_usage_id; +extern int32 my_file_opened; extern my_bool my_init_done, my_thr_key_mysys_exists; extern my_bool my_assert_on_error; extern myf my_global_flags; /* Set to MY_WME for more error messages */ |