A number of tests often trip warnings on Valgrind, because Valgrind
runs all threads in a single thread and may cause starvation:
InnoDB: A long wait (... seconds) was observed for dict_sys.latch
Let us disable those tests on Valgrind in order to avoid bogus failures.
Starting with commit 8f8ba75855
the assertion would fail in
./mtr --mysqld=--innodb-adaptive-hash-index innodb.instant_alter_crash
and it would keep failing even after
commit d2e649aec2
This is a backport of commit 8b6a308e46
from MariaDB Server 10.6.11. No attempt to reproduce the hang
in earlier an earlier version of MariaDB Server than 10.6 was made.
In each caller of fseg_n_reserved_pages() except ibuf_init_at_db_start()
which is a special case for ibuf.index at database startup, we must hold
an index latch that prevents concurrent allocation or freeing of index
pages.
Any operation that allocates or free pages that belong to an index tree
must first acquire an index latch in non-shared mode, and while
holding that, acquire an index root page latch in non-shared mode.
btr_get_size(), btr_get_size_and_reserved(): Assert that a strong enough
index latch is being held.
dict_stats_update_transient_for_index(),
dict_stats_analyze_index(): Acquire a strong enough index latch.
These operations had followed the same order of acquiring latches in
every InnoDB version since the very beginning
(commit c533308a15).
The hang was introduced in
commit 2e814d4702 which imported
mysql/mysql-server@ac74632293
which failed to strengthen the locking requirements of the function
btr_get_size().
* MDEV-29397 Fix note turning into error
ODBC Rewind triggered an error with no SQL, but this is sometimes a
valid condition (as can be seen with other classes). Setting this to a 0
return stops errors firing when they shouldn't.
Also fixes ASAN hits from in MDEV-29687 tabext.cpp.
ha_innobase::referenced_by_foreign_key(): Protect the check with
dict_sys.freeze(), to prevent races with TRUNCATE TABLE.
The test innodb.instant_alter_crash has been adjusted for this
additional locking.
dict_table_is_referenced_by_foreign_key(): Removed (merged to
the only caller).
create_table_info_t::create_table(): Ignore missing indexes for
FOREIGN KEY constraints if foreign_key_checks=0.
create_table_info_t::create_table_update_dict(): Rewritten as
a static function. Do not return any error.
ha_innobase::create(): When trx!=nullptr and we are operating
on a persistent table, do not rollback, commit, or release the
data dictionary latch.
ha_innobase::truncate(): Protect the entire critical section
with an exclusive dict_sys.latch, so that
ha_innobase::referenced_by_foreign_key() on referenced tables
will return a consistent result. In case of a failure,
invoke dict_load_foreigns() to restore also any FOREIGN KEY
constraints.
ha_innobase::free_foreign_key_create_info(): Define inline.
lock_release(): Disregard innodb_evict_tables_on_commit_debug=ON
when dict_sys.locked() holds. It would hold when fts_load_stopword()
is invoked by create_table_info_t::create_table_update_dict().
dict_sys_t::locked(): Return whether the current thread is holding
the exclusive dict_sys.latch.
dict_sys_t::frozen_not_locked(): Return whether any thread is
holding a shared dict_sys.latch.
In the test main.mysql_upgrade, the InnoDB persistent statistics
will no longer be recalculated in ha_innobase::open() as part of
CHECK TABLE ... FOR UPGRADE. They were deleted earlier in the test.
Tested by: Matthias Leich
spatial_index_info: Replaces index_tuple_info_t. Always take
a memory heap as a parameter to the member functions.
Remove pointer indirection for m_dtuple_vec.
spatial_index_info::add(): Duplicate any PRIMARY KEY fields that would
point to within ext->buf because that buffer will be allocated in
a shorter-lifetime memory heap.
- During alter operation of compressed table, page split operation
chooses the first record of the page as split record and it leads
to empty left page. This issue caused by the commit 77b3959b5c (MDEV-28457).
page_rec_is_second(), page_rec_is_second_last(): Removed the functions
since it is a deadcode.
- Failing debug assertion is to indicate whether the purge thread
is waiting when fts auxilary table is being dropped. But assertion
fails if the table name contains FTS_. So in fts_drop_table(), InnoDB
sets the auxilary table flag in transaction modified table list.
- InnoDB information schema query access the tablespace name after
getting freed by concurrent rename operation. To avoid this, InnoDB
should take exclusive tablespace latch during rename operation
and I_S query should take shared tablespace latch before accessing
the name
Every operation that is going to write redo log is supposed to
invoke log_free_check() before acquiring any latches. If there
is a risk of log buffer overrun, a log checkpoint would be
triggered by that call.
ibuf_merge_space(), ibuf_merge_in_background(),
ibuf_delete_for_discarded_space(): Invoke log_free_check()
when the current thread is not holding any page latches.
Unfortunately, in lower-level code called from ibuf_insert()
or ibuf_merge_or_delete_for_page(), some page latches may be
held and a call to log_free_check() could hang.
ibuf_set_bitmap_for_bulk_load(): Use the caller's mini-transaction.
The caller should have invoked log_free_check() while not holding
any page latches.
Something appears to be broken in the DBUG subsystem.
Let us remove frequent calls to it from the InnoDB internal SQL interpreter
that is used in the purge of transaction history.
The DBUG_PRINT in que_eval_sql() can remain for now, because those
operations are much less frequent.
InnoDB crash recovery can run out of memory before
commit 50324ce624 in
MariaDB Server 10.5.
Let us disable some frequently failing recovery tests
in earlier versions.
When allocation failed, fail consistently with error message and abort()
by using flags MY_WME|MY_FAE with my_malloc() and friends.
This ensures that better diagnostic information is available
when mysqltest fails.
Not creating explicit record locks will speed up the test.
Also, disable the use of InnoDB persistent statistics in the test of
MDEV-27270 to avoid intermittent failures in 10.6 or later
(after commit 9608773f75)
due to the nondeterministic scheduling of STATS_AUTO_PERSISTENT.
Problem:-
We are able to insert duplicate value in table because cmp_binary_offset
is not able to differentiate between NULL and empty string. So
check_duplicate_long_entry_key is never called and we don't check for
duplicate.
Solution
Added a if condition with is_null() on field which can differentiate
between NULL and empty string.
When trying to output stacktrace, and addr2line is not installed, the
child process forked by start_addr2line_fork() will fail to do exec(),
and finish with exit(1).
There is a problem with exit() though - it runs exit handlers,
and for the forked copy of crashing process, it is a bad idea.
In 10.5+ code for example, exit handlers include
tpool::task_group static destructors, and it will hang infinitely
waiting for completion of the outstanding tasks.
The fix is to use _exit() instead, which skips the execution of exit
handlers