Commit graph

182249 commits

Author SHA1 Message Date
Jacob Mathew
bf92784d38 MDEV-15712: If remote server used by Spider table is unavailable, some operations hang for a long time
When an attempt to connect to the remote server fails, Spider retries to
connect to the remote server 1000 times or until the connection attempt
succeeds.  This is perceived as a hang if the remote server remains
unavailable.

I have introduced changes in Spider's table status handler to fix this problem.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Merged From:
  Branch bb-10.3-MDEV-15712.
2018-04-30 19:07:44 -07:00
Sergei Golubchik
fab383aac0 Use after free in authentication 2018-05-01 00:30:17 +02:00
Sergey Vojtovich
68cbabbfb0 MDEV-15938 - TINYTEXT CHARACTER SET utf8 COMPRESSED truncates data
Unexpected data truncation may occur when storing data to compressed blob
column having multi byte variable length character sets.

The reason was incorrect number of characters limit was enforced for
blobs.
2018-04-30 19:34:08 +04:00
Sergey Vojtovich
9a84980668 MDEV-12645 - mysql_install_db: no install test db option
Added --skip-test-db option to mysql_install_db. If specified, no test
database created and relevant grants issued.

Removed --skip-auth-anonymous-user option of mysql_install_db. Now it is
covered by --skip-test-db.

Dropped some Debian patches that did the same.

Removed unused make_win_bin_dist.1, make_win_bin_dist and
mysql_install_db.pl.in.
2018-04-30 19:34:08 +04:00
Marko Mäkelä
8bbcc0d505 MDEV-12218: Put back mariabackup --innodb-flush-method
Implement innodb_flush_method as an enum parameter in Mariabackup,
instead of ignoring the option and hard-wiring it to a default value.

xb0xb.h: Remove. Only xtrabackup.cc refers to the enum parameters.

innodb_flush_method_names[], innodb_flush_method_typelib[]:
Define as non-static, so that mariabackup can share the definitions.

srv_file_flush_method: Change the type to ulong, to match the
assignment in init_one_value() and handle_options() in mariabackup.
2018-04-30 18:22:52 +03:00
Marko Mäkelä
9801715cb0 Use compile_time_assert() in InnoDB
Replace most use of #error. Some checks were impossible to
evaluate in the preprocessor due to the use of named
integer constants or enumerations.
2018-04-30 18:22:52 +03:00
Marko Mäkelä
8cd55ae2a9 Fix WITH_INNODB_EXTRA_DEBUG
The checks that used to be enabled by the flags
UNIV_AHI_DEBUG, UNIV_DDL_DEBUG, UNIV_DEBUG_FILE_ACCESSES
were already enabled in debug builds. So, there is no point
in setting these.

Only UNIV_ZIP_DEBUG is set independently of the debug build.

Allow WITH_INNODB_EXTRA_DEBUG to be set for non-debug builds as well.
Currently it only implies UNIV_ZIP_DEBUG, that is, extra validation
for operations on ROW_FORMAT=COMPRESSED tables.

page_zip_validate_low(): Allow the code to be built on non-debug server.
buf_LRU_block_remove_hashed(): Allow the code to be built without
WITH_INNODB_AHI.
2018-04-30 18:19:54 +03:00
Sergei Golubchik
a52c46e069 Bug#25471090: MYSQL USE AFTER FREE
a better fix
2018-04-30 15:49:19 +02:00
Monty
a1fe7d75dc Removed even more warning that was found with -Wunused
- Removed test if HA_FT_WTYPE == HA_KEYTYPE_FLOAT as this never worked
  (HA_KEYTYPE_FLOAT is an enum)
- Define HA_FT_MAXLEN to 126 (was tested before but never defined)
2018-04-30 15:21:52 +03:00
Monty
7d6b55b99a Added version of lex_string_eq that compares with const char *
Change all my_stcasecmp() calls that uses lexical keywords to use
lex_string_eq. This is faster as we only call strcasecmp() for
strings of different lengths.

Removed not used function lex_string_syseq()
2018-04-30 14:24:48 +03:00
Monty
862e602b5a Added more test to sql-bench
- test-alter now correctly drops all columns
- test-alter has a new test that times adding columns in middle of table
- test-insert has a new test to check updates that doesn't change data
- test-insert: update_with_key_prefix didn't change data. Now fixed
2018-04-30 14:05:27 +03:00
Jan Lindström
74abc32d30
Merge pull request #731 from codership/MDEV-15803
MDEV-15803 Fix and re-enable test galera_var_auto_inc_control_on
2018-04-30 12:54:32 +03:00
Jan Lindström
cf333b7fda
Merge branch '10.1' into MDEV-15803 2018-04-30 12:54:14 +03:00
Marko Mäkelä
cb16bc95ff MDEV-14906 Assertion index->is_instant() failed on DELETE
The assertion would fail with the following trace:

rec_init_offsets_comp_ordinary(..., format=REC_LEAF_COLUMNS_ADDED)
rec_init_offsets()
rec_get_offsets_func()
rec_copy_prefix_to_dtuple()
dict_index_build_data_tuple()
btr_pcur_restore_position_func()

When btr_cur_store_position() had stored pcur->old_rec, the table
contained instantly added columns. The table was emptied
(dict_index_t::remove_instant() invoked) between the 'store' and 'restore'
operations, causing the assertion to fail. Here is a non-deterministic
test case to repeat the scenario:

	--source include/have_innodb.inc
	--connect (con1,localhost,root,,test)
	CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE = InnoDB;
	INSERT INTO t1 VALUES (0);
	ALTER TABLE t1 ADD COLUMN a INT;
	ALTER TABLE t1 ADD UNIQUE KEY (a);
	DELETE FROM t1;
	send INSERT INTO t1 VALUES (1,0),(2,0);
	--connection default
	DELETE FROM t1; # the assertion could fail here
	DROP TABLE t1;
	--disconnect con1

The fix is to normalize the pcur->old_rec so that when the
record prefix is stored, it will always be in the plain format.
This can be done, because the record prefix never includes any
instantly added columns. (It can only include key columns, which
can never be instantly added.)

rec_copy_prefix_to_buf(): Convert REC_STATUS_COLUMNS_ADDED to
REC_STATUS_ORDINARY format.
2018-04-30 12:00:30 +03:00
Marko Mäkelä
38bc4bcc96 MDEV-16058 Unnecessary computations for SPATIAL INDEX
dict_index_copy_rec_order_prefix(): Avoid invoking
dict_index_get_n_unique_in_tree_nonleaf().

create_index(): Simplify code for creating SPATIAL or FULLTEXT index.

rec_copy_prefix_to_buf(): Skip the loop for SPATIAL INDEX.
2018-04-30 10:33:03 +03:00
Marko Mäkelä
d73241c0a9 Simplify dict_stats_analyze_index_level()
Only allocate n_uniq elements for offsets, instead of index->n_fields.
(Statistics are never computed on spatial indexes, so we never need
to access more fields even in rec_copy_prefix_to_buf().)
2018-04-30 10:28:50 +03:00
Marko Mäkelä
9b1313e849 rtr_estimate_n_rows_in_range(): Simplify code 2018-04-30 07:55:11 +03:00
Marko Mäkelä
935025f891 Add an explicit cast from double to ha_rows 2018-04-30 07:46:22 +03:00
Jan Lindström
89a7ad636c
Merge pull request #732 from codership/galera_gcs_fragment_auto_inc
Save / restore auto_increment_offset in test galera_gcs_fragment
2018-04-30 07:36:16 +03:00
Marko Mäkelä
b2c4740034 Fix some -Wsign-conversion
InnoDB was using int64_t instead of ha_rows (unsigned 64-bit).
2018-04-29 17:53:21 +03:00
Marko Mäkelä
baa5a43d8c MDEV-16045: Replace log_group_t with log_t::files
There is only one log_sys and only one log_sys.log.

log_t::files::create(): Replaces log_init().

log_t::files::close(): Replaces log_group_close(), log_group_close_all().

fil_close_log_files(): if (free) log_sys.log_close();
The callers that passed free=true used to call log_group_close_all().

log_header_read(): Replaces log_group_header_read().

log_t::files::file_header_bufs_ptr: Use a single allocation.

log_t::files::file_header_bufs[]: Statically allocate the pointers.

log_t::files::set_fields(): Replaces log_group_set_fields().

log_t::files::calc_lsn_offset(): Replaces log_group_calc_lsn_offset().
Simplify the computation by using fewer variables.

log_t::files::read_log_seg(): Replaces log_group_read_log_seg().

log_sys_t::complete_checkpoint(): Replaces log_io_complete_checkpoint().

fil_aio_wait(): Move the logic from log_io_complete().
2018-04-29 09:46:24 +03:00
Marko Mäkelä
d73a898d64 MDEV-16045: Allocate log_sys statically
There is only one redo log subsystem in InnoDB. Allocate the object
statically, to avoid unnecessary dereferencing of the pointer.

log_t::create(): Renamed from log_sys_init().

log_t::close(): Renamed from log_shutdown().

log_t::checkpoint_buf_ptr: Remove. Allocate log_t::checkpoint_buf
statically.
2018-04-29 09:46:24 +03:00
Marko Mäkelä
715e4f4320 MDEV-12218 Clean up InnoDB parameter validation
Bind more InnoDB parameters directly to MYSQL_SYSVAR and
remove "shadow variables".

innodb_change_buffering: Declare as ENUM, not STRING.

innodb_flush_method: Declare as ENUM, not STRING.

innodb_log_buffer_size: Bind directly to srv_log_buffer_size,
without rounding it to a multiple of innodb_page_size.

LOG_BUFFER_SIZE: Remove.

SysTablespace::normalize_size(): Renamed from normalize().

innodb_init_params(): A new function to initialize and validate
InnoDB startup parameters.

innodb_init(): Renamed from innobase_init(). Invoke innodb_init_params()
before actually trying to start up InnoDB.

srv_start(bool): Renamed from innobase_start_or_create_for_mysql().
Added the input parameter create_new_db.

SRV_ALL_O_DIRECT_FSYNC: Define only for _WIN32.

xb_normalize_init_values(): Merge to innodb_init_param().
2018-04-29 09:41:42 +03:00
Sergei Golubchik
c4499a0391 Merge branch '5.5' into 10.0 2018-04-29 00:38:10 +02:00
Marko Mäkelä
9ed2b2b2b8 Do not divide or multiply by srv_page_size
Instead, shift by srv_page_size_shift.
2018-04-28 20:52:22 +03:00
Marko Mäkelä
a90100d756 Replace univ_page_size and UNIV_PAGE_SIZE
Try to use one variable (srv_page_size) for innodb_page_size.

Also, replace UNIV_PAGE_SIZE_SHIFT with srv_page_size_shift.
2018-04-28 20:45:45 +03:00
Marko Mäkelä
ba19764209 Fix most -Wsign-conversion in InnoDB
Change innodb_buffer_pool_size, innodb_fill_factor to unsigned.
2018-04-28 20:45:45 +03:00
Marko Mäkelä
e37df0f95a Fix some -Wsign-conversion 2018-04-28 20:45:39 +03:00
Marko Mäkelä
1292a01c7f Simplify simple_counter
Introduce a separate simple_atomic_counter
2018-04-28 20:43:31 +03:00
Marko Mäkelä
8861d442d6 Correct member function comments 2018-04-28 20:37:31 +03:00
Marko Mäkelä
704ef98d0a Merge 10.2 into 10.3 2018-04-28 20:36:31 +03:00
Marko Mäkelä
bcc26dce3a Revert "Fix mtr to be able to wait for >1 exited mysqld"
This reverts commit 72deed5988
which was merged as commit 29d4ac2ceb.

The change caused regressions, such as mysql-test-run failing
to run at all with --valgrind, or aborting on Windows on the
first test failure.
2018-04-28 20:29:43 +03:00
Alexey Botchkov
4968049799 MDEV-11084 Select statement with partition selection against MyISAM
table opens all partitions.

Not-used partitions are not closed now.
2018-04-28 15:16:45 +04:00
Alexander Barkov
9df0eab327 Cleanup for MDEV-16020 (fixing compilation failure on Windows) 2018-04-28 08:49:07 +04:00
Alexander Barkov
96a301bbbe MDEV-16020 SP variables inside GROUP BY..WITH ROLLUP break replication
The code passing positions in the query to constructors of
Rewritable_query_parameter descendants (e.g. Item_splocal)
was not reliable. It used various Lex_input_stream methods:
- get_tok_start()
- get_tok_start_prev()
- get_tok_end()
- get_ptr()
to find positions of the recently scanned tokens.

The challenge was mostly to choose between get_tok_start()
and get_tok_start_prev(), taking into account to the current
grammar (depending if lookahead takes place before
or after we read the positions in every particular rule).

But this approach did not work at all in combination
with token contractions, when MYSQLlex() translates
two tokens into one token ID, for example:
   WITH ROLLUP -> WITH_ROLLUP_SYM

As a result, the tokenizer is already one more token ahead.
So in query fragment:

  "GROUP BY d, spvar WITH ROLLUP"

get_tok_start() points to "ROLLUP".
get_tok_start_prev() points to "WITH".

As a result, it was "WITH" who was erroneously replaced
to NAME_CONST() instead of "spvar".

This patch modifies the code to do it a different way.

Changes:

1. For keywords and identifiers, the tokenizer now
returns LEX_CTRING pointing directly to the query
fragment. So query positions are now just available using:
- $1.str           - for the beginning of a token
- $1.str+$1.length - for the end of a token

2. Identifiers are not allocated on the THD memory root
in the tokenizer any more. Allocation is now done
on later stages, in methods like LEX::create_item_ident().

3. Two LEX_CSTRING based structures were added:
- Lex_ident_cli_st - used to store the "client side"
  identifier representation, pointing to the
  query fragment. Note, these identifiers
  are encoded in @@character_set_client
  and can have broken byte sequences.

- Lex_ident_sys_st - used to store the "server side"
  identifier representation, pointing to the
  THD allocated memory. This representation
  guarantees that the identifier was checked
  for being well-formed, and is encoded in utf8.

4. To distinguish between two identifier types
   in the grammar, two Bison types were added:
   <ident_cli> and <ident_sys>

5. All non-reserved keywords were marked as
   being of the type <ident_cli>.
   All reserved keywords are still of the type NONE.

6. All curly brackets in rules collecting
   non-reserved keywords into non-terminal
   symbols were removed, e.g.:

   Was:

       keyword_sp_data_type:
         BIT_SYM           {}
       | BOOLEAN_SYM       {}

   Now:

       keyword_sp_data_type:
         BIT_SYM
       | BOOLEAN_SYM

  This is important NOT to have brackets here!!!!
  This is needed to make sure that the underlying
  Lex_ident_cli_ststructure correctly passes up to
  the calling rule.

6. The code to scan identifiers and keywords
  was moved from lex_one_token() into new
  Lex_input_stream methods:

   scan_ident_sysvar()
   scan_ident_start()
   scan_ident_middle()
   scan_ident_delimited()

  This was done to:
  - get rid of enormous amount of references to &yylval->lex_str
  - and remove a lot of references like lip->xxx

7. The allocating functionality which puts identifiers on the
   THD memory root now resides in methods of Lex_ident_sys_st,
   and in THD::to_ident_sys_alloc().
   get_quoted_token() was removed.

8. Cleanup: check_simple_select() was moved as a method to LEX.

9. Cleanup: Some more functionality was moved from *.yy
   to new methods were added to LEX:
     make_item_colon_ident_ident()
     make_item_func_call_generic()
     create_item_qualified_asterisk()
2018-04-27 22:11:18 +04:00
Jan Lindström
ed1d9c802d
Merge pull request #729 from codership/MDEV-15794
MDEV-15794 Fix and re-enable test galera_var_retry_autocommit
2018-04-27 14:42:47 +03:00
Jan Lindström
e0208e51d0
Merge pull request #730 from codership/MDEV-13549-fixes-for-galera_ist_mysqldump
MDEV-13549 Record and re-enable galera_ist_mysqldump
2018-04-27 13:37:45 +03:00
Daniele Sciascia
b8d4ae0838 Save / restore auto_increment_offset in test galera_gcs_fragment
Test galera_gcs_fragment performs cluster reconfiguration, so
`auto_increment_offset` may change, and check test case at the
end of test fails.
2018-04-27 12:02:23 +02:00
Sergei Golubchik
5cfe52314e Bug#25471090: MYSQL USE AFTER FREE
fix another similar line

followup for 7828ba0df4
2018-04-27 11:32:19 +02:00
Daniele Sciascia
74f22939dc MDEV-15803 Fix and re-enable test galera_var_auto_inc_control_on
The test assumes that `@@global.auto_increment_offset` is equal to
`wsrep_local_index + 1`. Which is normally the case if galera runs
with option `wsrep_auto_increment_control` enabled.
However, if some prior test performs a restart of a server, then
`wsrep_local_index` may change, and galera will set the value of
`auto_increment_offset` accordingly.
However, if `auto_increment_offset` changes during a test run, then
mtr will complain. To avoid that, tests that perform restarts include
`auto_increment_offset_save.inc` and `auto_increment_offset_restore.inc`.
Which reset the value of `auto_increment_offset`. And when that
happens, `auto_increment_offset` will no longer be equal to
`wsrep_local_index + 1`, and the test fails.
To avoid this problem, simply check that the offsets are different
on the nodes that compose the cluster.
2018-04-27 11:05:04 +02:00
Jan Lindström
e2c5283568
Merge pull request #723 from codership/10.1-MDEV-16005
MDEV-16005 sporadic failures with galera tests MW-328B and MW-328C
2018-04-27 09:17:01 +03:00
Igor Babaev
6c5e60f1b1 MDEV-16038 Assertion `map->n_bits > 0' failed (my_bitmap.c:386: bitmap_is_clear_all)
Rows with no elements are not allowed in a table value constructor
unless it is used in an INSERT statement.
2018-04-26 16:38:56 -07:00
Marko Mäkelä
99fa7c6c2f Merge 10.2 into 10.3 2018-04-26 22:58:41 +03:00
Marko Mäkelä
2898c7ec9e MDEV-15914: Make mtr_buf_t a plain class 2018-04-26 22:53:33 +03:00
Marko Mäkelä
362151e8c8 MDEV-15914: Simplify mlog_open_and_write_index() 2018-04-26 22:53:33 +03:00
Marko Mäkelä
6f88bc4511 MDEV-15914: Use buf_block_t* for undo, not page_t*
trx_undof_page_add_undo_rec_log(): Write the undo page number
directly from the buf_block_t descriptor, not by decoding the
fields in the page frame.
2018-04-26 22:53:33 +03:00
Marko Mäkelä
76c62bc69c MDEV-15914: Restore MLOG_UNDO_INSERT
trx_undof_page_add_undo_rec_log(): Write the MLOG_UNDO_INSERT
record instead of the equivalent MLOG_2BYTES and MLOG_WRITE_STRING.
This essentially reverts commit 9ee8917dfd.

In MariaDB 10.3, I attempted to simplify the crash recovery code
by making use of lower-level redo log records. It turns out that
we must keep the redo log parsing code in order to allow crash-upgrade
from older MariaDB versions (MDEV-14848).

Now, it further turns out that the InnoDB redo log record format is
suboptimal for logging multiple changes to a single page. This simple
change to the redo logging of undo log significantly affects the
INSERT and UPDATE performance.

Essentially, we wrote
	(space_id,page_number,MLOG_2BYTES,2 bytes)
	(space_id,page_number,MLOG_WRITE_STRING,N+4 bytes)
instead of the previously written
	(space_id,page_number,MLOG_UNDO_INSERT,N+2 bytes)

The added redo log volume caused a single-threaded INSERT
(without innodb_adaptive_hash_index) of
1,000,000 rows to consume 11 seconds instead of 9 seconds,
and a subsequent UPDATE of 30,000,000 rows to consume 64 seconds
instead of 58 seconds. If we omitted all redo logging for the
undo log, the INSERT would consume only 4 seconds.
2018-04-26 22:53:33 +03:00
Marko Mäkelä
83bd4dd1ee MDEV-15914: Remove trx_t::undo_mutex
The trx_t::undo_mutex covered both some main-memory data structures
(trx_undo_t) and access to undo pages. The trx_undo_t is only
accessed by the thread that is associated with a running transaction.
Likewise, each transaction has its private set of undo pages.
The thread that is associated with an active transaction may
lock multiple undo pages concurrently, but no other thread may
lock multiple pages of a foreign transaction.

Concurrent access to the undo logs of an active transaction is possible,
but trx_undo_get_undo_rec_low() only locks one undo page at a time,
without ever holding any undo_mutex.

It seems that the trx_t::undo_mutex would have been necessary if
multi-threaded execution or rollback of a single transaction
had been implemented in InnoDB.
2018-04-26 22:53:33 +03:00
Marko Mäkelä
f7cac5e26c MDEV-12288/MDEV-15132/MDEV-15158: Adjust a comment 2018-04-26 22:53:33 +03:00
Marko Mäkelä
ff0000cdd2 MDEV-15914: Remove trx_undo_t::empty
Use the value trx_undo_t::top_undo_no == IB_ID_MAX for indicating
that an undo log is empty.
2018-04-26 22:53:33 +03:00