Commit b86ffcef authored by sasha@mysql.sashanet.com's avatar sasha@mysql.sashanet.com

merge

parents b531e001 1e76c806
...@@ -33,6 +33,21 @@ unlock tables; ...@@ -33,6 +33,21 @@ unlock tables;
connection con1; connection con1;
reap; reap;
#test if drop database will wait until we release the global read lock
connection con1;
drop database if exists foo;
create database foo;
create table foo.t1(n int);
insert into foo.t1 values (23);
flush tables with read lock;
connection con2;
send drop database foo;
connection con1;
select * from foo.t1;
unlock tables;
connection con2;
reap;
# test if dirty close releases global read lock # test if dirty close releases global read lock
connection con1; connection con1;
create table t1 (n int); create table t1 (n int);
......
...@@ -688,6 +688,8 @@ bool MYSQL_LOG::write(Query_log_event* event_info) ...@@ -688,6 +688,8 @@ bool MYSQL_LOG::write(Query_log_event* event_info)
{ {
Intvar_log_event e((uchar)LAST_INSERT_ID_EVENT, thd->last_insert_id); Intvar_log_event e((uchar)LAST_INSERT_ID_EVENT, thd->last_insert_id);
e.set_log_seq(thd, this); e.set_log_seq(thd, this);
if(thd->server_id)
e.server_id = thd->server_id;
if (e.write(file)) if (e.write(file))
goto err; goto err;
} }
......
...@@ -218,5 +218,5 @@ ...@@ -218,5 +218,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -212,5 +212,5 @@ ...@@ -212,5 +212,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -209,5 +209,5 @@ ...@@ -209,5 +209,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -213,5 +213,5 @@ ...@@ -213,5 +213,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -209,5 +209,5 @@ ...@@ -209,5 +209,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -212,5 +212,5 @@ ...@@ -212,5 +212,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -209,5 +209,5 @@ ...@@ -209,5 +209,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -211,5 +211,5 @@ ...@@ -211,5 +211,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -209,5 +209,5 @@ ...@@ -209,5 +209,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -211,5 +211,5 @@ ...@@ -211,5 +211,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -209,5 +209,5 @@ ...@@ -209,5 +209,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -211,5 +211,5 @@ ...@@ -211,5 +211,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -211,5 +211,5 @@ ...@@ -211,5 +211,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -213,5 +213,5 @@ ...@@ -213,5 +213,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -209,5 +209,5 @@ ...@@ -209,5 +209,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -213,5 +213,5 @@ ...@@ -213,5 +213,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -212,5 +212,5 @@ ...@@ -212,5 +212,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -217,5 +217,5 @@ ...@@ -217,5 +217,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -210,5 +210,5 @@ ...@@ -210,5 +210,5 @@
"Lock wait timeout exceeded", "Lock wait timeout exceeded",
"The total number of locks exceeds the lock table size", "The total number of locks exceeds the lock table size",
"Update locks cannot be acquired during a READ UNCOMMITTED transaction", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Error connecting to master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Error running query on master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -206,8 +206,8 @@ ...@@ -206,8 +206,8 @@
"Kunde inte starta en tråd för replikering", "Kunde inte starta en tråd för replikering",
"Användare '%-.64s' har redan 'max_user_connections' aktiva inloggningar", "Användare '%-.64s' har redan 'max_user_connections' aktiva inloggningar",
"Du kan endast använda konstant-uttryck med SET", "Du kan endast använda konstant-uttryck med SET",
"Tiden att få ett lås var för lång", "Lock wait timeout exceeded",
"Antal lås är större än vad som ryms i lock tabellen", "The total number of locks exceeds the lock table size",
"Du kan inte låsa tabeller/poster under READ UNCOMMITTED", "Update locks cannot be acquired during a READ UNCOMMITTED transaction",
"Fick fel vid inloggning till master: %-.128s", "DROP DATABASE not allowed while thread is holding global read lock",
"Fick fel vid exekvering av fråga på master: %-.128s", "CREATE DATABASE not allowed while thread is holding global read lock",
...@@ -1440,7 +1440,7 @@ the slave thread with \"mysqladmin start-slave\". We stopped at log \ ...@@ -1440,7 +1440,7 @@ the slave thread with \"mysqladmin start-slave\". We stopped at log \
{ {
// show a little mercy, allow slave to read one more event // show a little mercy, allow slave to read one more event
// before cutting him off - otherwise he gets stuck // before cutting him off - otherwise he gets stuck
// on Invar events, since they do not advance the offset // on Intvar events, since they do not advance the offset
// immediately // immediately
if (++stuck_count > 2) if (++stuck_count > 2)
events_till_disconnect++; events_till_disconnect++;
......
...@@ -39,6 +39,32 @@ int mysql_create_db(THD *thd, char *db, uint create_options) ...@@ -39,6 +39,32 @@ int mysql_create_db(THD *thd, char *db, uint create_options)
DBUG_ENTER("mysql_create_db"); DBUG_ENTER("mysql_create_db");
VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
VOID(pthread_mutex_lock(&LOCK_open));
// do not create database if another thread is holding read lock
if (global_read_lock)
{
if (thd->global_read_lock)
{
net_printf(&thd->net, ER_CREATE_DB_WITH_READ_LOCK);
VOID(pthread_mutex_unlock(&LOCK_open));
goto exit;
}
while (global_read_lock && ! thd->killed)
{
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
}
if (thd->killed)
{
net_printf(&thd->net, ER_SERVER_SHUTDOWN);
VOID(pthread_mutex_unlock(&LOCK_open));
goto exit;
}
}
VOID(pthread_mutex_unlock(&LOCK_open));
/* Check directory */ /* Check directory */
(void)sprintf(path,"%s/%s", mysql_data_home, db); (void)sprintf(path,"%s/%s", mysql_data_home, db);
...@@ -117,6 +143,26 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists) ...@@ -117,6 +143,26 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists)
VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
// do not drop database if another thread is holding read lock
if (global_read_lock)
{
if (thd->global_read_lock)
{
net_printf(&thd->net, ER_DROP_DB_WITH_READ_LOCK);
goto exit;
}
while (global_read_lock && ! thd->killed)
{
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
}
if (thd->killed)
{
net_printf(&thd->net, ER_SERVER_SHUTDOWN);
goto exit;
}
}
(void) sprintf(path,"%s/%s",mysql_data_home,db); (void) sprintf(path,"%s/%s",mysql_data_home,db);
unpack_dirname(path,path); // Convert if not unix unpack_dirname(path,path); // Convert if not unix
/* See if the directory exists */ /* See if the directory exists */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment