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
ed2e4755
Commit
ed2e4755
authored
May 29, 2006
by
ingo@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/mydev/mysql-5.0-bug19815
into mysql.com:/home/mydev/mysql-5.1-bug19815
parents
eddfcc14
d00441e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
14 deletions
+89
-14
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
+35
-0
sql/sql_db.cc
sql/sql_db.cc
+46
-14
No files found.
mysql-test/r/lock_multi.result
View file @
ed2e4755
...
@@ -50,3 +50,11 @@ Field Type Null Key Default Extra
...
@@ -50,3 +50,11 @@ 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
mysql-test/t/lock_multi.test
View file @
ed2e4755
...
@@ -126,3 +126,38 @@ show columns from t1;
...
@@ -126,3 +126,38 @@ show columns from t1;
connection
locker
;
connection
locker
;
unlock
tables
;
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
;
sql/sql_db.cc
View file @
ed2e4755
...
@@ -538,16 +538,27 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
...
@@ -538,16 +538,27 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
my_error
(
ER_DB_CREATE_EXISTS
,
MYF
(
0
),
db
);
my_error
(
ER_DB_CREATE_EXISTS
,
MYF
(
0
),
db
);
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 */
(
void
)
evex_drop_db_events
(
thd
,
db
);
/* QQ Ignore errors for now */
(
void
)
evex_drop_db_events
(
thd
,
db
);
/* QQ Ignore errors for now */
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 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
...
@@ -901,9 +933,9 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
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
);
}
}
...
...
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