diff options
author | Sujatha <sujatha.sivakumar@mariadb.com> | 2020-04-09 20:45:45 +0530 |
---|---|---|
committer | Andrei Elkin <andrei.elkin@mariadb.com> | 2020-10-23 18:04:31 +0300 |
commit | bc00529d14aeda845d8129cb924efe4db2c11228 (patch) | |
tree | 3cfd84a4f79d8fa32887713b947493e48b0bbbc0 /sql/handler.h | |
parent | 72cb20820b4f48fda0ae5e0ead4783d76dde3ec0 (diff) | |
download | mariadb-git-bb-10.1-andrei.tar.gz |
MDEV-21117: --tc-heuristic-recover=rollback is not replication safebb-10.1-andrei
Problem:
=======
When run after master server crash --tc-heuristic-recover=rollback produces
inconsistent server state with binlog still containing transactions that were
rolled back by the option. Such way recovered server may not be used for
replication.
Fix:
===
A new --tc-heuristic-recover=BINLOG_TRUNCATE value is added to the
server option. It works as ROLLBACK for engines but makes its best to
synchronize binlog to truncate it to the last committed transaction.
The BINLOG_TRUNCATE algorithm starts scanning possibly a sequences of
binlog files starting from the binlog checkpoint file to find a
truncate position candidate. The candidate truncate position
corresponds to the beginning of the first GTID event whose transaction
is not found to have been committed. There must be no committed
transactions beyond this position *but* non-transactional events are
possible. This is also checked to warn when the case.
Rollback and possibly completion of partial commits (in the multi-engine case)
is done regardless, as well as the binlog GTID state is adjusted
accordingly. Also a STOP binlog event is written at the end of
truncated binary log.
Diffstat (limited to 'sql/handler.h')
-rw-r--r-- | sql/handler.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/handler.h b/sql/handler.h index c6cac5dfbbe..73af3b550fd 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -638,6 +638,13 @@ struct xid_t { }; typedef struct xid_t XID; +/* struct for heuristic binlog truncate recovery */ +struct xid_recovery_member +{ + my_xid xid; + uint in_engine_prepare; // number of engines that have xid prepared +}; + /* for recover() handlerton call */ #define MIN_XID_LIST_SIZE 128 #define MAX_XID_LIST_SIZE (1024*128) @@ -4270,7 +4277,8 @@ int ha_commit_one_phase(THD *thd, bool all); int ha_commit_trans(THD *thd, bool all); int ha_rollback_trans(THD *thd, bool all); int ha_prepare(THD *thd); -int ha_recover(HASH *commit_list); +int ha_recover(HASH *commit_list, MEM_ROOT *mem_root= NULL); +void ha_recover_binlog_truncate_complete(HASH *commit_list); /* transactions: these functions never call handlerton functions directly */ int ha_enable_transaction(THD *thd, bool on); @@ -4326,4 +4334,5 @@ void print_keydup_error(TABLE *table, KEY *key, myf errflag); int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info); int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table); +uint ha_count_rw_all(THD *thd, Ha_trx_info **ptr_ha_info, bool count_through); #endif /* HANDLER_INCLUDED */ |