Commit graph

196791 commits

Author SHA1 Message Date
Oleksandr Byelkin
9206c1ea97 Merge branch '10.10' into 10.11 2022-10-04 13:55:38 +02:00
Oleksandr Byelkin
bb76dcbec7 Merge branch '10.9' into 10.10 2022-10-04 13:32:38 +02:00
Oleksandr Byelkin
55e07d9ade Merge branch '10.8' into 10.9 2022-10-04 13:23:13 +02:00
Sergei Golubchik
8759967d1c MDEV-29625 Some clients/scripts refer to old slow log variables 2022-10-04 12:28:04 +02:00
Sergei Golubchik
05c11953ab MDEV-29595 Adjust variable name for slow log file and help referring to the value 2022-10-04 12:28:03 +02:00
Sergei Golubchik
ef08810b8b MDEV-7567 Add aliases with prefix log_slow for system variables relating to slow query log
post-merge fixes:
* remove log_slow_queries_not_using_indexes, no need to create variables
  that are deprecated since the moment of creation
* rename log_slow_query_enable->log_slow_query
  no other variable uses *_enable pattern
* MDEV-29626 Assertion `self == &Sys_slow_query_log' failed in fix_log_state
* tests

Closes #2137
2022-10-04 12:28:03 +02:00
Michael Qin
af4918b41f MDEV-7567 Add aliases with prefix log_slow for system variables relating to slow query log.
Thus, all these variables will be
grouped together and more logically named.

Descriptions for the old variables were updated to indicate they are
now aliases for the newly introduced variables with prefix log_slow.

log_slow_queries_not_using_indexes_filter will not be addressed
in this merge request.
log_throttle_queries_not_using_indexes seems to no longer be in use.

MTR tests are also updated to include the new variable names.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
2022-10-04 12:28:03 +02:00
Sergei Golubchik
315f2e8b81 cleanup: remove *slow*_basic tests 2022-10-04 12:28:03 +02:00
Oleksandr Byelkin
2f70784c2a Merge branch '10.7' into 10.8 2022-10-04 11:42:37 +02:00
Oleksandr Byelkin
b6ebadaa66 Merge branch '10.6' into 10.7 2022-10-04 07:41:35 +02:00
Oleksandr Byelkin
fe449affcf Merge branch '10.5' into 10.6 2022-10-03 16:20:59 +02:00
Rucha Deodhar
7865c8c9a2 Crash in INSERT...SELECT..RETURNING with subquery
Underlying causes of all bugs mentioned below are same. This patch fixes
all of them:
1) MDEV-25028: ASAN use-after-poison in
base_list_iterator::next or Assertion `sl->join == 0' upon
INSERT .. RETURNING via PS
2) MDEV-25187: Assertion `inited == NONE || table->open_by_handler'
failed or Direct leak in init_dynamic_array2 upon INSERT .. RETURNING
and memory leak in init_dynamic_array2
3) MDEV-28740: crash in INSERT RETURNING subquery in prepared statements
4) MDEV-27165: crash in base_list_iterator::next
5) MDEV-29686: Assertion `slave == 0' failed in
st_select_lex_node::attach_single

Analysis:
consider this statement:
INSERT(1)...SELECT(2)...(SELECT(3)...) RETURNING (SELECT(4)...)

When RETURNING is encountered, add_slave() changes how selects are linked.
It makes the builtin_select(1) slave of SELECT(2). This causes
losing of already existing slave(3) (which is nested select of SELECT of
INSERT...SELECT). When really, builtin_select (1) shouldn't be slave to
SELECT(2) because it is not nested within it. Also, push_select() to use
correct context also changed how select are linked.
During reinit_stmt_before_use(), we expect the selects to
be cleaned-up and have join=0. Since these selects are not linked correctly,
clean-up doesn't happen correctly so join is not NULL. Hence the crash.

Fix:
IF we are parsing RETURNING, make is_parsing_returning= true for
current select. get rid of add_slave(). In place of push_select(), used
push_context() to have correct context (the context of builtin_select)
to resolve items in item_list. And add these items to item_list of
builtin_select.
2022-10-03 18:07:41 +05:30
Sergei Golubchik
900d7bf360 Merge branch '10.5' into 10.6 2022-10-02 22:14:21 +02:00
Sergei Golubchik
3a2116241b Merge branch '10.4' into 10.5 2022-10-02 14:38:13 +02:00
Sergei Golubchik
d4f6d2f08f Merge branch '10.3' into 10.4 2022-10-01 23:07:26 +02:00
Sergei Golubchik
dd8833bff0 cleanup: suppress rocksdb compilation warning, fix a comment 2022-10-01 17:45:23 +02:00
Sergei Golubchik
fa6d7e4e98 compilation error
extended initializers are only allowed since c++11
2022-10-01 17:45:23 +02:00
Aleksey Midenkov
ba875e9396 MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection
When ha_end_bulk_insert() fails F_UNLCK was done twice: in
select_insert::prepare_eof() and in select_create::abort_result_set().

Now we avoid making F_UNLCK in prepare_eof() if error is non-zero.
2022-09-30 23:58:08 +03:00
Sergei Golubchik
2ab52cc0e5 update the test after merge
after d7d3ad698a debug_sync waits are no longer interrupted by
soft kills that server shutdown is using. Luckily in this test
there's no need to wait, it wants the commit to be properly completed,
fully committed in both engines.
2022-09-30 17:27:38 +02:00
Alexander Barkov
3744b8ae31 MDEV-20760 Add Type_handler::KEY_pack_flags()
Backporting from 10.5 to 10.4

This is needed to fix MDEV-28727 easier.
2022-09-30 14:56:33 +04:00
Sergei Golubchik
194cc36805 Merge branch '10.5' into 10.6 2022-09-30 12:29:24 +02:00
Oleksandr Byelkin
f65ba9aeb7 MDEV-17124: mariadb 10.1.34, views and prepared statements: ERROR 1615 (HY000): Prepared statement needs to be re-prepared
The problem is that if table definition cache (TDC) is full of real tables
which are in tables cache, view definition can not stay there so will be
removed by its own underlying tables.
In situation above old mechanism of detection matching definition in PS
and current version always require reprepare and so prevent executing
the PS.

One work around is to increase TDC, other - improve version check for
views/triggers (which is done here). Now in suspicious cases we check:
 - timestamp (microseconds) of the view to be sure that version really
   have changed;
 - time (microseconds) of creation of a trigger related to time
   (microseconds) of statement preparation.
2022-09-30 12:11:37 +02:00
Oleksandr Byelkin
98e62e6317 Better declaration of the buffer size 2022-09-30 12:11:37 +02:00
Sergei Golubchik
d026447101 Merge branch '10.10' into 10.11 2022-09-30 10:39:47 +02:00
Alexander Barkov
1118e979c2 MDEV-29672 Add MTR tests covering key and key segment flags and types 2022-09-30 11:08:49 +04:00
Anel Husakovic
1f51d6c0f6 MDEV-28548: ER_TABLEACCESS_DENIED_ERROR is missing information about DB
- Added missing information about database of corresponding table for various types of commands
- Update some typos

- Reviewed by: <vicentiu@mariadb.org>
2022-09-30 08:48:57 +02:00
Marko Mäkelä
e29fb95614 Cleanup: Remove innobase_destroy_background_thd()
We do not need a non-inline wrapper for the function
destroy_background_thd().
2022-09-30 08:25:00 +03:00
Aleksey Midenkov
aa08a7442a MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock
ha_release_auto_increment() must be done before F_UNLCK.
Non-atomic case is handled by select_insert::binlog_query().
2022-09-30 00:55:42 +03:00
Aleksey Midenkov
c579d66ba6 MDEV-29628 Memory leak after CREATE OR REPLACE with foreign key
MDEV-28933 added a condition to avoid keeping cached foreign keys when
renaming into temporary table. Such foreign keys must be freed.
2022-09-30 00:55:42 +03:00
Aleksey Midenkov
cb583b2f1b MDEV-29609 create_not_windows test fails with different result
make_tmp_name() creates temporary name with prefix containing PID and
TID. This prefix influences max length of the rest of the name (the
whole name is limited by NAME_LEN). During the test run PID and TID
can change. PID increases when the server restarts. TID is incremented
with the new connections (generated by next_thread_id(), is not the
posix thread ID).

During the test run PID can increase max 2 decimal positions: from
tens to thousands this requires ~900 restarts. TID depends on
connection count, but for test we assume it will not trespass 100000
connections which is 5 decimal positions. So it should be enough to
reserve 7 characters for PID and TID increment.

The patch reserves more: it reserves 12 characters for 7-decimal PID
and 5-decimal TID plus 4 chars of additional reserve (for future
prefix changes) and assumes minimal legth of the prefix is 30 bytes:

#sql-backup-PID-TID-
#sql-create-PID-TID-

4-6-PID-TID- is 10 + 4 + PID + TID, so PID + TID is 16 chars (7 + 5 + 4).
2022-09-30 00:55:42 +03:00
Aleksey Midenkov
dcd66c3814 MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables
Usually when we get into finalize_locked_tables() with error
m_locked_tables_count was not decremented. m_locked_tables_count is
decremented when we drop the original table and if we failed that
m_locked_tables_count is expected intact.

The bug comes from the fact that finalize_atomic_replace() violates
the above contract. It does HA_EXTRA_PREPARE_FOR_DROP and decrements
m_locked_tables_count. Then it tries rename_table_and_triggers() and
fails. With decremented m_locked_tables_count reopen_tables() does
nothing and we don't get new value for pos_in_locked_tables->table.

The test case demonstrates ER_ERROR_ON_RENAME where non-atomic CREATE
OR REPLACE would not fail. The original RENAME TABLE fails under such
broken environment, so nothing is wrong with atomic CREATE OR REPLACE
failing there too.
2022-09-30 00:55:42 +03:00
Sergei Golubchik
1ac8149b83 MDEV-29608 Default SSL makes mysqlslap much slower, tests fail with timeout
mysqlslap has an unusual semantics of the --iterations option, so that
$ mysqlslap --concurrency=16 --iterations=1000
performs 16,000 connections. Because of that it gets many times slower
with --ssl

Let's disable ssl for mysqlslap in mysql-test
2022-09-29 22:38:24 +02:00
Sergei Golubchik
530d19a320 after merge update *.result 2022-09-29 22:38:24 +02:00
Sergei Golubchik
6b685ea7b0 correctness assert
thd_get_ha_data() can be used without a lock, but only from the
current thd thread, when calling from anoher thread it *must*
be protected by thd->LOCK_thd_data

* fix group commit code to take thd->LOCK_thd_data
* remove innobase_close_connection() from the innodb background thread,
  it's not needed after 87775402cd and was failing the assert with
  current_thd==0
2022-09-29 10:44:39 +02:00
Sergei Golubchik
f9605eb209 fix sporadic failures on main.kill
KILL QUERY ID 0 was sometimes finding con3 that was still in the process
of disconnecting and had query_id==0 (as it didn't run any queries)
2022-09-29 10:18:50 +02:00
Igor Babaev
28ae361857 MDEV-29361 Infinite recursive calls when detecting CTE dependencies
This patch resolves the problem of improper name resolution of table
references to embedded CTEs for some queries. This improper binding could
lead to
  - infinite sequence of calls of recursive functions
  - crashes due to resolution of null pointers
  - wrong result sets returned by queries
  - bogus error messages

If the definition of a CTE contains with clauses then such CTE is called
embedding CTE while CTEs from the with clauses are called embedded CTEs.
If a table reference used in the definition of an embedded CTE cannot be
resolved within the unit that contains this reference it still may be
resolved against a CTE definition from the with clause with one of the
embedding CTEs.
A table reference can be resolved against a CTE definition if it used in
the the scope of this definition and it refers to the name of the CTE.
Table reference t is in the scope of the CTE definition of CTE cte if
- the definition of cte is an element of a with clause declared as
  RECURSIVE and the reference t belongs either to the unit to which
  this with clause is attached or to one of the elements of this clause
- the definition of cte is an element of a with clause without RECURSIVE
  specifier and the reference t belongs either to the unit to which this
  with clause is attached or to one of the elements from this clause that
  are placed before the definition of cte.
If a table reference can be resolved against several CTE definitions then
it is bound to the most embedded.

The code before this patch not always resolved table references used in
embedded CTE according to the above rules.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2022-09-28 22:33:05 -07:00
Sergei Golubchik
de130323b4 MDEV-29368 Assertion `trx->mysql_thd == thd' failed in innobase_kill_query from process_timers/timer_handler and use-after-poison in innobase_kill_query
This is a 10.5 version of 9b750dcbd8, fix for
MDEV-23536 Race condition between KILL and transaction commit

InnoDB needs to remove trx from thd before destroying it (trx), otherwise
a concurrent KILL might get a pointer from thd to a destroyed trx.

ha_close_connection() should allow engines to clear ha_data in
hton->on close_connection(). To prevent the engine from being unloaded
while hton->close_connection() is running, we remove the lock from
ha_data and unlock the plugin manually.
2022-09-29 00:11:02 +02:00
Sergei Golubchik
74ac683a7e cleanup: kill test
split it into debug and non-debug tests
2022-09-29 00:11:02 +02:00
Sergei Golubchik
d7d3ad698a debug_sync: ignore "sort" kills and disconnects
only "hard" kills will now interrupt debug_sync waits.
this is needed to have debug_sync points that work during disconnect
2022-09-29 00:11:02 +02:00
Mikhail Chalov
9de9f105b5
Use memory safe snprintf() in Connect Engine and elsewhere (#2210)
Continue with similar changes as done in 19af1890 to replace sprintf(buf, ...)
with snprintf(buf, sizeof(buf), ...), specifically in the "easy" cases where buf
is allocated with a size known at compile time.

All new code of the whole pull request, including one or several files that are
either new files or modified ones, are contributed under the BSD-new license.  I
am contributing on behalf of my employer Amazon Web Services, Inc.
2022-09-28 15:45:25 +01:00
Daniel Black
620d520d68
MDEV-29614 mariadb-upgrade calls mysql and mysql-check (#2279)
rather than mariadb/mariadb-check
2022-09-28 15:20:23 +01:00
Thirunarayanan Balathandayuthapani
7d4b2b9847 MDEV-29570 InnoDB fails to clean bulk buffer when server does rollback operation
- During bulk insert, server detects the error and does rollback
operation. At that time, InnoDB fails to clean up the bulk insert
buffer

trx_t::rollback_finish(): Removed the clean up of modified tables
from transaction

trx_t::commit_cleanup(): Free the bulk buffer for bulk insert operation

trx_t::commit(): Check whether modified table wasn't dropped only
for non-dictionary transaction
2022-09-28 18:41:00 +05:30
asklavou
9bf5274929 MDEV-29517: rpl.rpl_change_master_demote sporadically fails in BB
Problem:
=======
Test Case 4 sporadically failed upon waiting for the slave to start during
master demotion to slave, due to a GTID event not existing in the new
master's binlog. If by chance the original slave (new master) did not yet
receive all the binlog events, then this failure could occur.

Solution:
========
Sync slave with master GTID  before master demotion.

Reviewed By:
============
Brandon Nesterenko <brandon.nesterenko@mariadb.com>
2022-09-27 17:57:33 -04:00
Alexey Botchkov
b2cfcf1d1f MDEV-21134 Crash with partitioned table, PARTITION syntax, and index_merge.
When the partition table is cloned, the handlers for the partitions that were not opened
should anyway be created (but not opened).
2022-09-27 15:27:34 +04:00
Oleksandr Byelkin
47e9678982 MDEV-29022 add_slave destroy child list and has dead code
Nowdays subquery in a UNION's ORDER BY placed correctly in fake select,
the only problem was incorrect Name_resolution_contect is fixed by this
patch in parsing, so we do not need scanning/reseting of ORDER BY of
a union.
2022-09-27 09:56:21 +02:00
Marko Mäkelä
8833c24c61 Revert MDEV-29566
This reverts commit bdc5548cad
that introduced a work-around to ha_innobase::delete_table()
for avoiding failures when trying to remove table partitions.

This work-around (of not removing statistics in case of a locking
conflict) would occasionally cause a failure of the test
parts.part_supported_sql_func_innodb:

mysqltest: In included file "./suite/parts/inc/partition_supported_sql_funcs.inc":
included from ./suite/parts/inc/part_supported_sql_funcs_main.inc at line 91:
included from /buildbot/amd64-ubuntu-2004-msan/build/mysql-test/suite/parts/t/part_supported_sql_func_innodb.test at line 44:
At line 234: query 'alter table t66
reorganize partition s1 into
(partition p0 values less than ($valsqlfunc),
partition p1 values less than maxvalue)' failed: ER_DUP_KEY (1022): Can't write; duplicate key in table 'mysql.innodb_table_stats'
2022-09-27 10:30:49 +03:00
Sergei Golubchik
07581249e9 MDEV-29632 SUPER users created before 10.11 should retain READ_ONLY ADMIN privilege upon upgrade 2022-09-26 20:36:29 +02:00
Nayuta Yanagisawa
2b89598fe0 MDEV-26852 Spider: -Werror=maybe-uninitialized raises on spd_sys_table.cc and ha_spider.cc
The warning "maybe-uninitialized" raises on spd_sys_table.cc and
ha_spider.cc when the sever is compiled with CMAKE_CXX_FLAGS=-Og.
2022-09-26 23:23:13 +09:00
Sergei Golubchik
fa4e84b5d9 cleanup: main.mysqldump test
show error messages from mysqldump/mysqlimport
2022-09-26 15:01:36 +02:00
Sergei Golubchik
88db4e3ea4 wsrep suite isn't run by default, wsrep_info shouldn't either 2022-09-26 15:01:36 +02:00