diff options
author | Sujatha <sujatha.sivakumar@mariadb.com> | 2020-04-09 20:45:45 +0530 |
---|---|---|
committer | Andrei Elkin <andrei.elkin@mariadb.com> | 2021-06-11 19:49:39 +0300 |
commit | 6c39eaeb126328e7813b146ecf652d51e4508981 (patch) | |
tree | 0a5226675f3564235b02a99f29a0b6272af8efe0 /sql/log.h | |
parent | 82c07b178abfa9395f1d67747148a431d6eb6ae7 (diff) | |
download | mariadb-git-6c39eaeb126328e7813b146ecf652d51e4508981.tar.gz |
MDEV-21117: refine the server binlog-based recovery for semisync
Problem:
=======
When the semisync master is crashed and restarted as slave it could
recover transactions that former slaves may never have seen.
A known method existed to clear out all prepared transactions
with --tc-heuristic-recover=rollback does not care to adjust
binlog accordingly.
Fix:
===
The binlog-based recovery is made to concern of the slave semisync role of
post-crash restarted server.
No changes in behavior is done to the "normal" binloggging server
and the semisync master.
When the restarted server is configured with
--rpl-semi-sync-slave-enabled=1
the refined recovery attempts to roll back prepared transactions
and truncate binlog accordingly.
In case of a partially committed (that is committed at least
in one of the engine participants) such transaction gets committed.
It's guaranteed no (partially as well) committed transactions
exist beyond the truncate position.
In case there exists a non-transactional replication event
(being in a way a committed transaction) past the
computed truncate position the recovery ends with an error.
As after master crash and failover to slave, the demoted-to-slave
ex-master must be ready to face and accept its own (generated by)
events, without generally necessary --replicate-same-server-id.
So the acceptance conditions are relaxed for the semisync slave
to accept own events without that option.
While gtid_strict_mode ON ensures no duplicate transaction can be
(re-)executed the master_use_gtid=none slave has to be
configured with --replicate-same-server-id.
*NOTE* for reviewers.
This patch does not handle the user XA which is done
in next git commit.
Diffstat (limited to 'sql/log.h')
-rw-r--r-- | sql/log.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/log.h b/sql/log.h index eaf7cde1c07..d61e4660330 100644 --- a/sql/log.h +++ b/sql/log.h @@ -477,6 +477,7 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG /* Flag used to optimise around wait_for_prior_commit. */ bool queued_by_other; ulong binlog_id; + bool ro_1pc; // passes the binlog_cache_mngr::ro_1pc value to Gtid ctor }; /* @@ -810,7 +811,8 @@ public: my_bool *with_annotate= 0); // binary log write bool write_transaction_to_binlog(THD *thd, binlog_cache_mngr *cache_mngr, Log_event *end_ev, bool all, - bool using_stmt_cache, bool using_trx_cache); + bool using_stmt_cache, bool using_trx_cache, + bool is_ro_1pc); bool write_incident_already_locked(THD *thd); bool write_incident(THD *thd); @@ -860,6 +862,9 @@ public: int purge_first_log(Relay_log_info* rli, bool included); int set_purge_index_file_name(const char *base_file_name); int open_purge_index_file(bool destroy); + bool truncate_and_remove_binlogs(const char *truncate_file, + my_off_t truncate_pos, + rpl_gtid *gtid); bool is_inited_purge_index_file(); int close_purge_index_file(); int clean_purge_index_file(); @@ -896,7 +901,8 @@ public: void set_status_variables(THD *thd); bool is_xidlist_idle(); bool write_gtid_event(THD *thd, bool standalone, bool is_transactional, - uint64 commit_id); + uint64 commit_id, + bool has_xid= false, bool ro_1pc= false); int read_state_from_file(); int write_state_to_file(); int get_most_recent_gtid_list(rpl_gtid **list, uint32 *size); @@ -1237,4 +1243,8 @@ class Gtid_list_log_event; const char * get_gtid_list_event(IO_CACHE *cache, Gtid_list_log_event **out_gtid_list); +int binlog_commit(THD *thd, bool all, bool is_ro_1pc); +int binlog_commit_by_xid(handlerton *hton, XID *xid); +int binlog_rollback_by_xid(handlerton *hton, XID *xid); + #endif /* LOG_H */ |