1. 05 Feb, 2010 1 commit
    • Konstantin Osipov's avatar
      next-mr -> next-4284 merge: · 293268c6
      Konstantin Osipov authored
      fix a merge bug when write_bin_log called from mysql_routine_grant()
      would chew up the error.
      rpl_do_grant test would fail on assert that the diagnostics area is
      empty.
      293268c6
  2. 04 Feb, 2010 7 commits
    • Konstantin Osipov's avatar
      A post-merge fix for next-mr -> next-4284 merge: · 5deaf55a
      Konstantin Osipov authored
      Make all mutexes and conditions of type mysql_mutex_t, mysql_cond_t,
      since it's now the expectation of THD::awake().
      5deaf55a
    • Konstantin Osipov's avatar
      Merge next-mr -> next-4284. · ad0f1f80
      Konstantin Osipov authored
      ad0f1f80
    • Konstantin Osipov's avatar
      Merge next-mr -> next-4284. · 06e1a73a
      Konstantin Osipov authored
      Cherry-pick a fix Bug#37148 from next-mr, to preserve
      file ids of the added files, and ensure that all the necessary
      changes have been pulled.
      
      Since initially Bug#37148 was null-merged into 6.0,
      the changeset that is now being cherry-picked was likewise
      null merged into next-4284.
      
      Now that Bug#37148 has been reapplied to 6.0, try to make
      it work with next-4284. This is also necessary to be able
      to pull other changes from 5.1-rep into next-4284.
      
      To resolve the merge issues use this changeset applied
      to 6.0:
      revid:jperkin@sun.com-20091216103628-ylhqf7s6yegui2t9
      revno: 3776.1.1
      committer: He Zhenxing <zhenxing.he@sun.com>
      branch nick: 6.0-codebase-bugfixing
      timestamp: Thu 2009-12-17 17:02:50 +0800
      message:
        Fix merge problem with Bug#37148
      
      
      06e1a73a
    • Konstantin Osipov's avatar
      Merge next-mr -> next-4284-merge. · 89269e51
      Konstantin Osipov authored
      89269e51
    • Dmitry Lenev's avatar
      Small clean-up in CREATE TABLE LIKE implementation. · 8bba05e8
      Dmitry Lenev authored
      Removed local variables which became unused when we
      have switched to new approach for CREATE TABLE LIKE
      (i.e. abondoned .FRM file copying) and were causing
      warnings during compilation.
      8bba05e8
    • Jon Olav Hauglid's avatar
      Bug #50821 Deadlock between LOCK TABLES and ALTER TABLE · 34de83e1
      Jon Olav Hauglid authored
      This was a deadlock between ALTER TABLE and another DML statement
      (or LOCK TABLES ... READ). ALTER TABLE would wait trying to upgrade
      its lock to MDL_EXCLUSIVE and the DML statement would wait trying
      to acquire a TL_READ_NO_INSERT table level lock.
      
      This could happen if one connection first acquired a MDL_SHARED_READ
      lock on a table. In another connection ALTER TABLE is then started.
      ALTER TABLE eventually blocks trying to upgrade to MDL_EXCLUSIVE,
      but while holding a TL_WRITE_ALLOW_READ table level lock.
      
      If the first connection then tries to acquire TL_READ_NO_INSERT,
      it will block and we have a deadlock since neither connection can
      proceed.
      
      This patch fixes the problem by allowing TL_READ_NO_INSERT 
      locks to be granted if another connection holds TL_WRITE_ALLOW_READ
      on the same table. This will allow the DML statement to proceed
      such that it eventually can release its MDL lock which in turn
      makes ALTER TABLE able to proceed.
      
      Note that TL_READ_NO_INSERT was already partially compatible with
      TL_WRITE_ALLOW_READ as the latter would be granted if the former
      lock was held. This patch just makes the opposite true as well.
      
      Also note that since ALTER TABLE takes an upgradable MDL lock,
      there will be no starvation of ALTER TABLE statements by
      statements acquiring TL_READ or TL_READ_NO_INSERT.
      
      Test case added to lock_sync.test.
      34de83e1
    • Dmitry Lenev's avatar
      Improve concurrency in metadata locking subsystem by · 967bd206
      Dmitry Lenev authored
      moving calculation of hash value when looking up
      MDL_lock objects in MDL_map out of critical section.
      967bd206
  3. 03 Feb, 2010 12 commits
    • Konstantin Osipov's avatar
      Merge next-4284 -> next-4284-merge · 4d0f0c78
      Konstantin Osipov authored
      4d0f0c78
    • Konstantin Osipov's avatar
      Merge next-mr -> next-4284. · f141542a
      Konstantin Osipov authored
      f141542a
    • Dmitry Lenev's avatar
      A follow-up for the patch which implemented new · bcf70096
      Dmitry Lenev authored
      type-of-operation-aware metadata locks and added a
      wait-for graph based deadlock detector to the MDL
      subsystem (this patch fixed bug #46272 "MySQL 5.4.4,
      new MDL: unnecessary deadlock" and bug #37346
      "innodb does not detect deadlock between update and
      alter table").
      
      Removed unused and redundant method.
      bcf70096
    • Konstantin Osipov's avatar
      Merge next-4248 -> next-4284-merge · ac8990cb
      Konstantin Osipov authored
      ac8990cb
    • Konstantin Osipov's avatar
      Fix a failure of rpl_cross_version, caused by hand-initalization · ef48f71c
      Konstantin Osipov authored
      of the TABLE_LIST instance, which did not initialize the 
      MDL request properly.
      Use init_one_table() to initialize the MDL request.
      ef48f71c
    • Konstantin Osipov's avatar
      Merge next-mr -> next-4284. · f949e1b8
      Konstantin Osipov authored
      f949e1b8
    • Jon Olav Hauglid's avatar
      Bug #50786 Assertion `thd->mdl_context.trans_sentinel() == __null' · e190a415
      Jon Olav Hauglid authored
                 failed in open_ltable()
      
      The problem was too restrictive asserts that enforced that 
      open_ltable() was called without any active HANDLERs, LOCK TABLES
      or global read locks. 
      
      However, this can happen in several cases when opening system
      tables. The assert would, for example, be triggered when drop
      function was called from a connection with active HANDLERs as
      this would cause open_ltable() to be called for mysql.proc.
      The assert could also be triggered when using table-based
      general log (mysql.general_log).
      
      This patch removes the asserts since they will be triggered in
      several legitimate cases and because the asserts are no longer
      relevant due to changes in how locks are released.
      
      The patch also fixes set_needs_thr_lock_abort() that before 
      ignored its parameter and always set the member variable to TRUE.
      
      Test case added to mdl_sync.test.
      Thanks to Dmitry Lenev for help with this bug!
      e190a415
    • Konstantin Osipov's avatar
      Merge next-mr -> next-4284 · b92ab41c
      Konstantin Osipov authored
      b92ab41c
    • Konstantin Osipov's avatar
      Merge next-4284 -> next-4284-merge. · dfc15e2a
      Konstantin Osipov authored
      dfc15e2a
    • Konstantin Osipov's avatar
      Merge next-mr -> next-4284. · b7a80c67
      Konstantin Osipov authored
      Post merge fixes. In sys_vars tests suite, whenever we use LOCK TABLE WRITE,
      adjust to lock the subject table indirecty via a view, to ensure that
      there the desired lock conflict in thr_lock.c is still taking place.
      If locked directly in LOCK TABLES list, thr_lock.c does not get
      involved.
      Adjust the thread wait state names in information_schema.processlist.
      b7a80c67
    • Dmitry Lenev's avatar
      Fix for bug #50784 "MDL: Assertion `m_tickets.is_empty() || · 0ede7125
      Dmitry Lenev authored
      m_tickets.front() == m_trans_sentinel'".
      
      Debug build of server crashed due to assert failure in MDL
      subsystem when one tried to execute multi-table REPAIR or
      OPTIMIZE in autocommit=0 mode.
      
      The assert failure occured when multi-table REPAIR or OPTIMIZE
      started processing of second table from its table list and
      tried to acquire upgradable metadata lock on this table.
      The cause of the assert failure were MDL locks left over from
      processing of previous table. It turned out that in autocommit=0
      mode close_thread_tables() which happens at the end of table
      processing doesn't release metadata locks.
      
      This fix solves problem by releasing locks explicitly using
      MDL_context::release_trans_locks() call.
      0ede7125
    • Konstantin Osipov's avatar
      Merge next-mr -> next-4284. · 0ce6d93f
      Konstantin Osipov authored
      0ce6d93f
  4. 02 Feb, 2010 2 commits
  5. 01 Feb, 2010 6 commits
    • Konstantin Osipov's avatar
      Merge next-mr -> next-4284. · 2c6015e8
      Konstantin Osipov authored
      2c6015e8
    • Konstantin Osipov's avatar
    • Dmitry Lenev's avatar
      Fix for sporadical hangs of mdl_sync.test caused by patch · 5ff4406b
      Dmitry Lenev authored
      which implemented new type-of-operation-aware metadata
      locks and added a wait-for graph based deadlock detector
      to the MDL subsystem (this patch fixed bug #46272 "MySQL
      5.4.4, new MDL: unnecessary deadlock" and bug #37346
      "innodb does not detect deadlock between update and alter
      table").
      
      These hangs were caused by missing include of
      wait_condition.inc. This fix simply adds them.
      5ff4406b
    • Dmitry Lenev's avatar
      Fix for sporadical crashes of lock_multi_bug38499.test · 19940fa7
      Dmitry Lenev authored
      caused by patch which implemented new type-of-operation-aware
      metadata locks and added a wait-for graph based deadlock
      detector to the MDL subsystem (this patch fixed bug #46272
      "MySQL 5.4.4, new MDL: unnecessary deadlock" and bug #37346
      "innodb does not detect deadlock between update and alter
      table").
      
      Crashes were caused by a race in MDL_context::try_acquire_lock().
      This method added MDL_ticket to the list of granted tickets and
      released lock protecting list before setting MDL_ticket::m_lock.
      Thus some other thread was able to see ticket without properly
      set m_lock member for some short period of time. If this thread
      called method involving this member during this period crash
      happened.
      
      This fix ensures that MDL_ticket::m_lock is set in all cases
      when ticket is added to granted/pending lists in MDL_lock.
      19940fa7
    • Konstantin Osipov's avatar
      Fix a Windows compilation warning (req_count is later used · c5b48ab3
      Konstantin Osipov authored
      in a pointer arithmetics expression).
      c5b48ab3
    • Dmitry Lenev's avatar
      Implement new type-of-operation-aware metadata locks. · afd15c43
      Dmitry Lenev authored
      Add a wait-for graph based deadlock detector to the
      MDL subsystem.
      
      Fixes bug #46272 "MySQL 5.4.4, new MDL: unnecessary deadlock" and
      bug #37346 "innodb does not detect deadlock between update and
      alter table".
      
      The first bug manifested itself as an unwarranted abort of a
      transaction with ER_LOCK_DEADLOCK error by a concurrent ALTER
      statement, when this transaction tried to repeat use of a
      table, which it has already used in a similar fashion before
      ALTER started.
      
      The second bug showed up as a deadlock between table-level
      locks and InnoDB row locks, which was "detected" only after
      innodb_lock_wait_timeout timeout.
      
      A transaction would start using the table and modify a few
      rows.
      Then ALTER TABLE would come in, and start copying rows
      into a temporary table. Eventually it would stumble on
      the modified records and get blocked on a row lock.
      The first transaction would try to do more updates, and get
      blocked on thr_lock.c lock.
      This situation of circular wait would only get resolved
      by a timeout.
      
      Both these bugs stemmed from inadequate solutions to the
      problem of deadlocks occurring between different
      locking subsystems.
      
      In the first case we tried to avoid deadlocks between metadata
      locking and table-level locking subsystems, when upgrading shared
      metadata lock to exclusive one.
      Transactions holding the shared lock on the table and waiting for
      some table-level lock used to be aborted too aggressively.
      
      We also allowed ALTER TABLE to start in presence of transactions
      that modify the subject table. ALTER TABLE acquires
      TL_WRITE_ALLOW_READ lock at start, and that block all writes
      against the table (naturally, we don't want any writes to be lost
      when switching the old and the new table). TL_WRITE_ALLOW_READ
      lock, in turn, would block the started transaction on thr_lock.c
      lock, should they do more updates. This, again, lead to the need
      to abort such transactions.
      
      The second bug occurred simply because we didn't have any
      mechanism to detect deadlocks between the table-level locks
      in thr_lock.c and row-level locks in InnoDB, other than
      innodb_lock_wait_timeout.
      
      This patch solves both these problems by moving lock conflicts
      which are causing these deadlocks into the metadata locking
      subsystem, thus making it possible to avoid or detect such
      deadlocks inside MDL.
      
      To do this we introduce new type-of-operation-aware metadata
      locks, which allow MDL subsystem to know not only the fact that
      transaction has used or is going to use some object but also what
      kind of operation it has carried out or going to carry out on the
      object.
      
      This, along with the addition of a special kind of upgradable
      metadata lock, allows ALTER TABLE to wait until all
      transactions which has updated the table to go away.
      This solves the second issue.
      Another special type of upgradable metadata lock is acquired
      by LOCK TABLE WRITE. This second lock type allows to solve the
      first issue, since abortion of table-level locks in event of
      DDL under LOCK TABLES becomes also unnecessary.
      
      Below follows the list of incompatible changes introduced by
      this patch:
      
      - From now on, ALTER TABLE and CREATE/DROP TRIGGER SQL (i.e. those
        statements that acquire TL_WRITE_ALLOW_READ lock)
        wait for all transactions which has *updated* the table to
        complete.
      
      - From now on, LOCK TABLES ... WRITE, REPAIR/OPTIMIZE TABLE
        (i.e. all statements which acquire TL_WRITE table-level lock) wait
        for all transaction which *updated or read* from the table
        to complete.
        As a consequence, innodb_table_locks=0 option no longer applies
        to LOCK TABLES ... WRITE.
      
      - DROP DATABASE, DROP TABLE, RENAME TABLE no longer abort
        statements or transactions which use tables being dropped or
        renamed, and instead wait for these transactions to complete.
      
      - Since LOCK TABLES WRITE now takes a special metadata lock,
        not compatible with with reads or writes against the subject table
        and transaction-wide, thr_lock.c deadlock avoidance algorithm
        that used to ensure absence of deadlocks between LOCK TABLES
        WRITE and other statements is no longer sufficient, even for
        MyISAM. The wait-for graph based deadlock detector of MDL
        subsystem may sometimes be necessary and is involved. This may
        lead to ER_LOCK_DEADLOCK error produced for multi-statement
        transactions even if these only use MyISAM:
      
        session 1:         session 2:
        begin;
      
        update t1 ...      lock table t2 write, t1 write;
                           -- gets a lock on t2, blocks on t1
      
        update t2 ...
        (ER_LOCK_DEADLOCK)
      
      - Finally,  support of LOW_PRIORITY option for LOCK TABLES ... WRITE
        was abandoned.
        LOCK TABLE ... LOW_PRIORITY WRITE from now on has the same
        priority as the usual LOCK TABLE ... WRITE.
        SELECT HIGH PRIORITY no longer trumps LOCK TABLE ... WRITE  in
        the wait queue.
      
      - We do not take upgradable metadata locks on implicitly
        locked tables. So if one has, say, a view v1 that uses
        table t1, and issues:
        LOCK TABLE v1 WRITE;
        FLUSH TABLE t1; -- (or just 'FLUSH TABLES'),
        an error is produced.
        In order to be able to perform DDL on a table under LOCK TABLES,
        the table must be locked explicitly in the LOCK TABLES list.
      afd15c43
  6. 21 Jan, 2010 2 commits
    • Dmitry Lenev's avatar
      Patch that changes metadata locking subsystem to use mutex per lock and · a63f8480
      Dmitry Lenev authored
      condition variable per context instead of one mutex and one conditional
      variable for the whole subsystem.
      
      This should increase concurrency in this subsystem.
      
      It also opens the way for further changes which are necessary to solve
      such bugs as bug #46272 "MySQL 5.4.4, new MDL: unnecessary deadlock"
      and bug #37346 "innodb does not detect deadlock between update and alter
      table".
      
      Two other notable changes done by this patch:
      
      - MDL subsystem no longer implicitly acquires global intention exclusive
        metadata lock when per-object metadata lock is acquired. Now this has
        to be done by explicit calls outside of MDL subsystem.
      - Instead of using separate MDL_context for opening system tables/tables
        for purposes of I_S we now create MDL savepoint in the main context
        before opening tables and rollback to this savepoint after closing
        them. This means that it is now possible to get ER_LOCK_DEADLOCK error
        even not inside a transaction. This might happen in unlikely case when
        one runs DDL on one of system tables while also running DDL on some
        other tables. Cases when this ER_LOCK_DEADLOCK error is not justified
        will be addressed by advanced deadlock detector for MDL subsystem which
        we plan to implement.
      a63f8480
    • Alexander Nozdrin's avatar
      Auto-merge from mysql-next-mr. · b78e3a5d
      Alexander Nozdrin authored
      b78e3a5d
  7. 20 Jan, 2010 4 commits
    • Luis Soares's avatar
      Removes duplicate entry for ER_SLAVE_IGNORE_SERVER_IDS · 47ac5960
      Luis Soares authored
      in errmsg.txt. Kept the one in that matched the location
      in errmsg-utf8.txt, ie after ER_UNKNOWN_LOCALE.
      47ac5960
    • Alexander Nozdrin's avatar
      Add client/dtoa.c to .bzrignore. · 97edd3aa
      Alexander Nozdrin authored
      97edd3aa
    • Alexander Nozdrin's avatar
      b561f926
    • Jon Olav Hauglid's avatar
      Bug #50412 Assertion `! is_set()' failed in · c0051261
      Jon Olav Hauglid authored
                 Diagnostics_area::set_ok_status at PREPARE
      
      The problem occured during processing of stored routines. 
      Routines are loaded from mysql.proc, parsed and put into the sp cache by
      sp_cache_routine().  The assert occured because the return value from
      sp_cache_routine() was not checked for top level CALLs. This meant that any
      errors during sp_cache_routine() went unoticed and triggered the assert when
      my_ok() was later called.
      
      This is a regression introduced by the patch for Bug#30977, only visible in
      source trees with MDL and using debug builds of the server.
      
      This patch fixes the problem by checking the return value from sp_cache_routine() 
      for top level CALLs and propagating any errors similar to what is done for other 
      calls to sp_cache_routine().
      
      No test case added.
      c0051261
  8. 19 Jan, 2010 1 commit
  9. 18 Jan, 2010 4 commits
  10. 15 Jan, 2010 1 commit