MDEV-33671: Remove hardcoded open-files-limit in safe_process.cc

The fixed limit of 1024 open files was preventing proper concurrency
testing in MTR. This commit removes the hardcoded value and adds a new
option to control the limit when running tests: --open-files-limit=X.

The default is still 1024, but it can now be changed when needed,
making it easier to test scenarios that require different number of
open file descriptors at the same time e.g: partition_notwin.test

Documentation is added to mtr's help file as well.

Signed-off-by: Vicențiu Ciorbaru <vicentiu@mariadb.org>
This commit is contained in:
Mohanad 2025-03-29 20:36:08 +02:00 committed by Vicențiu-Marian Ciorbaru
parent a524ec5951
commit 1f5d2b2010
3 changed files with 20 additions and 6 deletions

View File

@ -138,6 +138,7 @@ sub new {
my $error = delete($opts{'error'}); my $error = delete($opts{'error'});
my $verbose = delete($opts{'verbose'}) || $::opt_verbose; my $verbose = delete($opts{'verbose'}) || $::opt_verbose;
my $nocore = delete($opts{'nocore'}); my $nocore = delete($opts{'nocore'});
my $open_files_limit = delete($opts{'open_files_limit'});
my $host = delete($opts{'host'}); my $host = delete($opts{'host'});
my $shutdown = delete($opts{'shutdown'}); my $shutdown = delete($opts{'shutdown'});
my $user_data= delete($opts{'user_data'}); my $user_data= delete($opts{'user_data'});
@ -161,6 +162,8 @@ sub new {
push(@safe_args, "--verbose") if $verbose > 0; push(@safe_args, "--verbose") if $verbose > 0;
push(@safe_args, "--nocore") if $nocore; push(@safe_args, "--nocore") if $nocore;
push(@safe_args, "--open-files-limit=$open_files_limit") if $open_files_limit;
# Point the safe_process at the right parent if running on cygwin # Point the safe_process at the right parent if running on cygwin
push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN; push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN;

View File

@ -220,6 +220,7 @@ int main(int argc, char* const argv[] )
pid_t own_pid= getpid(); pid_t own_pid= getpid();
pid_t parent_pid= getppid(); pid_t parent_pid= getppid();
bool nocore = false; bool nocore = false;
int open_files_limit = 1024;
struct sigaction sa,sa_abort; struct sigaction sa,sa_abort;
sa.sa_handler= handle_signal; sa.sa_handler= handle_signal;
@ -268,7 +269,14 @@ int main(int argc, char* const argv[] )
} }
else if ( strncmp (arg, "--env ", 6) == 0 ) else if ( strncmp (arg, "--env ", 6) == 0 )
{ {
putenv(strdup(arg+6)); putenv(strdup(arg+6));
}
else if ( strncmp(arg, "--open-files-limit=", 19) == 0 )
{
const char* start = arg + 19;
open_files_limit = atoi(start);
if (open_files_limit <= 0)
die("Invalid value '%s' passed to --open-files-limit", start);
} }
else else
die("Unknown option: %s", arg); die("Unknown option: %s", arg);
@ -318,11 +326,8 @@ int main(int argc, char* const argv[] )
if (nocore) if (nocore)
setlimit(RLIMIT_CORE, 0, 0); setlimit(RLIMIT_CORE, 0, 0);
/* // Set open files limit
mysqld defaults depend on that. make test results stable and independent setlimit(RLIMIT_NOFILE, open_files_limit, open_files_limit);
from the environment
*/
setlimit(RLIMIT_NOFILE, 1024, 1024);
// Signal that child is ready // Signal that child is ready
buf= 37; buf= 37;

View File

@ -130,6 +130,8 @@ our $path_language;
our $path_current_testlog; our $path_current_testlog;
our $path_testlog; our $path_testlog;
our $opt_open_files_limit;
our $default_vardir; our $default_vardir;
our $opt_vardir; # Path to use for var/ dir our $opt_vardir; # Path to use for var/ dir
our $plugindir; our $plugindir;
@ -1277,6 +1279,7 @@ sub command_line_setup {
'list-options' => \$opt_list_options, 'list-options' => \$opt_list_options,
'skip-test-list=s' => \@opt_skip_test_list, 'skip-test-list=s' => \@opt_skip_test_list,
'xml-report=s' => \$opt_xml_report, 'xml-report=s' => \$opt_xml_report,
'open-files-limit=i', => \$opt_open_files_limit,
My::Debugger::options(), My::Debugger::options(),
My::CoreDump::options(), My::CoreDump::options(),
@ -5767,6 +5770,7 @@ sub start_mysqltest ($) {
append => 1, append => 1,
error => $path_current_testlog, error => $path_current_testlog,
verbose => $opt_verbose, verbose => $opt_verbose,
open_files_limit => $opt_open_files_limit,
); );
mtr_verbose("Started $proc"); mtr_verbose("Started $proc");
return $proc; return $proc;
@ -6065,6 +6069,8 @@ Misc options
timediff With --timestamp, also print time passed since timediff With --timestamp, also print time passed since
*previous* test started *previous* test started
max-connections=N Max number of open connection to server in mysqltest max-connections=N Max number of open connection to server in mysqltest
open-files-limit=N Max number of open files allowed for any of the children
of my_safe_process. Default is 1024.
report-times Report how much time has been spent on different report-times Report how much time has been spent on different
phases of test execution. phases of test execution.
stress=ARGS Run stress test, providing options to stress=ARGS Run stress test, providing options to