MDEV-29575 Access to innodb_trx, innodb_locks and innodb_lock_waits along with detached XA's can cause SIGSEGV
trx->mysql_thd can be zeroed-out between thd_get_thread_id() and
thd_query_safe() calls in fill_trx_row(). trx_disconnect_prepared()
zeroes out trx->mysql_thd. And this can cause null pointer dereferencing
in fill_trx_row().
fill_trx_row() is invoked from fetch_data_into_cache(), which, in turns,
iterates transactions with trx_sys.trx_list.for_each() function, which
holds trx_sys.trx_list.mutex during the iteration.
Bug fix is in reseting trx_t::mysql_thd in trx_disconnect_prepared()
under trx_sys.trx_list.mutex lock.
MTR test case can't be created for the fix, as we need to wait for
trx_t::mysql_thd reseting in fill_trx_row() after trx_t::mysql_thd was
checked for null while trx_sys.trx_list.mutex is held. But
trx_t::mysql_thd must be reset in trx_disconnect_prepared() under
trx_sys.trx_list.mutex. There will be deadlock.
after d7d3ad698abd 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.
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.