Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
768deddc
Commit
768deddc
authored
Jul 28, 2001
by
monty@tik.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated LOCK TABLES manual section
Applied patch for mysqlhotcopy Fixed open-files-size option in safe_mysqld
parent
40aa7c6d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
43 deletions
+75
-43
Docs/manual.texi
Docs/manual.texi
+40
-27
scripts/mysqlhotcopy.sh
scripts/mysqlhotcopy.sh
+34
-13
scripts/safe_mysqld.sh
scripts/safe_mysqld.sh
+1
-3
No files found.
Docs/manual.texi
View file @
768deddc
...
...
@@ -7585,7 +7585,7 @@ You should also add /etc/my.cnf:
@example
[safe_mysqld]
open
_files_
limit=8192
open
-files-
limit=8192
@end example
The above should allow @strong{MySQL} to create up to 8192 connections/files.
...
...
@@ -22952,17 +22952,9 @@ are locked by the current thread are automatically unlocked when the
thread issues another @code{LOCK TABLES}, or when the connection to the
server is closed.
The main reasons to use @code{LOCK TABLES} are:
@itemize @bullet
@item
Emulate transactions with not transaction safe tables.
@item
To get more speed with @code{MyISAM} tables when inserting/updating data
over many statements. The main reason this gives more speed is that
@strong{MySQL} will not flush the key cache for the locked tables until
@code{UNLOCK TABLES} is called.
@end itemize
The main reasons to use @code{LOCK TABLES} are for emulating transactions
or getting more speed when updating tables. This is explained in more
detail later.
If a thread obtains a @code{READ} lock on a table, that thread (and all other
threads) can only read from the table. If a thread obtains a @code{WRITE}
...
...
@@ -22975,8 +22967,10 @@ execute while the lock is held. This can't however be used if you are
going to manipulate the database files outside @strong{MySQL} while you
hold the lock.
Each thread waits (without timing out) until it obtains all the locks it has
requested.
When you use @code{LOCK TABLES}, you must lock all tables that you are
going to use and you must use the same alias that you are going to use
in your queries! If you are using a table multiple times in a query
(with aliases), you must get a lock for each alias!
@code{WRITE} locks normally have higher priority than @code{READ} locks, to
ensure that updates are processed as soon as possible. This means that if one
...
...
@@ -22988,15 +22982,32 @@ locks while the thread is waiting for the @code{WRITE} lock. You should only
use @code{LOW_PRIORITY WRITE} locks if you are sure that there will
eventually be a time when no threads will have a @code{READ} lock.
@code{LOCK TABLES} and @code{UNLOCK TABLES} both commits any active
transactions.
@code{LOCK TABLES} works as follows:
@enumerate
@item
Sort all tables to be locked in a internally defined order (from the
user standpoint the order is undefined).
@item
If a table is locked with a read and a write lock, put the write lock
before the read lock.
@item
Lock one table at a time until the thread gets all locks.
@end enumerate
This policy ensures that table locking is deadlock free. There is
however other things one needs to be aware of with this schema:
When you use @code{LOCK TABLES}, you must lock all tables that you are
going to use and you must use the same alias that you are going to use
in your queries! If you are using a table multiple times in a query
(with aliases), you must get a lock for each alias! This policy ensures
that table locking is deadlock free and makes the locking code smaller,
simpler and much faster.
If you are using a @code{LOW_PRIORITY_WRITE} lock for a table, this
means only that @strong{MySQL} will wait for this particlar lock until
there is no threads that wants a @code{READ} lock. When the thread has
got the @code{WRITE} lock and is waiting to get the lock for the next
table in the lock table list, all other threads will wait for the
@code{WRITE} lock to be released. If this becomes a serious problem
with your application, you should consider converting some of your
tables to transactions safe tables.
You can safely kill a thread that is waiting for a table lock with
@code{KILL}. @xref{KILL}.
Note that you should @strong{NOT} lock any tables that you are using with
@code{INSERT DELAYED}. This is because that in this case the @code{INSERT}
...
...
@@ -23013,6 +23024,12 @@ If you are going to run many operations on a bunch of tables, it's much
faster to lock the tables you are going to use. The downside is, of course,
that no other thread can update a @code{READ}-locked table and no other
thread can read a @code{WRITE}-locked table.
The reason some things are faster under @code{LOCK TABLES} is that
@strong{MySQL} will not flush the key cache for the locked tables until
@code{UNLOCK TABLES} is called (normally the key cache is flushed after
each SQL statement). This speeds up inserting/updateing/deletes on
@code{MyISAM} tables.
@item
If you are using a table handler in @strong{MySQL} that doesn't support
transactions, you must use @code{LOCK TABLES} if you want to ensure that
...
...
@@ -23044,7 +23061,7 @@ table in the server and implemented with @code{pthread_mutex_lock()} and
See @ref{Internal locking}, for more information on locking policy.
You can
also
lock all tables in all databases with read locks with the
You can lock all tables in all databases with read locks with the
@code{FLUSH TABLES WITH READ LOCK} command. @xref{FLUSH}. This is very
convenient way to get backups if you have a file system, like Veritas,
that can take snapshots in time.
...
...
@@ -43898,8 +43915,6 @@ more than one way to compute}
@item @uref{http://www.spylog.ru/, SpyLOG ; A very popular Web counter site}
@item @uref{http://www.tucows.com/, TuCows Network; Free Software archive}
@item @uref{http://www.jobvertise.com,Jobvertise: Post and search for jobs}
@item @uref{http://www.musicdatabase.com, The Music Database}
...
...
@@ -45486,8 +45501,6 @@ For making @code{mysqlaccess} more secure.
@item Albert Chin-A-Young.
Configure updates for Tru64, large file support and better TCP wrappers
support.
@item Valueclick Inc.
For sponsoring the optimize section in this manual.
@end table
Other contributors, bugfinders, and testers: James H. Thompson, Maurizio
scripts/mysqlhotcopy.sh
View file @
768deddc
...
...
@@ -223,18 +223,27 @@ foreach my $rdb ( @db_desc ) {
my
$db
=
$rdb
->
{
src
}
;
eval
{
$dbh
->do
(
"use
$db
"
)
;
}
;
die
"Database '
$db
' not accessible:
$@
"
if
(
$@
)
;
my @dbh_tables
=
$dbh
->
func
(
'_ListTables'
)
;
my @dbh_tables
=
$dbh
->
tables
(
)
;
## generate regex for tables/files
my
$t_regex
=
$rdb
->
{
t_regex
}
;
## assign temporary regex
my
$negated
=
$t_regex
=
~
tr
/~//d
;
## remove and count negation operator: we don't allow ~ in table names
$t_regex
=
qr/
$t_regex
/
;
## make regex string from user regex
my
$t_regex
;
my
$negated
;
if
(
$rdb
->
{
t_regex
})
{
$t_regex
=
$rdb
->
{
t_regex
}
;
## assign temporary regex
$negated
=
$t_regex
=
~
tr
/~//d
;
## remove and count
## negation operator: we
## don't allow ~ in table
## names
$t_regex
=
qr/
$t_regex
/
;
## make regex string from
## user regex
## filter (out) tables specified in t_regex
print
"Filtering tables with '
$t_regex
'
\n
"
if
$opt
{
debug
}
;
@dbh_tables
=
(
$negated
?
grep
{
$_
!
~
$t_regex
}
@dbh_tables
:
grep
{
$_
=
~
$t_regex
}
@dbh_tables
)
;
}
## get list of files to copy
my
$db_dir
=
"
$datadir
/
$db
"
;
...
...
@@ -249,10 +258,18 @@ foreach my $rdb ( @db_desc ) {
closedir
(
DBDIR
)
;
## filter (out) files specified in t_regex
my @db_files
=
(
$negated
my @db_files
;
if
(
$rdb
->
{
t_regex
})
{
@db_files
=
(
$negated
?
grep
{
$db_files
{
$_
}
!
~
$t_regex
}
keys %db_files
:
grep
{
$db_files
{
$_
}
=
~
$t_regex
}
keys %db_files
)
;
}
else
{
@db_files
=
keys %db_files
;
}
@db_files
=
sort
@db_files
;
my @index_files
=()
;
## remove indices unless we're told to keep them
...
...
@@ -809,3 +826,7 @@ Ask Bjoern Hansen - Cleanup code to fix a few bugs and enable -w again.
Emil S. Hansen - Added resetslave and resetmaster.
Jeremy D. Zawodny - Removed depricated DBI calls. Fixed bug which
resulted
in
nothing being copied when a regexp was specified but no
database name
(
s
)
.
scripts/safe_mysqld.sh
View file @
768deddc
...
...
@@ -46,10 +46,8 @@ parse_arguments() {
# safe_mysqld-specific options - must be set in my.cnf ([safe_mysqld])!
--ledir
=
*
)
ledir
=
`
echo
"
$arg
"
|
sed
-e
"s;--ledir=;;"
`
;;
--err-log
=
*
)
err_log
=
`
echo
"
$arg
"
|
sed
-e
"s;--err-log=;;"
`
;;
# QQ The --open-files should be removed
--open-files
=
*
)
open_files
=
`
echo
"
$arg
"
|
sed
-e
"s;--open-files=;;"
`
;;
--open-files-limit
=
*
)
open_files
=
`
echo
"
$arg
"
|
sed
-e
"s;--open-files-limit=;;"
`
;;
--core-file-size
=
*
)
core_file_size
=
`
echo
"
$arg
"
|
sed
-e
"s;--core
_file_
size=;;"
`
;;
--core-file-size
=
*
)
core_file_size
=
`
echo
"
$arg
"
|
sed
-e
"s;--core
-file-
size=;;"
`
;;
--timezone
=
*
)
TZ
=
`
echo
"
$arg
"
|
sed
-e
"s;--timezone=;;"
`
;
export
TZ
;
;;
--mysqld
=
*
)
MYSQLD
=
`
echo
"
$arg
"
|
sed
-e
"s;--mysqld=;;"
`
;;
--mysqld-version
=
*
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment