summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-05-04 13:11:25 +0200
committerSergei Golubchik <serg@mariadb.org>2019-05-07 18:40:36 +0200
commit15c79c41e435758392a1474fccf45978fec1e45c (patch)
tree434cf1c13283cb5abd236b8b8068127cec06b6ba /mysys
parent3d7e06d4ab1c108d61ac7dd4d09287580d77add5 (diff)
downloadmariadb-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 'mysys')
-rw-r--r--mysys/my_fopen.c2
-rw-r--r--mysys/my_open.c9
-rw-r--r--mysys/my_static.c3
3 files changed, 6 insertions, 8 deletions
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index fbd84049700..e33d9d67925 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -223,7 +223,7 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
{
if (my_file_info[Filedes].type != UNOPEN)
{
- statistic_decrement(my_file_opened, &THR_LOCK_open); /* File is opened with my_open ! */
+ thread_safe_decrement32(&my_file_opened); /* File is opened with my_open ! */
}
else
{
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 92e46610100..aa3b0448cdb 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -105,7 +105,7 @@ int my_close(File fd, myf MyFlags)
{
my_free(name);
}
- statistic_decrement(my_file_opened, &THR_LOCK_open);
+ thread_safe_decrement32(&my_file_opened);
DBUG_RETURN(err);
} /* my_close */
@@ -133,13 +133,10 @@ File my_register_filename(File fd, const char *FileName, enum file_type
DBUG_ENTER("my_register_filename");
if ((int) fd >= MY_FILE_MIN)
{
+ thread_safe_increment32(&my_file_opened);
if ((uint) fd >= my_file_limit)
- {
- statistic_increment(my_file_opened,&THR_LOCK_open);
- DBUG_RETURN(fd); /* safeguard */
- }
+ DBUG_RETURN(fd);
my_file_info[fd].name = (char*) my_strdup(FileName, MyFlags);
- statistic_increment(my_file_opened,&THR_LOCK_open);
statistic_increment(my_file_total_opened,&THR_LOCK_open);
my_file_info[fd].type = type_of_file;
DBUG_PRINT("exit",("fd: %d",fd));
diff --git a/mysys/my_static.c b/mysys/my_static.c
index f2a9fbb7335..a8f520e656a 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -31,7 +31,7 @@ char *mysql_data_home= (char*) ".";
const char *my_progname= NULL, *my_progname_short= NULL;
char curr_dir[FN_REFLEN]= {0},
home_dir_buff[FN_REFLEN]= {0};
-ulong my_stream_opened=0,my_file_opened=0, my_tmp_file_created=0;
+ulong my_stream_opened=0,my_tmp_file_created=0;
ulong my_file_total_opened= 0;
int my_umask=0664, my_umask_dir=0777;
@@ -39,6 +39,7 @@ myf my_global_flags= 0;
my_bool my_assert_on_error= 0;
struct st_my_file_info my_file_info_default[MY_NFILE];
uint my_file_limit= MY_NFILE;
+int32 my_file_opened=0;
struct st_my_file_info *my_file_info= my_file_info_default;
/* From mf_brkhant */