summaryrefslogtreecommitdiff
path: root/sql/log_event.h
diff options
context:
space:
mode:
authorSujatha <sujatha.sivakumar@mariadb.com>2020-04-09 20:45:45 +0530
committerAndrei Elkin <andrei.elkin@mariadb.com>2021-06-11 19:49:39 +0300
commit6c39eaeb126328e7813b146ecf652d51e4508981 (patch)
tree0a5226675f3564235b02a99f29a0b6272af8efe0 /sql/log_event.h
parent82c07b178abfa9395f1d67747148a431d6eb6ae7 (diff)
downloadmariadb-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_event.h')
-rw-r--r--sql/log_event.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/sql/log_event.h b/sql/log_event.h
index 990d95e1dc0..3adc7a26d93 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -490,6 +490,16 @@ class String;
#define LOG_EVENT_IGNORABLE_F 0x80
/**
+ @def LOG_EVENT_ACCEPT_OWN_F
+
+ Flag sets by the semisync slave for accepting
+ the same server_id ("own") events which the slave must not have
+ in its state. Typically such events were never committed by
+ their originator (this server) and discared at its semisync-slave recovery.
+*/
+#define LOG_EVENT_ACCEPT_OWN_F 0x4000
+
+/**
@def LOG_EVENT_SKIP_REPLICATION_F
Flag set by application creating the event (with @@skip_replication); the
@@ -3602,6 +3612,13 @@ public:
event_mysql_xid_t xid;
#endif
uchar flags2;
+ uint flags_extra; // more flags area placed after the regular flags2's one
+ /*
+ Number of engine participants in transaction minus 1.
+ When zero the event does not contain that information.
+ */
+ uint8 extra_engines;
+
/* Flags2. */
/* FL_STANDALONE is set when there is no terminating COMMIT event. */
@@ -3633,9 +3650,19 @@ public:
/* FL_"COMMITTED or ROLLED-BACK"_XA is set for XA transaction. */
static const uchar FL_COMPLETED_XA= 128;
+ /* Flags_extra. */
+
+ /*
+ FL_EXTRA_MULTI_ENGINE is set for event group comprising a transaction
+ involving multiple storage engines. No flag and extra data are added
+ to the event when the transaction involves only one engine.
+ */
+ static const uchar FL_EXTRA_MULTI_ENGINE= 1;
+
#ifdef MYSQL_SERVER
Gtid_log_event(THD *thd_arg, uint64 seq_no, uint32 domain_id, bool standalone,
- uint16 flags, bool is_transactional, uint64 commit_id);
+ uint16 flags, bool is_transactional, uint64 commit_id,
+ bool has_xid= false, bool is_ro_1pc= false);
#ifdef HAVE_REPLICATION
void pack_info(Protocol *protocol);
virtual int do_apply_event(rpl_group_info *rgi);