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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
b487d8c2
Commit
b487d8c2
authored
Jun 02, 2006
by
ingo@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/mydev/mysql-5.1
into mysql.com:/home/mydev/mysql-5.1-amerge
parents
45ee3253
e4f12577
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
114 additions
and
43 deletions
+114
-43
mysql-test/r/lock_multi.result
mysql-test/r/lock_multi.result
+8
-0
mysql-test/t/lock_multi.test
mysql-test/t/lock_multi.test
+33
-0
sql/sql_db.cc
sql/sql_db.cc
+46
-14
storage/myisam/mi_check.c
storage/myisam/mi_check.c
+16
-18
storage/myisam/mi_key.c
storage/myisam/mi_key.c
+6
-8
storage/myisam/mi_update.c
storage/myisam/mi_update.c
+2
-1
storage/myisam/mi_write.c
storage/myisam/mi_write.c
+2
-1
storage/myisam/myisamdef.h
storage/myisam/myisamdef.h
+1
-1
No files found.
mysql-test/r/lock_multi.result
View file @
b487d8c2
...
@@ -50,6 +50,14 @@ Field Type Null Key Default Extra
...
@@ -50,6 +50,14 @@ Field Type Null Key Default Extra
a int(11) YES NULL
a int(11) YES NULL
unlock tables;
unlock tables;
drop table t1;
drop table t1;
CREATE DATABASE mysqltest_1;
FLUSH TABLES WITH READ LOCK;
DROP DATABASE mysqltest_1;
DROP DATABASE mysqltest_1;
ERROR HY000: Can't execute the query because you have a conflicting read lock
UNLOCK TABLES;
DROP DATABASE mysqltest_1;
ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist
use mysql;
use mysql;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
FLUSH TABLES;
FLUSH TABLES;
...
...
mysql-test/t/lock_multi.test
View file @
b487d8c2
...
@@ -128,6 +128,39 @@ unlock tables;
...
@@ -128,6 +128,39 @@ unlock tables;
drop
table
t1
;
drop
table
t1
;
#
#
# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
#
connect
(
con1
,
localhost
,
root
,,);
connect
(
con2
,
localhost
,
root
,,);
#
connection
con1
;
CREATE
DATABASE
mysqltest_1
;
FLUSH
TABLES
WITH
READ
LOCK
;
#
# With bug in place: acquire LOCK_mysql_create_table and
# wait in wait_if_global_read_lock().
connection
con2
;
send
DROP
DATABASE
mysqltest_1
;
--
sleep
1
#
# With bug in place: try to acquire LOCK_mysql_create_table...
# When fixed: Reject dropping db because of the read lock.
connection
con1
;
--
error
ER_CANT_UPDATE_WITH_READLOCK
DROP
DATABASE
mysqltest_1
;
UNLOCK
TABLES
;
#
connection
con2
;
reap
;
#
connection
default
;
disconnect
con1
;
disconnect
con2
;
# This must have been dropped by connection 2 already,
# which waited until the global read lock was released.
--
error
ER_DB_DROP_EXISTS
DROP
DATABASE
mysqltest_1
;
# Bug#16986 - Deadlock condition with MyISAM tables
# Bug#16986 - Deadlock condition with MyISAM tables
#
#
connection
locker
;
connection
locker
;
...
...
sql/sql_db.cc
View file @
b487d8c2
...
@@ -539,15 +539,26 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
...
@@ -539,15 +539,26 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
}
}
VOID
(
pthread_mutex_lock
(
&
LOCK_mysql_create_db
));
/*
Do not create database if another thread is holding read lock.
/* do not create database if another thread is holding read lock */
Wait for global read lock before acquiring LOCK_mysql_create_db.
After wait_if_global_read_lock() we have protection against another
global read lock. If we would acquire LOCK_mysql_create_db first,
another thread could step in and get the global read lock before we
reach wait_if_global_read_lock(). If this thread tries the same as we
(admin a db), it would then go and wait on LOCK_mysql_create_db...
Furthermore wait_if_global_read_lock() checks if the current thread
has the global read lock and refuses the operation with
ER_CANT_UPDATE_WITH_READLOCK if applicable.
*/
if
(
wait_if_global_read_lock
(
thd
,
0
,
1
))
if
(
wait_if_global_read_lock
(
thd
,
0
,
1
))
{
{
error
=
-
1
;
error
=
-
1
;
goto
exit2
;
goto
exit2
;
}
}
VOID
(
pthread_mutex_lock
(
&
LOCK_mysql_create_db
));
/* Check directory */
/* Check directory */
path_len
=
build_table_filename
(
path
,
sizeof
(
path
),
db
,
""
,
""
);
path_len
=
build_table_filename
(
path
,
sizeof
(
path
),
db
,
""
,
""
);
path
[
path_len
-
1
]
=
0
;
// Remove last '/' from path
path
[
path_len
-
1
]
=
0
;
// Remove last '/' from path
...
@@ -655,9 +666,9 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
...
@@ -655,9 +666,9 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
}
}
exit:
exit:
VOID
(
pthread_mutex_unlock
(
&
LOCK_mysql_create_db
));
start_waiting_global_read_lock
(
thd
);
start_waiting_global_read_lock
(
thd
);
exit2:
exit2:
VOID
(
pthread_mutex_unlock
(
&
LOCK_mysql_create_db
));
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
@@ -671,12 +682,23 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
...
@@ -671,12 +682,23 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
int
error
=
0
;
int
error
=
0
;
DBUG_ENTER
(
"mysql_alter_db"
);
DBUG_ENTER
(
"mysql_alter_db"
);
VOID
(
pthread_mutex_lock
(
&
LOCK_mysql_create_db
));
/*
Do not alter database if another thread is holding read lock.
/* do not alter database if another thread is holding read lock */
Wait for global read lock before acquiring LOCK_mysql_create_db.
After wait_if_global_read_lock() we have protection against another
global read lock. If we would acquire LOCK_mysql_create_db first,
another thread could step in and get the global read lock before we
reach wait_if_global_read_lock(). If this thread tries the same as we
(admin a db), it would then go and wait on LOCK_mysql_create_db...
Furthermore wait_if_global_read_lock() checks if the current thread
has the global read lock and refuses the operation with
ER_CANT_UPDATE_WITH_READLOCK if applicable.
*/
if
((
error
=
wait_if_global_read_lock
(
thd
,
0
,
1
)))
if
((
error
=
wait_if_global_read_lock
(
thd
,
0
,
1
)))
goto
exit2
;
goto
exit2
;
VOID
(
pthread_mutex_lock
(
&
LOCK_mysql_create_db
));
/*
/*
Recreate db options file: /dbpath/.db.opt
Recreate db options file: /dbpath/.db.opt
We pass MY_DB_OPT_FILE as "extension" to avoid
We pass MY_DB_OPT_FILE as "extension" to avoid
...
@@ -721,9 +743,9 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
...
@@ -721,9 +743,9 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
send_ok
(
thd
,
result
);
send_ok
(
thd
,
result
);
exit:
exit:
VOID
(
pthread_mutex_unlock
(
&
LOCK_mysql_create_db
));
start_waiting_global_read_lock
(
thd
);
start_waiting_global_read_lock
(
thd
);
exit2:
exit2:
VOID
(
pthread_mutex_unlock
(
&
LOCK_mysql_create_db
));
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
@@ -755,15 +777,26 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
...
@@ -755,15 +777,26 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
TABLE_LIST
*
dropped_tables
=
0
;
TABLE_LIST
*
dropped_tables
=
0
;
DBUG_ENTER
(
"mysql_rm_db"
);
DBUG_ENTER
(
"mysql_rm_db"
);
VOID
(
pthread_mutex_lock
(
&
LOCK_mysql_create_db
));
/*
Do not drop database if another thread is holding read lock.
/* do not drop database if another thread is holding read lock */
Wait for global read lock before acquiring LOCK_mysql_create_db.
After wait_if_global_read_lock() we have protection against another
global read lock. If we would acquire LOCK_mysql_create_db first,
another thread could step in and get the global read lock before we
reach wait_if_global_read_lock(). If this thread tries the same as we
(admin a db), it would then go and wait on LOCK_mysql_create_db...
Furthermore wait_if_global_read_lock() checks if the current thread
has the global read lock and refuses the operation with
ER_CANT_UPDATE_WITH_READLOCK if applicable.
*/
if
(
wait_if_global_read_lock
(
thd
,
0
,
1
))
if
(
wait_if_global_read_lock
(
thd
,
0
,
1
))
{
{
error
=
-
1
;
error
=
-
1
;
goto
exit2
;
goto
exit2
;
}
}
VOID
(
pthread_mutex_lock
(
&
LOCK_mysql_create_db
));
length
=
build_table_filename
(
path
,
sizeof
(
path
),
db
,
""
,
""
);
length
=
build_table_filename
(
path
,
sizeof
(
path
),
db
,
""
,
""
);
strmov
(
path
+
length
,
MY_DB_OPT_FILE
);
// Append db option file name
strmov
(
path
+
length
,
MY_DB_OPT_FILE
);
// Append db option file name
del_dbopt
(
path
);
// Remove dboption hash entry
del_dbopt
(
path
);
// Remove dboption hash entry
...
@@ -872,7 +905,6 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
...
@@ -872,7 +905,6 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
exit:
exit:
(
void
)
sp_drop_db_routines
(
thd
,
db
);
/* QQ Ignore errors for now */
(
void
)
sp_drop_db_routines
(
thd
,
db
);
/* QQ Ignore errors for now */
error
=
Events
::
drop_schema_events
(
thd
,
db
);
error
=
Events
::
drop_schema_events
(
thd
,
db
);
start_waiting_global_read_lock
(
thd
);
/*
/*
If this database was the client's selected database, we silently change the
If this database was the client's selected database, we silently change the
client's selected database to nothing (to have an empty SELECT DATABASE()
client's selected database to nothing (to have an empty SELECT DATABASE()
...
@@ -901,9 +933,9 @@ exit:
...
@@ -901,9 +933,9 @@ exit:
thd
->
db
=
0
;
thd
->
db
=
0
;
thd
->
db_length
=
0
;
thd
->
db_length
=
0
;
}
}
exit2:
VOID
(
pthread_mutex_unlock
(
&
LOCK_mysql_create_db
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_mysql_create_db
));
start_waiting_global_read_lock
(
thd
);
exit2:
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
...
storage/myisam/mi_check.c
View file @
b487d8c2
...
@@ -453,25 +453,24 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
...
@@ -453,25 +453,24 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
if
((
uint
)
share
->
base
.
auto_key
-
1
==
key
)
if
((
uint
)
share
->
base
.
auto_key
-
1
==
key
)
{
{
/* Check that auto_increment key is bigger than max key value */
/* Check that auto_increment key is bigger than max key value */
ulonglong
save_auto_value
=
info
->
s
->
state
.
auto_increment
;
ulonglong
auto_increment
;
info
->
s
->
state
.
auto_increment
=
0
;
info
->
lastinx
=
key
;
info
->
lastinx
=
key
;
_mi_read_key_record
(
info
,
0L
,
info
->
rec_buff
);
_mi_read_key_record
(
info
,
0L
,
info
->
rec_buff
);
updat
e_auto_increment
(
info
,
info
->
rec_buff
);
auto_increment
=
retriev
e_auto_increment
(
info
,
info
->
rec_buff
);
if
(
info
->
s
->
state
.
auto_increment
>
save_auto_value
)
if
(
auto_increment
>
info
->
s
->
state
.
auto_increment
)
{
{
mi_check_print_warning
(
param
,
mi_check_print_warning
(
param
,
"Auto-increment value: %s is smaller "
"Auto-increment value: %s is smaller
than max used value: %s"
,
"
than max used value: %s"
,
llstr
(
save_auto_value
,
buff2
),
llstr
(
info
->
s
->
state
.
auto_increment
,
buff2
),
llstr
(
info
->
s
->
state
.
auto_increment
,
buff
));
llstr
(
auto_increment
,
buff
));
}
}
if
(
param
->
testflag
&
T_AUTO_INC
)
if
(
param
->
testflag
&
T_AUTO_INC
)
{
{
set_if_bigger
(
info
->
s
->
state
.
auto_increment
,
auto_increment
);
set_if_bigger
(
info
->
s
->
state
.
auto_increment
,
set_if_bigger
(
info
->
s
->
state
.
auto_increment
,
param
->
auto_increment_value
);
param
->
auto_increment_value
);
}
}
else
info
->
s
->
state
.
auto_increment
=
save_auto_value
;
/* Check that there isn't a row with auto_increment = 0 in the table */
/* Check that there isn't a row with auto_increment = 0 in the table */
mi_extra
(
info
,
HA_EXTRA_KEYREAD
,
0
);
mi_extra
(
info
,
HA_EXTRA_KEYREAD
,
0
);
...
@@ -481,8 +480,8 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
...
@@ -481,8 +480,8 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
{
{
/* Don't count this as a real warning, as myisamchk can't correct it */
/* Don't count this as a real warning, as myisamchk can't correct it */
uint
save
=
param
->
warning_printed
;
uint
save
=
param
->
warning_printed
;
mi_check_print_warning
(
param
,
mi_check_print_warning
(
param
,
"Found row where the auto_increment "
"Found row where the auto_increment
column has the value 0"
);
"
column has the value 0"
);
param
->
warning_printed
=
save
;
param
->
warning_printed
=
save
;
}
}
mi_extra
(
info
,
HA_EXTRA_NO_KEYREAD
,
0
);
mi_extra
(
info
,
HA_EXTRA_NO_KEYREAD
,
0
);
...
@@ -4124,11 +4123,10 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
...
@@ -4124,11 +4123,10 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
}
}
else
else
{
{
ulonglong
auto_increment
=
(
repair_only
?
info
->
s
->
state
.
auto_increment
:
ulonglong
auto_increment
=
retrieve_auto_increment
(
info
,
record
);
param
->
auto_increment_value
);
info
->
s
->
state
.
auto_increment
=
0
;
update_auto_increment
(
info
,
record
);
set_if_bigger
(
info
->
s
->
state
.
auto_increment
,
auto_increment
);
set_if_bigger
(
info
->
s
->
state
.
auto_increment
,
auto_increment
);
if
(
!
repair_only
)
set_if_bigger
(
info
->
s
->
state
.
auto_increment
,
param
->
auto_increment_value
);
}
}
mi_extra
(
info
,
HA_EXTRA_NO_KEYREAD
,
0
);
mi_extra
(
info
,
HA_EXTRA_NO_KEYREAD
,
0
);
my_free
((
char
*
)
record
,
MYF
(
0
));
my_free
((
char
*
)
record
,
MYF
(
0
));
...
...
storage/myisam/mi_key.c
View file @
b487d8c2
...
@@ -509,20 +509,19 @@ int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf)
...
@@ -509,20 +509,19 @@ int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf)
/*
/*
Updat
e auto_increment info
Retriev
e auto_increment info
SYNOPSIS
SYNOPSIS
updat
e_auto_increment()
retriev
e_auto_increment()
info MyISAM handler
info MyISAM handler
record Row to update
record Row to update
IMPLEMENTATION
IMPLEMENTATION
Only replace the auto_increment value if it is higher than the previous
For signed columns we don't retrieve the auto increment value if it's
one. For signed columns we don't update the auto increment value if it's
less than zero.
less than zero.
*/
*/
void
updat
e_auto_increment
(
MI_INFO
*
info
,
const
byte
*
record
)
ulonglong
retriev
e_auto_increment
(
MI_INFO
*
info
,
const
byte
*
record
)
{
{
ulonglong
value
=
0
;
/* Store unsigned values here */
ulonglong
value
=
0
;
/* Store unsigned values here */
longlong
s_value
=
0
;
/* Store signed values here */
longlong
s_value
=
0
;
/* Store signed values here */
...
@@ -587,6 +586,5 @@ void update_auto_increment(MI_INFO *info,const byte *record)
...
@@ -587,6 +586,5 @@ void update_auto_increment(MI_INFO *info,const byte *record)
and if s_value == 0 then value will contain either s_value or the
and if s_value == 0 then value will contain either s_value or the
correct value.
correct value.
*/
*/
set_if_bigger
(
info
->
s
->
state
.
auto_increment
,
return
(
s_value
>
0
)
?
(
ulonglong
)
s_value
:
value
;
(
s_value
>
0
)
?
(
ulonglong
)
s_value
:
value
);
}
}
storage/myisam/mi_update.c
View file @
b487d8c2
...
@@ -164,7 +164,8 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec)
...
@@ -164,7 +164,8 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec)
key_changed
|=
HA_STATE_CHANGED
;
/* Must update index file */
key_changed
|=
HA_STATE_CHANGED
;
/* Must update index file */
}
}
if
(
auto_key_changed
)
if
(
auto_key_changed
)
update_auto_increment
(
info
,
newrec
);
set_if_bigger
(
info
->
s
->
state
.
auto_increment
,
retrieve_auto_increment
(
info
,
newrec
));
if
(
share
->
calc_checksum
)
if
(
share
->
calc_checksum
)
info
->
state
->
checksum
+=
(
info
->
checksum
-
old_checksum
);
info
->
state
->
checksum
+=
(
info
->
checksum
-
old_checksum
);
...
...
storage/myisam/mi_write.c
View file @
b487d8c2
...
@@ -149,7 +149,8 @@ int mi_write(MI_INFO *info, byte *record)
...
@@ -149,7 +149,8 @@ int mi_write(MI_INFO *info, byte *record)
info
->
state
->
checksum
+=
info
->
checksum
;
info
->
state
->
checksum
+=
info
->
checksum
;
}
}
if
(
share
->
base
.
auto_key
)
if
(
share
->
base
.
auto_key
)
update_auto_increment
(
info
,
record
);
set_if_bigger
(
info
->
s
->
state
.
auto_increment
,
retrieve_auto_increment
(
info
,
record
));
info
->
update
=
(
HA_STATE_CHANGED
|
HA_STATE_AKTIV
|
HA_STATE_WRITTEN
|
info
->
update
=
(
HA_STATE_CHANGED
|
HA_STATE_AKTIV
|
HA_STATE_WRITTEN
|
HA_STATE_ROW_CHANGED
);
HA_STATE_ROW_CHANGED
);
info
->
state
->
records
++
;
info
->
state
->
records
++
;
...
...
storage/myisam/myisamdef.h
View file @
b487d8c2
...
@@ -593,7 +593,7 @@ extern uint _mi_pack_key(MI_INFO *info,uint keynr,uchar *key,uchar *old,
...
@@ -593,7 +593,7 @@ extern uint _mi_pack_key(MI_INFO *info,uint keynr,uchar *key,uchar *old,
extern
int
_mi_read_key_record
(
MI_INFO
*
info
,
my_off_t
filepos
,
byte
*
buf
);
extern
int
_mi_read_key_record
(
MI_INFO
*
info
,
my_off_t
filepos
,
byte
*
buf
);
extern
int
_mi_read_cache
(
IO_CACHE
*
info
,
byte
*
buff
,
my_off_t
pos
,
extern
int
_mi_read_cache
(
IO_CACHE
*
info
,
byte
*
buff
,
my_off_t
pos
,
uint
length
,
int
re_read_if_possibly
);
uint
length
,
int
re_read_if_possibly
);
extern
void
updat
e_auto_increment
(
MI_INFO
*
info
,
const
byte
*
record
);
extern
ulonglong
retriev
e_auto_increment
(
MI_INFO
*
info
,
const
byte
*
record
);
extern
byte
*
mi_alloc_rec_buff
(
MI_INFO
*
,
ulong
,
byte
**
);
extern
byte
*
mi_alloc_rec_buff
(
MI_INFO
*
,
ulong
,
byte
**
);
#define mi_get_rec_buff_ptr(info,buf) \
#define mi_get_rec_buff_ptr(info,buf) \
...
...
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