- 08 Dec, 2009 13 commits
-
-
Jon Olav Hauglid authored
Bug #43272 HANDLER SQL command does not work under LOCK TABLES HANDLER commands are now explicitly disallowed in LOCK TABLES mode. Before, HANDLER OPEN gave the misleading error message: "Table x was not locked with LOCK TABLES". This patch changes HANDLER OPEN/READ/CLOSE to give ER_LOCK_OR_ACTIVE_TRANSACTION "Can't execute the given command because you have active locked tables or an active transaction" in LOCK TABLES mode. Test case added to lock.test.
-
Jon Olav Hauglid authored
Bug #45067 Assertion `stmt_da->is_error()' in Delayed_insert::open_and_lock_table The assert was triggered when delayed insert was killed by another connection using mysql_notify_thread_having_shared_lock(). During handling of thd->killed, thd.fatal_error() was called without a previous call to my_error() which triggered the assert. This patch allows the assert to pass if thd->killed has been set.
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2617.69.24 committer: Konstantin Osipov <kostja@sun.com> branch nick: 5.4-42546 timestamp: Fri 2009-08-14 19:22:05 +0400 message: A pre-requisite for a fix for Bug#42546 "Backup: RESTORE fails, thinking it finds an existing table" Back-port from WL 148 "Foreign keys" feature tree a patch that introduced Prelocking_strategy class -- a way to parameterize open_tables() behaviour, implemented by Dmitry Lenev. (Part of WL#4284). sql/sql_base.cc: Implement different prelocking strategies. Use an instance of prelocking_strategy in open_tables(). sql/sql_class.h: Add declarations for class Prelocking_strategy. sql/sql_lex.h: Add a helper method to access last table of the global table list (lex->query_tables). sql/sql_parse.cc: Use a special prelocking strategy when locking tables for LOCK TABLES. sql/sql_table.cc: Use normal open_and_lock_tables_derived() in ALTER TABLE. sql/sql_yacc.yy: Modify the grammar to not pollute the global table list with tables that should not be opened.
-
Konstantin Osipov authored
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2617.69.21 committer: Konstantin Osipov <kostja@sun.com> branch nick: 5.4-4284-1-assert timestamp: Thu 2009-08-13 20:13:55 +0400 message: A fix and a test case for Bug#46610 "MySQL 5.4.4: MyISAM MRG engine crash on auto-repair of child". Also fixes Bug#42862 "Crash on failed attempt to open a children of a merge table". MERGE engine needs to extend the global table list with TABLE_LIST elements for child tables, so that they are opened and locked. Previously these table list elements were allocated in memory of ha_myisammrg object (MERGE engine handler). That would lead to access to freed memory in recover_from_failed_open_table_attempt(), which would try to recover a MERGE table child (MyISAM table) and use for that TABLE_LIST of that child. But by the time recover_from_failed_open_table_attempt() is invoked, ha_myisammrg object that owns this TABLE_LIST may be destroyed, and thus TABLE_LIST memory freed. The fix is to ensure that TABLE_LIST elements that are added to the global table list (lex->query_tables) are always allocated in thd->mem_root, which is not destroyed until end of execution. If previously TABLE_LIST elements were allocated at ha_myisammrg::open() (i.e. when the TABLE object was created and added to the table cache), now they are allocated in ha_myisammrg::add_chidlren_list() (i.e. right after "open" of the merge parent in open_tables()). We still create a list of children names at ha_myisammrg::open() to use as a basis for creation of TABLE_LISTs, that allows to avoid reading the merge handler data file on every execution. mysql-test/r/merge_recover.result: Test results for Bug#46610. mysql-test/t/merge_recover-master.opt: Option file for Bug#46610 test (need a new test because of that option, which is not tested anywhere else). mysql-test/t/merge_recover.test: Add a test case for Bug#46610. sql/table.h: MERGE child child_def_version is now moved from TABLE_LIST to MERGE engine specific data structure. storage/myisammrg/ha_myisammrg.cc: Introduce an auxiliary structure to keep MERGE child name and definition version. A list of Mrg_child_def is created in ha_myisammrg::open() and reused in ha_myisammrg::add_children_list().
-
Jon Olav Hauglid authored
Bug #22876 Four-way deadlock This bug was fixed as a part of Bug#989 "If DROP TABLE while there's an active transaction, wrong binlog order" A statement which would have caused circular wait will now be aborted with ER_LOCK_DEADLOCK. Test case based on bug description added to innodb_mysql_lock.test. Note that innodb_lock_wait_timeout is set to 5 mins to prevent race conditions in the test.
-
Jon Olav Hauglid authored
Bug #39675 rename tables on innodb tables with pending transactions causes slave data issue Bug was already fixed as part of patch for Bug#989 (If DROP TABLE while there's an active transaction, wrong binlog order) Test case added to rpl_innodb.test.
-
Jon Olav Hauglid authored
Bug #45066 FLUSH TABLES WITH READ LOCK deadlocks against LOCK TABLE Test coverage for combinations of LOCK TABLE READ / WRITE and FLUSH TABLES / FLUSH TABLES WITH READ LOCK added to lock.test. LOCK and FLUSH are executed sequentially from one connection.
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2617.69.20 committer: Konstantin Osipov <kostja@sun.com> branch nick: 5.4-4284-1-assert timestamp: Thu 2009-08-13 18:29:55 +0400 message: WL#4284 "Transactional DDL locking" A review fix. Since WL#4284 implementation separated MDL_request and MDL_ticket, MDL_request becamse a utility object necessary only to get a ticket. Store it by-value in TABLE_LIST with the intent to merge MDL_request::key with table_list->table_name and table_list->db in future. Change the MDL subsystem to not require MDL_requests to stay around till close_thread_tables(). Remove the list of requests from the MDL context. Requests for shared metadata locks acquired in open_tables() are only used as a list in recover_from_failed_open_table_attempt(), which calls mdl_context.wait_for_locks() for this list. To keep such list for recover_from_failed_open_table_attempt(), introduce a context class (Open_table_context), that collects all requests. A lot of minor cleanups and simplications that became possible with this change. sql/event_db_repository.cc: Remove alloc_mdl_requests(). Now MDL_request instance is a member of TABLE_LIST, and init_one_table() initializes it. sql/ha_ndbcluster_binlog.cc: Remove now unnecessary declaration and initialization of binlog_mdl_request. sql/lock.cc: No need to allocate MDL requests in lock_table_names() now. sql/log.cc: Use init_one_table() method, remove alloc_mdl_requests(), which is now unnecessary. sql/log_event.cc: No need to allocate mdl_request separately now. Use init_one_table() method. sql/log_event_old.cc: Update to the new signature of close_tables_for_reopen(). sql/mdl.cc: Update try_acquire_exclusive_lock() to be more easy to use. Function lock_table_name_if_not_cached() has been removed. Make acquire_shared_lock() signature consistent with try_acquire_exclusive_lock() signature. Remove methods that are no longer used. Update comments. sql/mdl.h: Implement an assignment operator that doesn't copy MDL_key (MDL_key::operator= is private and should remain private). This is a hack to work-around assignment of TABLE_LIST by value in several places. Such assignments violate encapsulation, since only perform a shallow copy. In most cases these assignments are a hack on their own. sql/mysql_priv.h: Update signatures of close_thread_tables() and close_tables_for_reopen(). sql/sp.cc: Allocate TABLE_LIST in thd->mem_root. Use init_one_table(). sql/sp_head.cc: Use init_one_table(). Remove thd->locked_tables_root, it's no longer needed. sql/sql_acl.cc: Use init_mdl_requests() and init_one_table(). sql/sql_base.cc: Update to new signatures of try_acquire_shared_lock() and try_acquire_exclusive_lock(). Remove lock_table_name_if_not_cached(). Fix a bug in open_ltable() that would not return ER_LOCK_DEADLOCK in case of a failed lock_tables() and a multi-statement transaction. Fix a bug in open_and_lock_tables_derived() that would not return ER_LOCK_DEADLOCK in case of a multi-statement transaction and a failure of lock_tables(). Move assignment of enum_open_table_action to a method of Open_table_context, a new class that maintains information for backoff actions. Minor rearrangements of the code. Remove alloc_mdl_requests() in functions that work with system tables: instead the patch ensures that callers always initialize TABLE_LIST argument. sql/sql_class.cc: THD::locked_tables_root is no more. sql/sql_class.h: THD::locked_tables_root is no more. Add a declaration for Open_table_context class. sql/sql_delete.cc: Update to use the simplified MDL API. sql/sql_handler.cc: TABLE_LIST::mdl_request is stored by-value now. Ensure that mdl_request.ticket is NULL for every request that is passed into MDL, to satisfy MDL asserts. @ sql/sql_help.cc Function open_system_tables_for_read() no longer initializes mdl_requests. Move TABLE_LIST::mdl_request initialization closer to TABLE_LIST initialization. sql/sql_help.cc: Function open_system_tables_for_read() no longer initializes mdl_requests. Move TABLE_LIST::mdl_request initialization closer to TABLE_LIST initialization. sql/sql_insert.cc: Remove assignment by-value of TABLE_LIST in TABLEOP_HOOKS. We can't carry over a granted MDL ticket from one table list to another. sql/sql_parse.cc: Change alloc_mdl_requests() -> init_mdl_requests(). @todo We can remove init_mdl_requests() altogether in some places: all places that call add_table_to_list() already have mdl requests initialized. sql/sql_plugin.cc: Use init_one_table(). THD::locked_tables_root is no more. sql/sql_servers.cc: Use init_one_table(). sql/sql_show.cc: Update acquire_high_priority_shared_lock() to use TABLE_LIST::mdl_request rather than allocate an own. Fix get_trigger_table_impl() to use init_one_table(), check for out of memory, follow the coding style. sql/sql_table.cc: Update to work with TABLE_LIST::mdl_request by-value. Remove lock_table_name_if_not_cached(). The code that used to delegate to it is quite simple and concise without it now. sql/sql_udf.cc: Use init_one_table(). sql/sql_update.cc: Update to use the new signature of close_tables_for_reopen(). sql/table.cc: Move re-setting of mdl_requests for prepared statements and stored procedures from close_thread_tables() to reinit_stmt_before_use(). Change alloc_mdl_requests() to init_mdl_requests(). init_mdl_requests() is a hack that can't be deleted until we don't have a list-aware TABLE_LIST constructor. Hopefully its use will be minimal sql/table.h: Change alloc_mdl_requests() to init_mdl_requests() TABLE_LIST::mdl_request is stored by value. sql/tztime.cc: We no longer initialize mdl requests in open_system_tables_for*() functions. Move this initialization closer to initialization of the rest of TABLE_LIST members. storage/myisammrg/ha_myisammrg.cc: Simplify mdl_request initialization.
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2617.69.2 committer: Konstantin Osipov <kostja@sun.com> branch nick: 5.4-azalea-bugfixing timestamp: Mon 2009-08-03 19:26:04 +0400 message: A fix and a test case for Bug#45035 "Altering table under LOCK TABLES results in "Error 1213 Deadlock found...". If a user had a table locked with LOCK TABLES for READ and for WRITE in the same connection, ALTER TABLE could fail. Root cause analysis: If a connection issues LOCK TABLE t1 write, t1 a read, t1 b read; the new LOCK TABLES code in 6.0 (part of WL 3726) will create the following list of TABLE_LIST objects (thd->locked_tables_list->m_locked_tables): {"t1" "b" tl_read_no_insert}, {"t1" "a" tl_read_no_insert}, {"t1" "t1" tl_write } Later on, when we try to ALTER table t1, mysql_alter_table() closes all TABLE instances and releases its thr_lock locks, keeping only an exclusive metadata lock on t1. But when ALTER is finished, Locked_table_list::reopen_tables() tries to restore the original list of open and locked tables. Before this patch, it used to do so one by one: Open t1 b, get TL_READ_NO_INSERT lock, Open t1 a, get TL_READ_NO_INSERT lock Open t1, try to get TL_WRITE lock, deadlock. The cause of the deadlock is that thr_lock.c doesn't resolve the situation when the read list only consists of locks taken by the same thread, followed by this very thread trying to take a WRITE lock. Indeed, since thr_lock_multi always gets a sorted list of locks, WRITE locks always precede READ locks in the list to lock. Don't try to fix thr_lock.c deficiency, keep this code simple. Instead, try to take all thr_lock locks at once in ::reopen_tables(). mysql-test/r/lock.result: Update results: test case for Bug#45035. mysql-test/t/lock.test: Add a test case for Bug#45035. sql/sql_base.cc: Take all thr_lock locks at once in Locked_tables_list::reopen_tables(). sql/sql_class.h: Add a helper array to store tables for mysql_lock_tables() in reopen_tables(). sql/sql_table.cc: Update unlink_all_closed_tables() to the new signature.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2617.65.6 committer: Dmitry Lenev <dlenev@mysql.com> branch nick: mysql-azalea-bg39674 timestamp: Sat 2009-07-25 00:28:43 +0400 message: Fix for bug #39674 "On shutdown mdl_destroy() called before plugin_shutdown()". Attempt to shutdown PBXT engine plugin led to assertion failure caused by using already destroyed mutex in metadata locking subsystem. This problem stemmed from the fact that we MDL subsystem and table definition cache were deinitialized before plugin shutdown while PBXT plugin during its shutdown process accessed tables and therefore expected them to be in working shape. This patch solves this problem by moving deinitialization of these two subsystems after plugins are shut down. No test case is provided since such test case would require using PBXT or other plugin which accesses tables during its shutdown process. sql/mysql_priv.h: Introduced table_def_start_shutdown() function which informs table definition cache that shutdown process has been started so it has to keep number of TABLE and TABLE_SHARE objects minimal in order to reduce number of references to pluggable engines. sql/mysqld.cc: Destroy table definition cache and meta-data locking subsystem after shutting down plugins. This allows plugins to work with tables during their shutdown. Since table definition cache hold references to storage engine plugins we have to remove unused tables from it before shutting down plugins and keep number of these references minimal during the process (by immediately removing tables opened during this process from the table definition cache). sql/sql_base.cc: Introduced table_def_start_shutdown() function which informs table definition cache that shutdown process has been started so it has to keep number of TABLE and TABLE_SHARE objects minimal in order to reduce number of references to pluggable engines. This allows to smoothly shutdown such plugins without completely prohibiting access to tables/table definition cache while shutting down other plugins.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2617.43.3 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: 40188-6.0 timestamp: Thu 2009-05-07 13:15:54 +0200 message: Sort results as the file list of the database directory is not sorted (MY_DONT_SORT). (This is a follow-up fix for WL#4284). mysql-test/r/drop_debug.result: Update test case result. mysql-test/t/drop_debug.test: Sort warnings.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2617.31.7 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: mysql-6.0-runtime timestamp: Wed 2009-03-25 19:22:00 -0300 message: WL#4284: Transactional DDL locking Post-merge fixes for test cases. mysql-test/include/mix1.inc: Ignore deadlock errors due to the table being altered. mysql-test/r/innodb_mysql.result: Update test case result (WL$4284). mysql-test/suite/parts/r/partition_special_innodb.result: The INSERT and SELECT are not necessary to reproduce the problem as the assertion happens when the table is being altered. Furthermore, the INSERT and SELECT will yield a deadlock error as after the alter the table version is set to zero, which means that any metadata locks on the table must be relinquished, but this won't happen voluntarily in a multi-statement transaction (metadata locks are released on commit or rollback). Reported as Bug#43867. mysql-test/suite/parts/t/partition_special_innodb.test: The INSERT and SELECT are not necessary to reproduce the problem as the assertion happens when the table is being altered. Furthermore, the INSERT and SELECT will yield a deadlock error as after the alter the table version is set to zero, which means that any metadata locks on the table must be relinquished, but this won't happen voluntarily in a multi-statement transaction (metadata locks are released on commit or rollback). Reported as Bug#43867.
-
- 04 Dec, 2009 1 commit
-
-
Konstantin Osipov authored
2617.31.12, 2617.31.15, 2617.31.15, 2617.31.16, 2617.43.1 - initial changeset that introduced the fix for Bug#989 and follow up fixes for all test suite failures introduced in the initial changeset. ------------------------------------------------------------ revno: 2617.31.1 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: 4284-6.0 timestamp: Fri 2009-03-06 19:17:00 -0300 message: Bug#989: If DROP TABLE while there's an active transaction, wrong binlog order WL#4284: Transactional DDL locking Currently the MySQL server does not keep metadata locks on schema objects for the duration of a transaction, thus failing to guarantee the integrity of the schema objects being used during the transaction and to protect then from concurrent DDL operations. This also poses a problem for replication as a DDL operation might be replicated even thought there are active transactions using the object being modified. The solution is to defer the release of metadata locks until a active transaction is either committed or rolled back. This prevents other statements from modifying the table for the entire duration of the transaction. This provides commitment ordering for guaranteeing serializability across multiple transactions. - Incompatible change: If MySQL's metadata locking system encounters a lock conflict, the usual schema is to use the try and back-off technique to avoid deadlocks -- this schema consists in releasing all locks and trying to acquire them all in one go. But in a transactional context this algorithm can't be utilized as its not possible to release locks acquired during the course of the transaction without breaking the transaction commitments. To avoid deadlocks in this case, the ER_LOCK_DEADLOCK will be returned if a lock conflict is encountered during a transaction. Let's consider an example: A transaction has two statements that modify table t1, then table t2, and then commits. The first statement of the transaction will acquire a shared metadata lock on table t1, and it will be kept utill COMMIT to ensure serializability. At the moment when the second statement attempts to acquire a shared metadata lock on t2, a concurrent ALTER or DROP statement might have locked t2 exclusively. The prescription of the current locking protocol is that the acquirer of the shared lock backs off -- gives up all his current locks and retries. This implies that the entire multi-statement transaction has to be rolled back. - Incompatible change: FLUSH commands such as FLUSH PRIVILEGES and FLUSH TABLES WITH READ LOCK won't cause locked tables to be implicitly unlocked anymore. mysql-test/extra/binlog_tests/drop_table.test: Add test case for Bug#989. mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test: Fix test case to reflect the fact that transactions now hold metadata locks for the duration of a transaction. mysql-test/include/mix1.inc: Fix test case to reflect the fact that transactions now hold metadata locks for the duration of a transaction. mysql-test/include/mix2.inc: Fix test case to reflect the fact that transactions now hold metadata locks for the duration of a transaction. mysql-test/r/flush_block_commit.result: Update test case result (WL#4284). mysql-test/r/flush_block_commit_notembedded.result: Update test case result (WL#4284). mysql-test/r/innodb.result: Update test case result (WL#4284). mysql-test/r/innodb_mysql.result: Update test case result (WL#4284). mysql-test/r/lock.result: Add test case result for an effect of WL#4284/Bug#989 (all locks should be released when a connection terminates). mysql-test/r/mix2_myisam.result: Update test case result (effects of WL#4284/Bug#989). mysql-test/r/not_embedded_server.result: Update test case result (effects of WL#4284/Bug#989). Add a test case for interaction of WL#4284 and FLUSH PRIVILEGES. mysql-test/r/partition_innodb_semi_consistent.result: Update test case result (effects of WL#4284/Bug#989). mysql-test/r/partition_sync.result: Temporarily disable the test case for Bug#43867, which will be fixed by a subsequent backport. mysql-test/r/ps.result: Add a test case for effect of PREPARE on transactional locks: we take a savepoint at beginning of PREAPRE and release it at the end. Thus PREPARE does not accumulate metadata locks (Bug#989/WL#4284). mysql-test/r/read_only_innodb.result: Update test case result (effects of WL#4284/Bug#989). mysql-test/suite/binlog/r/binlog_row_drop_tbl.result: Add a test case result (WL#4284/Bug#989). mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result: Update test case result (effects of WL#4284/Bug#989). mysql-test/suite/binlog/r/binlog_stm_drop_tbl.result: Add a test case result (WL#4284/Bug#989). mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result: Update test case result (effects of WL#4284/Bug#989). mysql-test/suite/binlog/r/binlog_unsafe.result: A side effect of Bug#989 -- slightly different table map ids. mysql-test/suite/binlog/t/binlog_row_drop_tbl.test: Add a test case for WL#4284/Bug#989. mysql-test/suite/binlog/t/binlog_stm_drop_tbl.test: Add a test case for WL#4284/Bug#989. mysql-test/suite/binlog/t/binlog_stm_row.test: Update to the new state name. This is actually a follow up to another patch for WL#4284, that changes Locked thread state to Table lock. mysql-test/suite/ndb/r/ndb_index_ordered.result: Remove result for disabled part of the test case. mysql-test/suite/ndb/t/disabled.def: Temporarily disable a test case (Bug#45621). mysql-test/suite/ndb/t/ndb_index_ordered.test: Disable a part of a test case (needs update to reflect semantics of Bug#989). mysql-test/suite/rpl/t/disabled.def: Disable tests made meaningless by transactional metadata locking. mysql-test/suite/sys_vars/r/autocommit_func.result: Add a commit (Bug#989). mysql-test/suite/sys_vars/t/autocommit_func.test: Add a commit (Bug#989). mysql-test/t/flush_block_commit.test: Fix test case to reflect the fact that transactions now hold metadata locks for the duration of a transaction. mysql-test/t/flush_block_commit_notembedded.test: Fix test case to reflect the fact that transactions now hold metadata locks for the duration of a transaction. Add a test case for transaction-scope locks and the global read lock (Bug#989/WL#4284). mysql-test/t/innodb.test: Fix test case to reflect the fact that transactions now hold metadata locks for the duration of a transaction (effects of Bug#989/WL#4284). mysql-test/t/lock.test: Add a test case for Bug#989/WL#4284. mysql-test/t/not_embedded_server.test: Add a test case for Bug#989/WL#4284. mysql-test/t/partition_innodb_semi_consistent.test: Replace TRUNCATE with DELETE, to not issue an implicit commit of a transaction, and not depend on metadata locks. mysql-test/t/partition_sync.test: Temporarily disable the test case for Bug#43867, which needs a fix to be backported from 6.0. mysql-test/t/ps.test: Add a test case for semantics of PREPARE and transaction-scope locks: metadata locks on tables used in PREPARE are enclosed into a temporary savepoint, taken at the beginning of PREPARE, and released at the end. Thus PREPARE does not effect what locks a transaction owns. mysql-test/t/read_only_innodb.test: Fix test case to reflect the fact that transactions now hold metadata locks for the duration of a transaction (Bug#989/WL#4284). Wait for the read_only statement to actually flush tables before sending other concurrent statements that depend on its state. mysql-test/t/xa.test: Fix test case to reflect the fact that transactions now hold metadata locks for the duration of a transaction (Bug#989/WL#4284). sql/ha_ndbcluster_binlog.cc: Backport bits of changes of ha_ndbcluster_binlog.cc from 6.0, to fix the failing binlog test suite with WL#4284. WL#4284 implementation does not work with 5.1 implementation of ndbcluster binlog index. sql/log_event.cc: Release metadata locks after issuing a commit. sql/mdl.cc: Style changes (WL#4284). sql/mysql_priv.h: Rename parameter to match the name used in the definition (WL#4284). sql/rpl_injector.cc: Release metadata locks on commit (WL#4284). sql/rpl_rli.cc: Remove assert made meaningless, metadata locks are released at the end of the transaction. sql/set_var.cc: Close tables and release locks if autocommit mode is set. sql/slave.cc: Release metadata locks after a rollback. sql/sql_acl.cc: Don't implicitly unlock locked tables. Issue a implicit commit at the end and unlock tables. sql/sql_base.cc: Defer the release of metadata locks when closing tables if not required to. Issue a deadlock error if the locking protocol requires that a transaction re-acquire its locks. Release metadata locks when closing tables for reopen. sql/sql_class.cc: Release metadata locks if the thread is killed. sql/sql_parse.cc: Release metadata locks after implicitly committing a active transaction, or after explicit commits or rollbacks. sql/sql_plugin.cc: Allocate MDL request on the stack as the use of the table is contained within the function. It will be removed from the context once close_thread_tables is called at the end of the function. sql/sql_prepare.cc: The problem is that the prepare phase of the CREATE TABLE statement takes a exclusive metadata lock lock and this can cause a self-deadlock the thread already holds a shared lock on the table being that should be created. The solution is to make the prepare phase take a shared metadata lock when preparing a CREATE TABLE statement. The execution of the statement will still acquire a exclusive lock, but won't cause any problem as it issues a implicit commit. After some discussions with stakeholders it has been decided that metadata locks acquired during a PREPARE statement must be released once the statement is prepared even if it is prepared within a multi statement transaction. sql/sql_servers.cc: Don't implicitly unlock locked tables. Issue a implicit commit at the end and unlock tables. sql/sql_table.cc: Close table and release metadata locks after a admin operation. sql/table.h: The problem is that the prepare phase of the CREATE TABLE statement takes a exclusive metadata lock lock and this can cause a self-deadlock the thread already holds a shared lock on the table being that should be created. The solution is to make the prepare phase take a shared metadata lock when preparing a CREATE TABLE statement. The execution of the statement will still acquire a exclusive lock, but won't cause any problem as it issues a implicit commit. sql/transaction.cc: Release metadata locks after the implicitly committed due to a new transaction being started. Also, release metadata locks acquired after a savepoint if the transaction is rolled back to the save point. The problem is that in some cases transaction-long metadata locks could be released before the transaction was committed. This could happen when a active transaction was ended by a "START TRANSACTION" or "BEGIN" statement, in which case the metadata locks would be released before the actual commit of the active transaction. The solution is to defer the release of metadata locks to after the transaction has been implicitly committed. No test case is provided as the effort to provide one is too disproportional to the size of the fix.
-
- 03 Dec, 2009 20 commits
-
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2617.23.22 committer: Konstantin Osipov <kostja@sun.com> branch nick: mysql-6.0-runtime timestamp: Wed 2009-03-04 23:29:16 +0300 message: WL#4284, "Transactional DDL locking": fix a Windows compilation warning.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2617.23.23 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: mysql-6.0-runtime timestamp: Thu 2009-03-05 18:39:58 -0300 message: Fix for broken build: SHARED is defined by Solaris headers. sql/mdl.cc: Add MDL_LOCK prefix to the lock types of MDL_LOCK.
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2617.23.20 committer: Konstantin Osipov <kostja@sun.com> branch nick: mysql-6.0-runtime timestamp: Wed 2009-03-04 16:31:31 +0300 message: WL#4284 "Transactional DDL locking" Review comments: "Objectify" the MDL API. MDL_request and MDL_context still need manual construction and destruction, since they are used in environment that is averse to constructors/destructors. sql/mdl.cc: Improve comments. Add asserts to backup()/restore_from_backup()/merge() methods. Fix an order bug in the error path of mdl_acquire_exclusive_locks(): we used to first free a ticket object, and only then exclude it from the list of tickets.
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2617.23.19 committer: Konstantin Osipov <kostja@sun.com> branch nick: mysql-6.0-runtime timestamp: Tue 2009-03-03 01:20:44 +0300 message: Metadata locking: realign comments. No semantical changes, only enforce a bit of the coding style. This is a review fix for WL#4284 "Transactional DDL locking". sql/mdl.cc: Realign doxygen comments. sql/mdl.h: Realign doxygen comments.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2617.23.18 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: 4284-6.0 timestamp: Mon 2009-03-02 18:18:26 -0300 message: Bug#989: If DROP TABLE while there's an active transaction, wrong binlog order WL#4284: Transactional DDL locking This is a prerequisite patch: These changes are intended to split lock requests from granted locks and to allow the memory and lifetime of granted locks to be managed within the MDL subsystem. Furthermore, tickets can now be shared and therefore are used to satisfy multiple lock requests, but only shared locks can be recursive. The problem is that the MDL subsystem morphs lock requests into granted locks locks but does not manage the memory and lifetime of lock requests, and hence, does not manage the memory of granted locks either. This can be problematic because it puts the burden of tracking references on the users of the subsystem and it can't be easily done in transactional contexts where the locks have to be kept around for the duration of a transaction. Another issue is that recursive locks (when the context trying to acquire a lock already holds a lock on the same object) requires that each time the lock is granted, a unique lock request/granted lock structure structure must be kept around until the lock is released. This can lead to memory leaks in transactional contexts as locks taken during the transaction should only be released at the end of the transaction. This also leads to unnecessary wake ups (broadcasts) in the MDL subsystem if the context still holds a equivalent of the lock being released. These issues are exacerbated due to the fact that WL#4284 low-level design says that the implementation should "2) Store metadata locks in transaction memory root, rather than statement memory root" but this is not possible because a memory root, as implemented in mysys, requires all objects allocated from it to be freed all at once. This patch combines review input and significant code contributions from Konstantin Osipov (kostja) and Dmitri Lenev (dlenev). mysql-test/r/mdl_sync.result: Add test case result. mysql-test/t/mdl_sync.test: Add test case for shared lock upgrade case. sql/event_db_repository.cc: Rename mdl_alloc_lock to mdl_request_alloc. sql/ha_ndbcluster_binlog.cc: Use new function names to initialize MDL lock requests. sql/lock.cc: Rename MDL functions. sql/log_event.cc: The MDL request now holds the table and database name data (MDL_KEY). sql/mdl.cc: Move the MDL key to the MDL_LOCK structure in order to make the object suitable for allocation from a fixed-size allocator. This allows the simplification of the lists in the MDL_LOCK object, which now are just two, one for granted tickets and other for waiting (upgraders) tickets. Recursive requests for a shared lock on the same object can now be granted using the same lock ticket. This schema is only used for shared locks because that the only case that matters. This is used to avoid waste of resources in case a context (connection) already holds a shared lock on a object. sql/mdl.h: Introduce a metadata lock object key which is used to uniquely identify lock objects. Separate the structure used to represent pending lock requests from the structure used to represent granted metadata locks. Rename functions used to manipulate locks requests in order to have a more consistent function naming schema. sql/sp_head.cc: Rename mdl_alloc_lock to mdl_request_alloc. sql/sql_acl.cc: Rename alloc_mdl_locks to alloc_mdl_requests. sql/sql_base.cc: Various changes to accommodate that lock requests are separated from lock tickets (granted locks). sql/sql_class.h: Last acquired lock before the savepoint was set. sql/sql_delete.cc: Various changes to accommodate that lock requests are separated from lock tickets (granted locks). sql/sql_handler.cc: Various changes to accommodate that lock requests are separated from lock tickets (granted locks). sql/sql_insert.cc: Rename alloc_mdl_locks to alloc_mdl_requests. sql/sql_parse.cc: Rename alloc_mdl_locks to alloc_mdl_requests. sql/sql_plist.h: Typedef for iterator type. sql/sql_plugin.cc: Rename alloc_mdl_locks to alloc_mdl_requests. sql/sql_servers.cc: Rename alloc_mdl_locks to alloc_mdl_requests. sql/sql_show.cc: Various changes to accommodate that lock requests are separated from lock tickets (granted locks). sql/sql_table.cc: Various changes to accommodate that lock requests are separated from lock tickets (granted locks). sql/sql_trigger.cc: Save reference to the lock ticket so it can be downgraded later. sql/sql_udf.cc: Rename alloc_mdl_locks to alloc_mdl_requests. sql/table.cc: Rename mdl_alloc_lock to mdl_request_alloc. sql/table.h: Separate MDL lock requests from lock tickets (granted locks). storage/myisammrg/ha_myisammrg.cc: Rename alloc_mdl_locks to alloc_mdl_requests.
-
Konstantin Osipov authored
Add two more files to .bzrignore. .bzrignore: Ignore symlinks to new WL#4284 source and header files.
-
Konstantin Osipov authored
Add two more files to .bzrignore. .bzrignore: Ignore symlinks to new WL#4284 source and header files.
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2617.22.7 committer: Konstantin Osipov <kostja@sun.com> branch nick: mysql-6.0-runtime timestamp: Tue 2009-01-27 16:41:58 +0300 message: WL#4284 "Transactional DDL locking" review. Improve a comment. sql/mdl.cc: Improve a comment.
-
Konstantin Osipov authored
revno: 2617.22.4 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: mysql-6.0-runtime timestamp: Mon 2009-01-26 15:19:14 -0200 message: Move checks for OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN to a separate helper function. sql/ha_ndbcluster.cc: Use helper method to check transaction mode. sql/log.cc: Use helper method to check transaction mode. sql/sql_cache.cc: Use helper method to check transaction mode. sql/sql_class.cc: Use helper method to check transaction mode. sql/sql_class.h: Add helper method to check whether session is in a multi-statement transaction. sql/sql_parse.cc: Use helper method to check transaction mode. sql/transaction.cc: Use helper method to check transaction mode.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 3035.4.1 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: 39897-6.0 timestamp: Thu 2009-01-15 12:17:57 -0200 message: Bug#39897: lock_multi fails in pushbuild: timeout waiting for processlist The problem is that relying on the "Table lock" thread state in its current position to detect that a thread is waiting on a lock is race prone. The "Table lock" state change happens before the thread actually tries to grab a lock on a table. The solution is to move the "Table lock" state so that its set only when a thread is actually going to wait for a lock. The state change happens after the thread fails to grab the lock (because it is owned by other thread) and proceeds to wait on a condition. This is considered part of work related to WL#4284 "Transactional DDL locking" Warning: this patch contains an incompatible change. When waiting on a lock in thr_lock.c, the server used to display "Locked" processlist state. After this patch, the state is "Table lock". The new state was actually intended to be display since year 2002, when Monty added it. But up until removal of thd->locked boolean member, this state was ignored by SHOW PROCESSLIST code. mysql-test/r/lock_multi.result: A style fix. mysql-test/r/sp-threads.result: Changed output of SHOW PROCESSLIST (new wait state). mysql-test/t/lock_multi.test: Use a more accurate state description when waiting inside thr_lock.c. mysql-test/t/lock_sync.test: Use a more accurate state description when waiting inside thr_lock.c. mysql-test/t/multi_update.test: Use a more accurate state description when waiting inside thr_lock.c. mysql-test/t/query_cache_28249.test: Use a more accurate state description when waiting inside thr_lock.c. mysql-test/t/sp_notembedded.test: Use a more accurate state description when waiting inside thr_lock.c. mysql-test/t/status.test: Use a more accurate state description when waiting inside thr_lock.c. mysys/thr_lock.c: Update thread state while waiting for a table lock. sql/lock.cc: State change was moved inside thr_lock.c.
-
Konstantin Osipov authored
----------------------------------------------------------- 2497.479.10 Sergei Golubchik 2008-08-27 proc_info_hook, mysys access to thd->proc_info This patch is necessary for backport of WL#4284 "Transactional DDL locking". include/my_global.h: proc_info_hook include/my_sys.h: proc_info_hook mysys/my_static.c: proc_info_hook sql/mysqld.cc: proc_info_hook sql/sql_class.cc: proc_info_hook
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2630.22.3 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: 4284-6.0 timestamp: Thu 2008-08-07 22:33:43 -0300 message: WL#4284: Transactional DDL locking Make transaction management more modular through a new interface. The overall objective of this change is to provide groundwork for the design of transactional DDL locking by cleaning up the transaction high level API to better distinguish operations implicit and explicit, and single statement transaction from operations on the normal transaction. Having a a high-level interface for transaction management provides a better base for implementing transactional concepts that are not always tied to storage engines and also makes it easier to interect with other higher level modules of the server. client/Makefile.am: Add new file to the build. libmysqld/CMakeLists.txt: Add new file to the build. libmysqld/Makefile.am: Add new file to the build. sql/CMakeLists.txt: Add new file to the build. sql/Makefile.am: Add new file to the build. sql/handler.cc: Remove multiplexer commit or rollback function. Most callers already have enough information to decided whether to rollback or commit. Having plain and well named functions makes it easier to read and understand code. sql/handler.h: Remove wrapper function as the low level transaction functions shouldn't be called directly anymore. sql/log_event.cc: Rename transaction management functions to the new names. sql/log_event_old.cc: Rename transaction management functions to the new names. sql/mysql_priv.h: Remove obsolete functions for implicit and explicit commit. sql/rpl_injector.cc: Rename transaction management functions to the new names. sql/rpl_rli.cc: Rename transaction management functions to the new names. sql/set_var.cc: Rename transaction management functions to the new names. sql/slave.cc: Rename transaction management functions to the new names. sql/sql_base.cc: Rename transaction management functions to the new names. sql/sql_class.cc: Rename transaction management functions to the new names. sql/sql_delete.cc: Rename transaction management functions to the new names. sql/sql_do.cc: Rename transaction management functions to the new names. sql/sql_insert.cc: Rename transaction management functions to the new names. sql/sql_parse.cc: Rename transaction management functions to the new names. sql/sql_partition.cc: Rename transaction management functions to the new names. sql/sql_table.cc: Rename transaction management functions to the new names. sql/transaction.cc: Implement wrapper functions to differentiate operations on the single statement transaction from the ones operating on the normal transaction. sql/transaction.h: Export new functions for dealing with transaction commands.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2630.13.17 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: 4284-6.0 timestamp: Sun 2008-07-27 10:14:46 -0300 message: Post-merge fixes: Remove dependency on binlog, require not embedded as test uses the event scheduler and disable abort on error for syntax only available on servers built with debugging support. This is a patch in scope of WL#4284 "Transactional DDL locking" mysql-test/t/implicit_commit.test: Remove dependency on binlog, require not embedded as test uses the event scheduler and disable abort on error for syntax only available on servers built with debugging support.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2630.13.16 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: WL#4284 timestamp: Sat 2008-07-26 13:38:20 -0300 message: WL#4284: Transactional DDL locking SQL statements' effect on transactions. Currently the MySQL server and its storage engines are not capable of rolling back operations that define or modify data structures (also known as DDL statements) or operations that alter any of the system tables (the mysql database). Allowing these group of statements to participate in transactions is unfeasible at this time (since rollback has no effect whatsoever on them) and goes against the design of our metadata locking subsystem. The solution is to issue implicit commits before and after those statements execution. This effectively confines each of those statements to its own special transaction and ensures that metadata locks taken during this special transaction are not leaked into posterior statements/transactions. mysql-test/include/commit.inc: Alter table rename was not committing the normal transaction at the end of its execution, and as a consequence, the commit was being issued in the next DDL command (rename table) that happened to end the active transaction. Other changes are to take into account the implicit commits issued before and after the DDL command execution. mysql-test/include/implicit_commit_helper.inc: Add auxiliary test that shows if a statement issued a implicit commit. mysql-test/r/commit_1innodb.result: Update test case result. mysql-test/r/implicit_commit.result: Test implicit commit behavior of some SQL commands. mysql-test/t/implicit_commit.test: Test implicit commit behavior of some SQL commands. sql/events.cc: Transaction is now ended before the command execution. sql/mysql_priv.h: Add flags array for server commands and remove historical left over. sql/sql_class.h: Add flags to control when to issue implicit commits before and after a command execution. sql/sql_delete.cc: A implicit commit is issued at the end of truncate statements. sql/sql_parse.cc: Mark commands that need implicit commits before and after their executions. The implicit commits of the statement and the normal transaction are now issued regardless of the user access privileges. sql/sql_table.cc: A implicit commit is now issued before admin commands. tests/mysql_client_test.c: Test that COM_REFRESH issues a implicit commit.
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2630.2.7 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-runtime timestamp: Wed 2008-06-04 15:18:52 +0400 message: Fix a code regression (not observable externally) that I introduced in the fix for Bug#26141 (backporting as part of all patches related to WL#3726)
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2630.2.23 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-runtime timestamp: Fri 2008-06-27 21:15:11 +0400 message: Add an assert that we never call COMMIT or ROLLBACK while having a table lock. sql/sql_parse.cc: We should never call COMMIT or ROLLBACK with a table lock, except when under LOCK TABLES.
-
Konstantin Osipov authored
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2630.13.4 committer: Dmitry Lenev <dlenev@mysql.com> branch nick: mysql-6.0-runtime timestamp: Mon 2008-07-07 19:51:20 +0400 message: Fixed outdated comment describing mdl_init_lock() function.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2630.4.39 committer: Dmitry Lenev <dlenev@mysql.com> branch nick: mysql-6.0-3726-w2 timestamp: Thu 2008-06-26 13:08:27 +0400 message: Fix warnings about passing pointer to not fully-initialized THD object to constructor of base Open_tables_state classe, which appeared on Windows and were introduced by one of the patches implementing WL#3726 "DDL locking for all metadata objects". sql/sql_class.cc: Moved code preparing Open_tables_state instance for operations which open/lock/close tables from class constructor to init_open_tables_state() method. This allows us to move such initialization of base Open_table_state instance in THD class constructor from base classes initialization section to constructor's body and thus to get rid of warnings about about passing pointer to not fully-initialized THD object to base class constructor. sql/sql_class.h: Moved code preparing Open_tables_state instance for operations which open/lock/close tables from class constructor to init_open_tables_state() method. This allows us to move such initialization of base Open_table_state instance in THD class constructor from base classes initialization section to constructor's body and thus to get rid of warnings about about passing pointer to not fully-initialized THD object to base class constructor.
-
Konstantin Osipov authored
-
- 02 Dec, 2009 6 commits
-
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2630.4.38 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-4144 timestamp: Wed 2008-06-25 22:07:06 +0400 message: WL#4144 - Lock MERGE engine children. Committing a version of the patch merged with WL#3726 on behalf of Ingo. Step #1: Move locking from parent to children. MERGE children are now left in the query list of tables after inserted there in open_tables(). So they are locked by lock_tables() as all other tables are. The MERGE parent does not store locks any more. It appears in a MYSQL_LOCK with zero lock data. This is kind of a "dummy" lock. All other lock handling is also done directly on the children. To protect against parent or child modifications during LOCK TABLES, the children are detached after every statement and attached before every statement, even under LOCK TABLES. The children table list is removed from the query list of tables on every detach and on close of the parent. Step #2: Move MERGE specific functionality from SQL layer into table handler. Functionality moved from SQL layer (mainly sql_base.cc) to the table handler (ha_myisammrg.cc). Unnecessary code is removed from the SQL layer. Step #3: Moved all MERGE specific members from TABLE to ha_myisammrg. Moved members from TABLE to ha_myisammrg. Renamed some mebers. Fixed comments. Step #4: Valgrind and coverage testing Valgrind did not uncover new problems. Added purecov comments. Added a new test for DATA/INDEX DIRECTORY options. Changed handling of ::reset() for non-attached children. Fixed the merge-big test. Step #5: Fixed crashes detected during review Changed detection when to attach/detach. Added new tests. Backport also the fix for Bug#44040 "MySQL allows creating a MERGE table upon VIEWs but crashes when using it" include/my_base.h: WL#4144 - Lock MERGE engine children Added HA_EXTRA_ADD_CHILDREN_LIST and HA_EXTRA_IS_ATTACHED_CHILDREN for MERGE table support mysql-test/r/merge.result: WL#4144 - Lock MERGE engine children Fixed test result. mysql-test/t/disabled.def: Enable merge.test, which now is working again (WL#4144). mysql-test/t/merge-big.test: Fix the messages for wait_condition (merge with WL#3726). mysql-test/t/merge.test: WL#4144 - Lock MERGE engine children Fixed one test to meet coding standards for tests (upper case keywords, engine names as in SHOW ENGINES). Fixed error codes. Added a test for DATA/INDEX DIRECTORY. mysys/thr_lock.c: WL#4144 - Lock MERGE engine children Added purecov comments. sql/ha_partition.cc: WL#4144 - Lock MERGE engine children Added MERGE specific extra operations to ha_partition::extra(). Extended comments. Changed function comment to doxygen style. Fixed nomenclature: 'parameter' -> 'operation'. sql/mysql_priv.h: WL#4144 - Lock MERGE engine children Removed declarations for removed functions. sql/sql_base.cc: WL#4144 - Lock MERGE engine children Leave the children in the query list of tables after open_tables(). Set proper back links (prev_global). Attach MERGE children before and detach them after every statement. Even under LOCK TABLES. Remove children from the query list when they are detached. Remove lock forwarding from children to parent. Moved MERGE specific functions to ha_myisammrg.cc. Added purecov comments. Backport the fix for Bug#44040 "MySQL allows creating a MERGE table upon VIEWs but crashes when using it" sql/sql_table.cc: WL#4144 - Lock MERGE engine children Changed detection of MERGE tables. sql/table.cc: WL#4144 - Lock MERGE engine children Moved is_children_attached() method from TABLE to ha_myisammrg. sql/table.h: WL#4144 - Lock MERGE engine children Moved all MERGE specific members from TABLE to ha_myisammrg. storage/myisammrg/ha_myisammrg.cc: WL#4144 - Lock MERGE engine children Set proper back links in the child list (prev_global). Added a function for removal of the child list from the query list. Remove children from the query list when the parent is closed. Make parent lock handling a dummy (zero locks). Moved MERGE specific functionality from SQL layer to here. Moved all MERGE specific members from TABLE to ha_myisammrg. Renamed children list pointers. Added initialization and free for the children list mem_root. Fixed comments. Added purecov comments. storage/myisammrg/ha_myisammrg.h: WL#4144 - Lock MERGE engine children Added method add_children_list(). Moved all MERGE specific members from TABLE to ha_myisammrg. Renamed children list pointers. Added a mem_root for the children list. storage/myisammrg/myrg_extra.c: WL#4144 - Lock MERGE engine children Changed handling of ::reset() for non-attached children.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2630.4.37 committer: Dmitry Lenev <dlenev@mysql.com> branch nick: mysql-6.0-3726-w2 timestamp: Wed 2008-06-25 20:28:57 +0400 message: Fix build failure of mysql-6.0-3726 tree on Windows. The failure was caused by the fact that sql/mdl.cc was using __func__ macro without including sql_profile.h header which contained definition of this macro for those platforms that miss it. This patch solves this problem by moving this define to include/my_global.h which makes it available in modules which don't/can't include sql/mysql_priv.h. This is a patch that is part of WL#3726. include/my_global.h: Moved definition of __func__ macro from sql/sql_profile.h to include/my_global.h to make it accessible from those modules of the server which don't include mysql_priv.h. sql/sql_profile.cc: Removed _unknown_func_ const variable since it is no longer used by __func__ macro. sql/sql_profile.h: Moved definition of __func__ macro from sql/sql_profile.h to include/my_global.h to make it accessible from those modules of the server which don't include mysql_priv.h.
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2630.4.36 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-3726 timestamp: Wed 2008-06-25 17:03:37 +0400 message: As per discussion with Serg and Dmitri, remove the code that is trying to emulate LOCK TABLES when locking tables for prelocking. This code was worked around by the engines, and has no effect. We may still have to do something to ensure that statement-based replication is consistent in MVCC engines, or other engines that downgrade table level locks, but this will have to be done somehow differently. sql/sql_base.cc: Do not try to emulate LOCK TABLES when locking tables for pre-locking.
-
Konstantin Osipov authored
---------------------------------------------------------- revno: 2630.4.35 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-3726 timestamp: Wed 2008-06-25 16:44:00 +0400 message: Fix a MyISAM-specific bug in the new implementation of LOCK TABLES (WL#3726). If more than one instance of a MyISAM table are open in the same connection, all of them must share the same status_param. Otherwise, unlock of a table may lead to lost records. See also comments in thr_lock.c. include/thr_lock.h: Declare thr_lock_merge_status(). mysql-test/r/lock.result: Update test results (WL#3726). mysql-test/t/lock.test: Add a test case for the situation when the same table is locked twice by LOCK TABLES, and only one instance is updated. mysys/thr_lock.c: Move the code that makes sure all status_params of the same table are shared into a separate function. sql/lock.cc: Make sure that status_param is shared when a table is reopened.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2630.4.33 committer: Dmitry Lenev <dlenev@mysql.com> branch nick: mysql-6.0-3726-w2 timestamp: Fri 2008-06-20 17:11:20 +0400 message: WL#3726 "DDL locking for all metadata objects". After-review fixes in progress. Minimized dependency of mdl.cc on other modules (particularly made it independant of mysql_priv.h) in order to be able write unit tests for metadata locking subsystem. sql/ha_ndbcluster_binlog.cc: Use newly introduced MAX_MDLKEY_LENGTH constant for allocating buffer for object key for metadata locking subsystem. sql/log_event.cc: Use newly introduced MAX_MDLKEY_LENGTH constant for allocating buffer for object key for metadata locking subsystem. sql/mdl.cc: Removed dependency on THD class (and thus on mysql_priv.h) by using direct access to members of st_my_thread_var instead of accessing THD::killed/enter_cond()/exit_cond(). sql/mdl.h: Added MAX_MDLKEY_LENGTH constant to be used for allocating buffers for key for metadata locking subsystem. Added declarations of server kernel functions used by metadata locking subsystem to mdl.h in order to decrease dependency of mdl.cc on other files. sql/mysql_priv.h: Moved declaration of notify_thread_having_shared_lock() to the mdl.h (also renamed it to make clear in metadata locking code that it is a callback to SQL-layer). sql/sql_base.cc: Renamed notify_thread_having_shared_lock() to make it clear in metadata locking subsystem code that it is a callback to SQL layer. sql/sql_handler.cc: Use newly introduced MAX_MDLKEY_LENGTH constant for allocating buffer for object key for metadata locking subsystem. sql/sql_show.cc: Use newly introduced MAX_MDLKEY_LENGTH constant for allocating buffer for object key for metadata locking subsystem.
-
Konstantin Osipov authored
------------------------------------------------------------ revno: 2630.4.32 committer: Dmitry Lenev <dlenev@mysql.com> branch nick: mysql-6.0-3726-w2 timestamp: Thu 2008-06-19 16:39:58 +0400 message: WL#3726 "DDL locking for all metadata objects". After-review fixes in progress. Ensure that metadata locking subsystem properly handles out-of-memory conditions. Clarified MDL interface by separating release of locks and removal of lock requests from the context. sql/lock.cc: mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible for removal of metadata lock requests from the context. One should explicitly call mdl_remove_all_locks() and mdl_remove_lock() to do this. sql/mdl.cc: Ensured that metadata locking subsystem properly handles out-of-memory conditions. Introduced new MDL_INITIALIZED state for metadata lock request which is used in all cases when lock is not acquired and we have not associated request with object respesenting lock. MDL_PENDING is now only used for requests for exclusive locks which are added to the MDL_LOCK::waiting_exclusive queue. mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible for removal of metadata lock requests from the context. One should explicitly call mdl_remove_all_locks() and newly introduced mdl_remove_lock() to do this. Also renamed mdl_release_all_locks_for_name() to emphasize that it also actually removes lock requests from the context. Finally mdl_try_acquire_exclusive_lock() is now returs information about encountered lock conflict in separate out parameter since its return value is used for distinguishing between error (e.g. due to OOM) and success. sql/mdl.h: Introduced new MDL_INITIALIZED state for metadata lock request which is used in all cases when lock is not acquired and we have not associated request with object respesenting lock. MDL_PENDING is now only used for requests for exclusive locks which are added to the MDL_LOCK::waiting_exclusive queue. mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible for removal of metadata lock requests from the context. One should explicitly call mdl_remove_all_locks() and newly introduced mdl_remove_lock() to do this. Also renamed mdl_release_all_locks_for_name() to emphasize that it also actually removes lock requests from the context. Finally mdl_try_acquire_exclusive_lock() is now returs information about encountered lock conflict in separate out parameter since its return value is used for distinguishing between error (e.g. due to OOM) and success. sql/sql_base.cc: mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible for removal of metadata lock requests from the context. One should explicitly call mdl_remove_all_locks() and mdl_remove_lock() to do this. Also adjusted open_table() to ensure that it releases/removes metadata locks in case of error after adding/acquiring them (unless keeping these lock requests is required for recovering action). sql/sql_delete.cc: mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible for removal of metadata lock requests from the context. One should explicitly call mdl_remove_all_locks() and mdl_remove_lock() to do this. sql/sql_handler.cc: mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible for removal of metadata lock requests from the context. One should explicitly call mdl_remove_all_locks() and mdl_remove_lock() to do this. sql/sql_show.cc: mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible for removal of metadata lock requests from the context. One should explicitly call mdl_remove_all_locks() and mdl_remove_lock() to do this. sql/sql_table.cc: Renamed mdl_release_all_locks_for_name() to emphasize that it also actually removes lock requests from the context. mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible for removal of metadata lock requests from the context. One should explicitly call mdl_remove_all_locks() and mdl_remove_lock() to do this. Finally mdl_try_acquire_exclusive_lock() is now returs information about encountered lock conflict in separate out parameter since its return value is used for distinguishing between error (e.g. due to OOM) and success.
-