summaryrefslogtreecommitdiff
path: root/sql/sys_vars.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-06-06 14:06:13 +0200
committerSergei Golubchik <sergii@pisem.net>2012-06-06 14:06:13 +0200
commit7eaf0975ac4e1752399fdc06209739171350ccf4 (patch)
tree4a056789ae46505989455ac36c3d3dbfa8c2948e /sql/sys_vars.cc
parentca5473f1db6dc63baffc736737e54bdffd6449a6 (diff)
parent4361c8645b45bca3f48b248241de0225bafbcc09 (diff)
downloadmariadb-git-7eaf0975ac4e1752399fdc06209739171350ccf4.tar.gz
merge
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r--sql/sys_vars.cc30
1 files changed, 9 insertions, 21 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index ca434821800..c8af1422388 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1596,14 +1596,15 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type)
}
/*
- Perform a 'FLUSH TABLES WITH READ LOCK'.
- This is a 3 step process:
- - [1] lock_global_read_lock()
- - [2] close_cached_tables()
- - [3] make_global_read_lock_block_commit()
- [1] prevents new connections from obtaining tables locked for write.
- [2] waits until all existing connections close their tables.
- [3] prevents transactions from being committed.
+ READ_ONLY=1 prevents write locks from being taken on tables and
+ blocks transactions from committing. We therefore should make sure
+ that no such events occur while setting the read_only variable.
+ This is a 2 step process:
+ [1] lock_global_read_lock()
+ Prevents connections from obtaining new write locks on
+ tables. Note that we can still have active rw transactions.
+ [2] make_global_read_lock_block_commit()
+ Prevents transactions from committing.
*/
read_only= opt_readonly;
@@ -1612,19 +1613,6 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type)
if (thd->global_read_lock.lock_global_read_lock(thd))
goto end_with_mutex_unlock;
- /*
- This call will be blocked by any connection holding a READ or WRITE lock.
- Ideally, we want to wait only for pending WRITE locks, but since:
- con 1> LOCK TABLE T FOR READ;
- con 2> LOCK TABLE T FOR WRITE; (blocked by con 1)
- con 3> SET GLOBAL READ ONLY=1; (blocked by con 2)
- can cause to wait on a read lock, it's required for the client application
- to unlock everything, and acceptable for the server to wait on all locks.
- */
- if ((result= close_cached_tables(thd, NULL, TRUE,
- thd->variables.lock_wait_timeout)))
- goto end_with_read_lock;
-
if ((result= thd->global_read_lock.make_global_read_lock_block_commit(thd)))
goto end_with_read_lock;