mariadb/include
Marko Mäkelä ddd7d5d8e3 MDEV-24035 Failing assertion: UT_LIST_GET_LEN(lock.trx_locks) == 0 causing disruption and replication failure
Under unknown circumstances, the SQL layer may wrongly disregard an
invocation of thd_mark_transaction_to_rollback() when an InnoDB
transaction had been aborted (rolled back) due to one of the following errors:
* HA_ERR_LOCK_DEADLOCK
* HA_ERR_RECORD_CHANGED (if innodb_snapshot_isolation=ON)
* HA_ERR_LOCK_WAIT_TIMEOUT (if innodb_rollback_on_timeout=ON)

Such an error used to cause a crash of InnoDB during transaction commit.
These changes aim to catch and report the error earlier, so that not only
this crash can be avoided but also the original root cause be found and
fixed more easily later.

The idea of this fix is from Michael 'Monty' Widenius.

HA_ERR_ROLLBACK: A new error code that will be translated into
ER_ROLLBACK_ONLY, signalling that the current transaction
has been aborted and the only allowed action is ROLLBACK.

trx_t::state: Add TRX_STATE_ABORTED that is like
TRX_STATE_NOT_STARTED, but noting that the transaction had been
rolled back and aborted.

trx_t::is_started(): Replaces trx_is_started().

ha_innobase: Check the transaction state in various places.
Simplify the logic around SAVEPOINT.

ha_innobase::is_valid_trx(): Replaces ha_innobase::is_read_only().

The InnoDB logic around transaction savepoints, commit, and rollback
was unnecessarily complex and might have contributed to this
inconsistency. So, we are simplifying that logic as well.

trx_savept_t: Replace with const undo_no_t*. When we rollback to
a savepoint, all we need to know is the number of undo log records
that must survive.

trx_named_savept_t, DB_NO_SAVEPOINT: Remove. We can store undo_no_t
directly in the space allocated at innobase_hton->savepoint_offset.

fts_trx_create(): Do not copy previous savepoints.

fts_savepoint_rollback(): If a savepoint was not found, roll back
everything after the default savepoint of fts_trx_create().
The test innodb_fts.savepoint is extended to cover this code.

Reviewed by: Vladislav Lesin
Tested by: Matthias Leich
2024-12-12 18:02:00 +02:00
..
atomic
mysql
aligned.h
aria_backup.h
assume_aligned.h
big_endian.h
byte_order_generic.h
byte_order_generic_x86.h
byte_order_generic_x86_64.h
CMakeLists.txt
decimal.h
dur_prop.h
errmsg.h
ft_global.h
handler_ername.h
handler_state.h
hash.h
heap.h
ilist.h
json_lib.h
keycache.h
lf.h
little_endian.h
m_ctype.h
m_string.h
ma_dyncol.h
maria.h
mariadb_capi_rename.h
my_alarm.h
my_alloc.h
my_alloca.h
my_atomic.h
my_atomic_wrapper.h
my_attribute.h
my_base.h
my_bit.h
my_bitmap.h
my_byteorder.h
my_check_opt.h
my_cmp.h
my_compare.h
my_compiler.h
my_counter.h
my_cpu.h
my_crypt.h
my_dbug.h
my_decimal_limits.h
my_default.h
my_dir.h
my_getopt.h
my_global.h
my_handler_errors.h
my_libwrap.h
my_list.h
my_md5.h
my_minidump.h
my_net.h
my_nosys.h
my_pthread.h
my_rdtsc.h
my_rnd.h
my_service_manager.h
my_stack_alloc.h
my_stacktrace.h
my_sys.h
my_time.h
my_tree.h
my_uctype.h
my_user.h
my_valgrind.h
my_xml.h
myisam.h
myisamchk.h
myisammrg.h
myisampack.h
mysql.h
mysql_com.h
mysql_com_server.h
mysql_embed.h
mysql_time.h
mysql_version.h.in
mysqld_default_groups.h
mysys_err.h
no_valgrind_without_big.inc
pack.h
password.h
pfs_file_provider.h
pfs_idle_provider.h
pfs_memory_provider.h
pfs_metadata_provider.h
pfs_socket_provider.h
pfs_stage_provider.h
pfs_statement_provider.h
pfs_table_provider.h
pfs_thread_provider.h
pfs_transaction_provider.h
probes_mysql.d.base
probes_mysql.h
probes_mysql_nodtrace.h.in
queues.h
rijndael.h
scope.h
service_versions.h
source_revision.h.in
span.h
sql_common.h
ssl_compat.h
sslopt-case.h
sslopt-longopts.h
sslopt-vars.h
t_ctype.h
thr_alarm.h
thr_lock.h
thr_timer.h
typelib.h
violite.h
waiting_threads.h
welcome_copyright_notice.h
wqueue.h
wsrep.h