Commit graph

110 commits

Author SHA1 Message Date
Sergei Golubchik
a34fd50ce1 MDEV-7478 log-basename unpredictable behavior in standalone mode
* fix /etc/init.d/mysql to use log-basename for pid-filename
* fix mysqld_safe not to force logging-to-file when log-basename is specified
2015-02-09 20:53:36 +01:00
Sergei Golubchik
3212aaa995 MDEV-6220 mysqldump will not backup database with --flush-logs parameter and log_error my.cnf parameter defined
some checks were "if [ -n "$err_log" ]", others were "if [ $want_syslog -eq 0 ]",
so when both are set, error log file was only partially initialized.
To avoid this ambiguity we reset want_syslog when error log file is used.
2015-01-19 17:18:24 +01:00
Sergei Golubchik
8fc3724421 MDEV-5958 Inconsitent handling of invalid arguments for mysqld_safe
issue an error for unrecognized options in the [mysqld_safe] section of my.cnf
but don't abort the script
2014-07-23 21:44:35 +02:00
Sergei Golubchik
fa3f8a18b2 mysql-5.5.34 merge
(some patches reverted, test case added)
2013-11-19 13:16:25 +01:00
Sergei Golubchik
41fc2493ed MDEV-5186 /usr/bin/mysqld_safe doesn't have NUMA options support
port mysqld_safe numa extensions from percona-server: --flush-caches and --numa-interleave
2013-11-11 09:31:13 +01:00
Sergei Golubchik
6e52631065 MDEV-4979 mysqld_safe section in my.cnf doesn't have mariadb equivalent
read also [mariadb_safe] section.
modify the manpage accordingly (and remove a netware-specific option from it)
2013-09-19 22:24:39 +02:00
Venkata Sidagam
06bcc2a410 Bug #16776528 RACE CONDITION CAN CAUSE MYSQLD TO REMOVE SOCKET FILE ERRANTLY
Reverting the patch. Because this change is not to me made for GA versions.
2013-09-09 20:21:02 +05:30
Anirudh Mangipudi
793b5835fd Bug #16776528 RACE CONDITION CAN CAUSE MYSQLD TO REMOVE SOCKET FILE ERRANTLY
Problem Description:
A mysqld_safe instance is started. An InnoDB crash recovery begins which takes
few seconds to complete. During this crash recovery process happening, another
mysqld_safe instance is started with the same server startup parameters. Since
the mysqld's pid file is absent during the crash recovery process the second
instance assumes there is no other process and tries to acquire a lock on the
ibdata files in the datadir.  But this step fails and the 2nd instance keeps 
retrying 100 times each with a delay of 1 second. Now after the 100 attempts, 
the server goes down, but while going down it hits the mysqld_safe script's 
cleanup section and without any check it blindly deletes the socket and pid 
files. Since no lock is placed on the socket file, it gets deleted.

Solution:
We create a mysqld_safe.pid file in the datadir, which protects the presence 
server instance resources by storing the mysqld_safe's process id in it. We
place a check if the mysqld_safe.pid file is existing in the datadir. If yes
then we check if the pid it contains is an active pid or not. If yes again,
then the scripts logs an error saying "A mysqld_safe instance is already 
running". Otherwise it will log the present mysqld_safe's pid into the 
mysqld_safe.pid file.
2013-08-12 23:06:58 +05:30
Anirudh Mangipudi
8757f39543 Bug #16776528 RACE CONDITION CAN CAUSE MYSQLD TO REMOVE SOCKET FILE ERRANTLY
Problem Description:
A mysqld_safe instance is started. An InnoDB crash recovery begins which takes
few seconds to complete. During this crash recovery process happening, another
mysqld_safe instance is started with the same server startup parameters. Since
the mysqld's pid file is absent during the crash recovery process the second
instance assumes there is no other process and tries to acquire a lock on the
ibdata files in the datadir.  But this step fails and the 2nd instance keeps 
retrying 100 times each with a delay of 1 second. Now after the 100 attempts, 
the server goes down, but while going down it hits the mysqld_safe script's 
cleanup section and without any check it blindly deletes the socket and pid 
files. Since no lock is placed on the socket file, it gets deleted.

Solution:
We create a mysqld_safe.pid file in the datadir, which protects the presence 
server instance resources by storing the mysqld_safe's process id in it. We
place a check if the mysqld_safe.pid file is existing in the datadir. If yes
then we check if the pid it contains is an active pid or not. If yes again,
then the scripts logs an error saying "A mysqld_safe instance is already 
running". Otherwise it will log the present mysqld_safe's pid into the 
mysqld_safe.pid file.
2013-08-12 21:54:50 +05:30
Sergei Golubchik
3bfd88d1d6 MDEV-4068 rpm scriptlet chown command dangerous
add --mysqld option to my_print_defaults
change server-postin script to use that
2013-03-06 09:32:13 +01:00
Michael Widenius
4cace76d4d Automatic merge 2013-03-01 18:09:06 +02:00
Sergei Golubchik
8161c6772d merge with mysql-5.5.30 minus few incorrect or not applicable changesets 2013-02-28 18:42:49 +01:00
Michael Widenius
2d78ef1d3b Added support for --crash-script in mysqld_safe.
Trivial cleanup

scripts/mysqld_safe.sh:
  Added support for --crash-script.
  Don't remove socket file (not needed as server will re-create it if needed)
  Patch by Eric Bergen
storage/maria/ha_maria.h:
  Removed not existing variable.
2013-02-28 08:42:05 +02:00
Sergei Golubchik
d3935adf7a mysql-5.5.29 merge 2013-01-15 19:13:32 +01:00
Sergei Golubchik
aca8e7ed6b 5.3 merge 2013-01-15 19:07:46 +01:00
Sergei Golubchik
bd87fed1dc 5.1 merge 2013-01-10 13:54:04 +01:00
Nirbhay Choubey
519daab67a Merge of patch for Bug#16046140 from mysql-5.1. 2012-12-27 17:36:11 +05:30
Nirbhay Choubey
825459b8cd Bug#16046140 BIN/MYSQLD_SAFE: TEST: ARGUMENT EXPECTED
Some shell interpreters do not support '-e' test
primary to construct conditions.

man test 1 (on S10)
...skip...
-e file True if file exists. (Not available in sh.)
...skip...

Hence, check for the existence of a file using
'-e' might result in a syntax error on such
shell programs.

Fixed by replacing it by '-f'.
2012-12-27 17:33:34 +05:30
Tatjana Azundris Nuernberg
b4a7756186 Bug#11764559: UMASK IS IGNORED BY ERROR LOG
mysqld_safe script did not heed MySQL specific environment variable
$UMASK, leading to divergent behavior between mysqld and mysqld_safe.

Patch adds an approximation of mysqld's behavior to mysqld_safe,
within the bounds dictated by attempt to have mysqld_safe run on
even the most basic of shells (proper '70s sh, not just bash
with a fancy symlink).

Patch also adds approximation of said behavior to mysqld_multi
(in perl).

(backport)

manual merge
2012-10-17 07:36:40 +01:00
Tatjana Azundris Nuernberg
b86aea6ce5 Bug#11764559: UMASK IS IGNORED BY ERROR LOG
mysqld_safe script did not heed MySQL specific environment variable
$UMASK, leading to divergent behavior between mysqld and mysqld_safe.

Patch adds an approximation of mysqld's behavior to mysqld_safe,
within the bounds dictated by attempt to have mysqld_safe run on
even the most basic of shells (proper '70s sh, not just bash
with a fancy symlink).

Patch also adds approximation of said behavior to mysqld_multi
(in perl).
2012-10-17 07:22:06 +01:00
Georgi Kodinov
4fb57747fe Bug #13548161: MYSQLD_SAFE IMPROVEMENTS FOR 5.5 ALLWAYS SETS PLUGIN_DIR
TO DEFAULT IGNOR

The test in mysqld_safe for the presence of the --plugin-dir and assigning a default
value to it were performed before the actual argument parsing.
This is wrong, as PLUGIN_DIR mysqld_safe code also uses MY_BASEDIR_VERSION to 
look for version specific plugin directory if present.
Fixed by moving the PLUGIN_DIR logic after the parse_arguments() call.
2012-08-27 15:30:58 +03:00
Michael Widenius
2887bfbe9e Fixed lp:886484 "nowatch option for mysqld (allow systemd)"
Added a --nowatch (with aliases --no-watch and --no-auto-restart) option to mysqld_safe that causes it to exit after
spawning mysqld.  We don't need mysqld_safe to restart mysqld after a crash, because systemd can do that just fine.

Based on code from Maarten Vanraes

scripts/mysqld_safe.sh:
  Added option --nowatch (with aliases --no-watch and --no-auto-restart)
2012-04-02 12:09:22 +03:00
Sergei Golubchik
4933d21e5d merge with mysql-5.5.21 2012-03-09 08:06:59 +01:00
Sergei Golubchik
38e3ae155d mysql-5.5 merge 2012-01-16 20:16:35 +01:00
unknown
e36692d0c2 fix for bug 11748060/34981 2011-11-17 09:13:43 +01:00
Georgi Kodinov
cc76953cde Bug #11761530: 54035: MSYQLD_SAFE BEHAVIOUR CONSUMES TOO MUCH CPU IF IT IS UNABLE TO RESTART MY
Added a trottling mechanism to mysqld_safe.
On every 5 sub-second restarts it will wait for a second before attempting again.
Note that this requires 'sleep' and 'date' command line utilities.
The code would adjust and will do nothing if any of them is not present.
2011-11-10 15:46:51 +02:00
Sergei Golubchik
76f0b94bb0 merge with 5.3
sql/sql_insert.cc:
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
  ******
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
sql/sql_table.cc:
  small cleanup
  ******
  small cleanup
2011-10-19 21:45:18 +02:00
Michael Widenius
7de98f2ffb Added --log-basename to mysqld to allow one to set the prefix for all logs with one command
Changed test suite to use --log-basename (to get the code tested)
Added --sync-sys=1 to test suite to speed it up.
Better error messages if something goes wrong with mysql_install_db


mysql-test/Makefile.am:
  Removed not existing directory
mysql-test/lib/My/ConfigFactory.pm:
  Use log-basename
  We had to also set 'log_error' as some test was explicitely using the old name
  Added 'sync-sys=1' to speed up test suite
mysql-test/r/variables-notembedded.result:
  Updated test results (variable relay_log is now set)
mysql-test/suite/binlog/t/binlog_delete_and_flush_index-master.opt:
  Force specific names for some log files.
mysql-test/suite/binlog/t/binlog_index-master.opt:
  Force specific names for some log files.
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt:
  Force specific names for some log files.
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test:
  Better error message if something goes wrong
mysql-test/suite/rpl/r/rpl_flushlog_loop.result:
  Updated results
mysql-test/suite/rpl/rpl_1slave_base.cnf:
  Use --log-basename
scripts/mysql_install_db.sh:
  More information to --help
  Write url to knowledge base if something goes wrong
  Fail at once if we can't create a database directory (no reason to continue and write a screenful of not related text)
scripts/mysqld_safe.sh:
  Also allow one to use --data for --datadir (common shortening)
  Added support for --log-basename
  Fail at once if we can't create a log directory
  Fixed bug where we used a pid file name without '.pid' extension
sql/log.cc:
  Create a log file name trough my_once_alloc()  (To get it automaticly freed at exit)
sql/mysql_priv.h:
  Added new prototype
sql/mysqld.cc:
  Added support for --log-basename
  Better help for a lot of log-filename related variables.
sql/rpl_rli.cc:
  Write information that one can use --log-basename
sql/set_var.cc:
  Add log_basename as a readonly variable
2011-03-23 17:59:41 +02:00
Michael Widenius
0fae0335d4 Ensure that all clients reads the appropriate 'client', client-mariadb and 'mariadb' sections from my.cnf
The mysqld server and all clients now reads the new client-server section
Fixed that mysqldumpslow supports new slow log formats and new mysqld --slow- options


client/mysql.cc:
  Read also client-server and client-mariadb sections.
client/mysql_upgrade.c:
  Read also client-server and client-mariadb sections.
client/mysqladmin.cc:
  Read also client-server and client-mariadb sections.
client/mysqlbinlog.cc:
  Read also client-server and client-mariadb sections.
client/mysqlcheck.c:
  Read also client-server and client-mariadb sections.
client/mysqldump.c:
  Read also client-server and client-mariadb sections.
client/mysqlimport.c:
  Read also client-server and client-mariadb sections.
client/mysqlshow.c:
  Read also client-server and client-mariadb sections.
client/mysqltest.cc:
  Read also client-server and client-mariadb sections.
extra/my_print_defaults.c:
  Updated help text
scripts/mysql_fix_privilege_tables.sh:
  Read also sections client client-server client-mariadb
scripts/mysql_install_db.pl.in:
  Also allow --data=* option
  Read also groups mariadb, server and client-server.
scripts/mysql_install_db.sh:
  Also allow --data=* option
  Read also groups mariadb, server and client-server.
  Added --lose-skip-pbxt to bootstrap
scripts/mysql_secure_installation.sh:
  Read also groups client-server and client-mariadb
scripts/mysqld_multi.sh:
  Read also group mariadb
scripts/mysqld_safe.sh:
  Read also groups mariadb server and client-server
scripts/mysqldumpslow.sh:
  Fixed to support new slow log formats
  Added sorting on -ae (aggregated number of retreived rows) and e (retrieved rows)
  Read also group 'mariadb'
  If there is many instances of same option, use last one.
  Get slow log file from options log-slow-queries=filename or query-log-file=filename
  Added support for future --log-basename option
sql-common/client.c:
  Read also groups 'client-server' and 'client-mariadb'
tests/mysql_client_test.c:
  Read also groups 'client-server' and 'client-mariadb'
tests/thread_test.c:
  Read also groups 'client-server' and 'client-mariadb'
2011-03-18 17:03:43 +02:00
Jonathan Perkin
c0d2440565 We can't rely on mysql_config for core functionality like plugins
as it may be part of a separate package.

Work out the likliest plugin directory using similar logic to the
data directory, and avoid the dependancy.
2010-07-05 22:19:14 +01:00
Jonathan Perkin
12fc3a9f38 bug#52737 plugin_dir is set to /usr/local/mysql/lib/plugin while
starting via mysqld_safe

Rather than hardcode the plugin directory, enhance mysql_config
to fix plugin path when running a relocated install, and use it
to provide the plugin directory to mysqld_safe.
2010-06-30 12:19:54 +01:00
Mats Kindahl
2de17fbb2b BUG#52737: plugin_dir is set to /usr/local/mysql/lib/plugin while starting via mysqld_safe
Incremental patch to fix plugin_dir from .../lib/plugin to .../lib/mysql/plugin.
2010-06-16 11:25:55 +02:00
Alexander Nozdrin
dabd4a1c55 Manual merge from mysql-trunk.
Conflicts:
  - mysql-test/r/partition.result
  - mysql-test/r/variables_debug.result
  - mysql-test/t/partition.test
  - mysql-test/t/variables_debug.test
2010-05-20 16:35:28 +04:00
Jonathan Perkin
ce2aabb712 Changes to build using CMake according to existing release packages:
- Update/fix file layouts for each package type, add new types for
   native package formats including deb, rpm and svr4.

 - Build all plugins, including debug versions

 - Update compiler flags to match current release

 - Add missing @VAR@ expansions

 - Install correct mysqclient library symlinks

 - Fix icc/ia64 builds

 - Fix install of libmysqld-debug

 - Don't include mysql_embedded

 - Remove unpackaged manual pages to avoid missing files warnings

 - Don't install mtr's test suite
2010-05-12 12:51:23 +01:00
Mats Kindahl
6363f34ff9 Bug #52737: plugin_dir is set to /usr/local/mysql/lib/plugin while starting
via mysqld_safe

Plugin dir was set to a hard-coded path instead of relative the base dir.

This patch fixes this by using a path relative the basedir instead of the
plugin directory indicated by the configuration.
2010-05-11 15:55:52 +02:00
Alexey Kopytov
456235a13c Automerge of mysql-5.1-bugteam to mysql-trunk-merge. 2010-04-11 11:17:42 +04:00
Georgi Kodinov
83dfeb2435 Bug #47095: Can't open_files_limit really be larger than 65535?
Several problems addressed:

1. The maximum value for --open_files_limit on non-windows boxes
is now raised to UINT_MAX (the maximum possible without significant
changes in the code). The maximum value on windows is kept to be
2048 due to a known limitation (bug 24509).

2. mysqld_safe now supports --open_files_limit=xx in addition to 
--open-files-limit=xx

3. mysqld_safe always passes through --open[_-]files[_-]limit
to the underlying mysqld. It used to pass it through only if it 
the user running the script has access to the root directory or
there was an --user argument specified.

4. Fixed a prototype in my_file.c to match its counterpart in 
the other #ifdef branch.
2010-04-09 14:47:18 +03:00
Mats Kindahl
cba4c8d1dd Bug #51938 plugin_dir gets bad default value
When building the script directory using a CMake-based build, both the
variables in config.h.cmake (including PLUGINDIR) and the variables in
CMakeList.txt (which includes pkgplugindir).

However, for autotools-based builds, only pkgplugindir is substituted,
which means that the plugin-path is not substituted.

This patch solves the problem by using pkgplugindir, which works on both
CMake-based and autotools-based builds, instead of PLUGINDIR.
2010-03-14 21:11:19 +01:00
Mats Kindahl
5c8d6c7473 Bug #49022: Plugins included into bin release cannot be
installed on debug version of server

When starting a server using mysqld_safe with the option
--mysqld-version=debug, the debug version of the server
is started. When attempting to load a plugin that is not
debug-built, the load will fail because a non-debug built
plugin use, e.g., fastmutex while the debug-built server
uses safemutex.

To solve this problem, mysqld_safe will set the plugin-dir
to use a directory where debug-built plugins are placed.

This patch sets the plugin dir to <plugin-dir>/whatever,
when mysqld-version=whatever, and just <plugin-dir> otherwise.
2010-03-01 23:40:24 +01:00
Vladislav Vaintroub
c514d75ebb Handle different installation layouts.
using  cmake option INSTALL_LAYOUT=STANDALONE would produce the layout as in 
tar.gz or zip packages.
INSTALL_LAYOUT=UNIX will produce unixish install layout  (with mysqld being in sbin subdirectory , libs in lib/mysql etc). This layout is used for RPM packages.

Subtle differences in both packages unfortunately lead to the need to recompile MySQL to use with other package type - as otherwise for example default plugins or data directories would be wrong set.

There are numerous other variables that  allow fine-tuning packaging layout. (INSTALL_BINDIR, INSTALL_LIBDIR , INSTALL_PLUGINDIR etc).

This options are different from autotools as they do not expect full paths to directories, but only subdirectory of CMAKE_INSTALL_PREFIX.

There are 2 special options that expect full directory paths
- MYSQL_DATADIR that defines default MYSQL data directory (autotools equivalent
is --localstatedir)
- SYSCONFDIR  can be added to search my.cnf search path (autotools equivalent is --sysconfdir)
2010-01-24 16:23:16 +01:00
Guilhem Bichot
27fca0ab17 Backport of the fix for BUG#40368 "mysqld_safe not honouring underscore same as dash on server options" from 6.0
(revision-id:guilhem@mysql.com-20090505113602-l12kxupeatve18dh).
Such bug led "mysqld_safe --core_file_size=#" to not work because mysqld_safe wouldn't recognize
that "ulimit -c" is needed; only --core-file-size=# worked. Same for --open_files_limit and other
options with _ where mysqld_safe needs to do something more than passing to mysqld.
Original fix by Erik Ljungstrom erik at ibiblio dot org ; slightly modified here.
Tested on all internally accessible Unix.
2009-11-18 21:36:17 +01:00
unknown
5ce71b22bf Add --malloc-lib=LIB option to mysqld_safe to LD_PRELOAD a shared library for mysqld 2009-09-23 01:26:08 +02:00
Staale Smedseng
a1212080ad Bug #44736 mysqld_safe's my_which() is broken and
doesn't find 'logger'

Due to a variable quoting mistake, the $PATH environment
variable isn't parsed correctly when searching for the
existence of the desired executable(s) (logger in this 
case).

This patch removes the quotes.
2009-05-25 18:21:40 +02:00
Jim Winstead
cc3f48b2e1 mysqld_safe could generate filenames with spaces and then didn't properly
quote them in later use. (Bug #33685, based on a patch by Hartmut Holzgraefe)
2009-05-07 17:25:23 -07:00
Chad MILLER
3b32eea2a2 Fix several quoting problems, and clean up IFS on failure in my_which(). 2009-03-16 15:28:06 -04:00
Chad MILLER
c924f116f6 Bug#39326: mysqld_safe doesn't use --basedir value in search of \
my_print_defaults

Now use basedir to set an unset ledir and to find the location of
my_print_defaults .
2009-03-16 14:54:28 -04:00
unknown
1d772c91e0 Bug #32679: mysqld_safe looks for errmsg.sys in wrong path
The fix for bug 28544 moved our package data from ./share/mysql
to ./share.  mysqld_safe had the old directory hard-coded.  The
fix is to use the @pkgdatadir@ and @prefix@ values, to adapt to
different ways of building the package.


scripts/make_binary_distribution.sh:
  Document that our build system explicitly overrides the @pkgfoo@ (e.g.,
  pkgdatadir, pkglibdir, etc.) variables when 'make' is called.
scripts/mysqld_safe.sh:
  Replace hard-coded "./share/mysql" with something like
  echo @pkgdatadir@ | sed -e s/^@prefix@//.
  
  Since the fix for bug 28544, this has been broken for mysql 5.1+,
  where the package data dir is "./share" instead of "./share/mysql".
2007-12-03 18:19:35 -07:00
unknown
6859d8b8c7 Merge zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-maint


mysql-test/lib/mtr_report.pl:
  Auto merged
mysql-test/mysql-test-run-shell.sh:
  Auto merged
netware/mysql_test_run.c:
  Auto merged
sql/mysqld.cc:
  Auto merged
storage/ndb/include/ndbapi/Ndb.hpp:
  Auto merged
scripts/mysqld_safe.sh:
  Manual merge.
2007-10-08 12:40:21 -04:00
unknown
6f2c2dc8e8 Change URLs.
Our web server has been restructured several times, and references
to it in our source code has stayed the same.  This patch from Paul
DuBois updates all URLs to modern semantics.


debian/po/ca.po:
  Change URLs.
debian/po/cs.po:
  Change URLs.
debian/po/da.po:
  Change URLs.
debian/po/gl.po:
  Change URLs.
debian/po/ja.po:
  Change URLs.
debian/po/pt_BR.po:
  Change URLs.
debian/po/sv.po:
  Change URLs.
debian/po/tr.po:
  Change URLs.
mysql-test/lib/mtr_report.pl:
  Change URLs.
mysql-test/mysql-test-run-shell.sh:
  Change URLs.
ndb/include/ndbapi/Ndb.hpp:
  Change URLs.
netware/mysql_test_run.c:
  Change URLs.
scripts/mysqld_safe.sh:
  Change URLs.
sql/mysqld.cc:
  Change URLs.
2007-10-05 13:16:54 -04:00
unknown
51f2b38f24 Finish up last syslog -> want_syslog change missed in r1.91,
fixing bug#30624


scripts/mysqld_safe.sh:
  Fix last syslog -> want_syslog.
2007-08-24 16:40:26 +02:00