1. 11 Jun, 2018 1 commit
    • Alexander Barkov's avatar
      MDEV-16190 Server crashes in Item_null_result::field_type on SELECT with time... · 52271989
      Alexander Barkov authored
      MDEV-16190 Server crashes in Item_null_result::field_type on SELECT with time field, ROLLUP and HAVING
      
      virtual Item_null_result::get_date() was not overridden.
      It used the inherited Item::get_date(), which tests field_type(),
      which in case of Item_null_result calls result_field->field_type(),
      and result_field is not really always set (e.g. it's not set in the
      test case from the bug report).
      
      Overriding Item_null::get_date() like it's done for other val_xxx() methods.
      This make the code more symmetric across data types.
      
      In the new reduction, get_date() immediately returns NULL without entering
      into any data type specific code.
      52271989
  2. 09 Jun, 2018 1 commit
    • Varun Gupta's avatar
      MDEV-16191: Analyze format=json gives incorrect value for r_limit inside a dependent · c17468d4
      Varun Gupta authored
      subquery when ORDER BY is present
      
      Currently for setting r_limit we divide with the number of iterations we invoke the dependent subquery.
      This is not needed for the case of limit. For varying limits we produce the output that the limit varies with
      execution.
      Also there is a type for filtered , we forgot to multiply by 100 as it is represented as a percent.
      c17468d4
  3. 07 Jun, 2018 1 commit
    • Marko Mäkelä's avatar
      MDEV-16416 Crash on IMPORT TABLESPACE of a ROW_FORMAT=COMPRESSED table · 3627dd7f
      Marko Mäkelä authored
      fil_iterate(): Invoke fil_encrypt_buf() correctly when
      a ROW_FORMAT=COMPRESSED table with a physical page size of
      innodb_page_size is being imported. Also, validate the page checksum
      before decryption, and reduce the scope of some variables.
      
      AbstractCallback::operator()(): Remove the parameter 'offset'.
      The check for it in FetchIndexRootPages::operator() was basically
      redundant and dead code since the previous refactoring.
      3627dd7f
  4. 06 Jun, 2018 1 commit
  5. 05 Jun, 2018 4 commits
  6. 29 May, 2018 4 commits
    • Vladislav Vaintroub's avatar
      c1698e8d
    • Marko Mäkelä's avatar
      MDEV-16283 ALTER TABLE...DISCARD TABLESPACE still takes long on a large buffer pool · 6aa50bad
      Marko Mäkelä authored
      Also fixes MDEV-14727, MDEV-14491
      InnoDB: Error: Waited for 5 secs for hash index ref_count (1) to drop to 0
      by replacing the flawed wait logic in dict_index_remove_from_cache_low().
      
      On DISCARD TABLESPACE, there is no need to drop the adaptive hash index.
      We must drop it on IMPORT TABLESPACE, and eventually on DROP TABLE or
      DROP INDEX. As long as the dict_index_t object remains in the cache
      and the table remains inaccessible, the adaptive hash index entries
      to orphaned pages would not do any harm. They would be dropped when
      buffer pool pages are reused for something else.
      
      btr_search_drop_page_hash_when_freed(), buf_LRU_drop_page_hash_batch():
      Remove the parameter zip_size, and pass 0 to buf_page_get_gen().
      
      buf_page_get_gen(): Ignore zip_size if mode==BUF_PEEK_IF_IN_POOL.
      
      buf_LRU_drop_page_hash_for_tablespace(): Drop the adaptive hash index
      even if the tablespace is inaccessible.
      
      buf_LRU_drop_page_hash_for_tablespace(): New global function, to drop
      the adaptive hash index.
      
      buf_LRU_flush_or_remove_pages(), fil_delete_tablespace():
      Remove the parameter drop_ahi.
      
      dict_index_remove_from_cache_low(): Actively drop the adaptive hash index
      if entries exist. This should prevent InnoDB hangs on DROP TABLE or
      DROP INDEX.
      
      row_import_for_mysql(): Drop any adaptive hash index entries for the table.
      
      row_drop_table_for_mysql(): Drop any adaptive hash index for the table,
      except if the table resides in the system tablespace. (DISCARD TABLESPACE
      does not apply to the system tablespace, and we do no want to drop the
      adaptive hash index for other tables than the one that is being dropped.)
      
      row_truncate_table_for_mysql(): Drop any adaptive hash index entries for
      the table, except if the table resides in the system tablespace.
      6aa50bad
    • Marko Mäkelä's avatar
      Fix type mismatch · b7985a45
      Marko Mäkelä authored
      b7985a45
    • Marko Mäkelä's avatar
      MDEV-14589 InnoDB should not lock a delete-marked record · 35a9c90f
      Marko Mäkelä authored
      When the transaction isolation level is SERIALIZABLE, or when
      a locking read is performed in the REPEATABLE READ isolation level,
      InnoDB must lock delete-marked records in order to prevent another
      transaction from inserting something.
      
      However, at READ UNCOMMITTED or READ COMMITTED isolation level or
      when the parameter innodb_locks_unsafe_for_binlog is set, the
      repeatability of the reads does not matter, and there is no need
      to lock any records.
      
      row_search_for_mysql(): Skip locks on delete-marked committed records
      upfront, instead of invoking row_unlock_for_mysql() afterwards.
      The unlocking never worked for secondary index records.
      35a9c90f
  7. 26 May, 2018 4 commits
  8. 25 May, 2018 1 commit
    • Sergei Golubchik's avatar
      embedded use-after-free ASAN error · 9e22cae1
      Sergei Golubchik authored
      Close MYSQL (and destroy THD) in the same thread where it was used,
      because THD embeds MDL_context, that owns some LF_PINS, that remember
      a pointer to my_thread_var->stack_ends_here.
      9e22cae1
  9. 24 May, 2018 4 commits
  10. 23 May, 2018 1 commit
    • Monty's avatar
      Fixed ASAN heap-use-after-free handler::ha_index_or_rnd_end · a816aa06
      Monty authored
      MDEV-16123 ASAN heap-use-after-free handler::ha_index_or_rnd_end
      MDEV-13828 Segmentation fault on RENAME TABLE
      
      Problem was that destructor called methods for closed table.
      Fixed by removing code in destructor.
      a816aa06
  11. 22 May, 2018 5 commits
    • Monty's avatar
      MDEV-15308 Assertion `ha_alter_info->alter_info->drop_list.elements · 908676df
      Monty authored
      Problem was that handle_if_exists_options() didn't correct
      alter_info->flags when things was removed from the list.
      908676df
    • Monty's avatar
      MDEV-16229 Replication aborts with ER_VIEW_SELECT_TMPTABLE after half-failed RENAME · da71c1ba
      Monty authored
      Problem was that detection of temporary tables was all wrong for
      RENAME TABLE.
      (Temporary tables where opened by top level call to
      open_temporary_tables(), which can't detect if a temporary table
      was renamed to something and then reused).
      
      Fixed by adding proper parsing of rename list to check against
      the current name of a table at each rename stage.
      Also change do_rename_temporary() to check against the current
      state of temporary tables, not according to the state of start
      of RENAME TABLE.
      da71c1ba
    • Monty's avatar
      Fixes for Aria transaction handling with lock tables · 2f3779d3
      Monty authored
      MDEV-10130 Assertion `share->in_trans == 0' failed in storage/maria/ma_close.c
      MDEV-10378 Assertion `trn' failed in virtual int ha_maria::start_stmt
      
      The problem was that maria_handler->trn was not properly reset
      at commit/rollback and ha_maria::exernal_lock() could get confused
      because.
      
      There was some old code in ha_maria::implicit_commit() that tried
      to take care of this, but it was not bullet proof.
      
      Fixed by adding list of all tables that is part of the maria transaction to
      TRN.
      
      A nice side effect was of the fix is that loops in
      ha_maria::implict_commit() got to be much simpler.
      
      Other things:
      - Fixed a bug in mysql_admin_table() where argument open_for_modify
        was wrongly reset for the next table in the chain
      - rollback admin command also in case of fatal error.
      - Split _ma_set_trn_for_table() to three version to simplify code
        and debugging.
      - Several new asserts to detect the original problem (that file was
        not properly removed from trn before calling ma_close())
      2f3779d3
    • sachin's avatar
      MDEV-10259 mysqld crash with certain statement length and... · 5797cbaf
      sachin authored
      order with Galera and encrypt-tmp-files=1
      
      Problem:- If trans_cache (IO_CACHE) uses encrypted tmp file
      then on next DML server will crash.
      
      Case:-
       Lets take a case , we have a table t1 , We try to do 2 inserts in t1
        1. A really long insert so that trans_cache has to use temp_file
        2. Just a small insert
      
      Analysis:- Actually server crashes from inside of galera
      library.
      /lib64/libc.so.6(abort+0x175)[0x7fb5ba779dc5]
      /usr/lib64/galera/libgalera_smm.so(_ZN6galera3FSMINS_9TrxHandle5State...
      mysys/stacktrace.c:247(my_print_stacktrace)[0x7fb5a714940e]
      sql/signal_handler.cc:160(handle_fatal_signal)[0x7fb5a715c1bd]
      sql/wsrep_hton.cc:257(wsrep_rollback)[0x7fb5bcce923a]
      sql/wsrep_hton.cc:268(wsrep_rollback)[0x7fb5bcce9368]
      sql/handler.cc:1658(ha_rollback_trans(THD*, bool))[0x7fb5bcd4f41a]
      sql/handler.cc:1483(ha_commit_trans(THD*, bool))[0x7fb5bcd4f804]
      
      but actual issue is not in galera but in mariadb, because for 2nd
      insert we should never call rollback. We are calling rollback because
      log_and_order fails it fails because write_cache fails , It fails
      because after reinit_io_cache(trans_cache) , my_b_bytes_in_cache says 0
      so we look into tmp_file for data , which is obviously wrong since temp
      was used for previous insert and it no longer exist.
      wsrep_write_cache_inc() reads the IO_CACHE in a loop, filling it with
      my_b_fill() until it returns "0 bytes read". Later
      MYSQL_BIN_LOG::write_cache() does the same.  wsrep_write_cache_inc()
      assumes that reading a zero bytes past EOF leaves the old data in the
      cache
      
      Solution:- There is two issue in my_b_encr_read
      1st we should never equal read_end to info->buffer. I mean this
      does not make sense read_end should always point to end of buffer.
      2nd For most of the case(apart from async IO_CACHE) info->pos_in_file
      should be equal to info->buffer position wrt to temp file , since
      in this case we are not changing info->buffer it should remain
      unchanged.
      5797cbaf
    • Jacob Mathew's avatar
      MDEV-12900: spider tests failed in buildbot with valgrind · 519060da
      Jacob Mathew authored
      The failures with valgrind occur as a result of Spider sometimes using the
      wrong transaction for operations in background threads that send requests to
      the data nodes.  The use of the wrong transaction caused the networking to the
      data nodes to use the wrong thread in some cases.  Valgrind eventually
      detects this when such a thread is destroyed before it is used to disconnect
      from the data node by that wrong transaction when it is freed.
      
      I have fixed the problem by correcting the transaction used in each of these
      cases.
      
      Author:
        Jacob Mathew.
      
      Reviewer:
        Kentoku Shiba.
      
      Cherry-Picked:
        Commit afe5a51c on branch 10.2
      519060da
  12. 19 May, 2018 3 commits
  13. 18 May, 2018 2 commits
    • Vladislav Vaintroub's avatar
      MDEV-16220 MTR - do not pass UTF8 on the command line for mysql client. · 27a7365f
      Vladislav Vaintroub authored
      It should work ok on all Unixes, but on Windows ,only worked by accident
      in the past, with client not being Unicode safe.
      
      It stopped working with Visual Studio 2017 15.7 update now.
      27a7365f
    • Jacob Mathew's avatar
      MDEV-7914: spider/bg.ha, spider/bg.ha_part crash server sporadically in buildbot · f76a17e3
      Jacob Mathew authored
      The crash occurs when a thread that is closing its connection attempts to
      access Spider transaction information when another thread has freed that memory
      while processing Spider plugin deinit.  This occurs because Spider does not
      adjust the plugin's reference count when it sets a transaction information
      pointer for the plugin.
      
      The fix I implemented changes the way Spider sets the transaction information
      pointer to use thd_set_ha_data() so that Spider's plugin reference counter is
      adjusted as well.
      
      Author:
        Jacob Mathew.
      
      Reviewer:
        Kentoku Shiba.
      
      Merged From:
        Commit ab9d420d on branch 10.2
      f76a17e3
  14. 17 May, 2018 1 commit
  15. 16 May, 2018 3 commits
  16. 15 May, 2018 3 commits
    • Monty's avatar
      MDEV-14943 Alter table ORDER BY bug · b050df4f
      Monty authored
      Problem was that if copy_data_between_tables() didn't do proper
      clean up in case of failures:
      - copy object was not properly freed
      - end_bulk_insert() was not called
      - mysql_trans_prepare_alter_copy_data() set THD->transaction.on to
        false which was not properly restored
      
      The last part caused a crash in Aria as Aria depends on that THD
      is correct.
      
      Other things:
      - Reset info->switched_transactional after usage (safety)
      - Reset bulk_insert_single_undo (safety)
      b050df4f
    • Monty's avatar
      MDEV-654 Assertion `share->now_transactional' failed in flush_log_for_bitmap... · 2b749a7b
      Monty authored
      MDEV-654 Assertion `share->now_transactional' failed in flush_log_for_bitmap on concurrent workload with Aria tables
      
      Problem was that we the bitmap needs to be flushed before disabling
      logging of redo entires, as writing the bitmap to disk by
      background checkpoint may cause redo entries.
      2b749a7b
    • Oleksandr Byelkin's avatar
      MDEV-15347: Valgrind or ASAN errors in mysql_make_view on query from information_schema · 0bd2b802
      Oleksandr Byelkin authored
      Make each lex pointing to statement lex instead of global pointer in THD (no
      need store and restore the global pointer and put it on SP stack).
      0bd2b802
  17. 11 May, 2018 1 commit