MySQL  8.0.20
Source Code Documentation
applier.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef APPLIER_INCLUDE
24 #define APPLIER_INCLUDE
25 
28 #include <list>
29 #include <vector>
30 
31 #include "my_inttypes.h"
43 #include "sql/sql_class.h"
44 
45 // Define the applier packet types
46 #define ACTION_PACKET_TYPE 2
47 #define VIEW_CHANGE_PACKET_TYPE 3
48 #define SINGLE_PRIMARY_PACKET_TYPE 4
49 #define SYNC_BEFORE_EXECUTION_PACKET_TYPE 5
50 #define TRANSACTION_PREPARED_PACKET_TYPE 6
51 #define LEAVING_MEMBERS_PACKET_TYPE 7
52 
53 // Define the applier return error codes
54 #define APPLIER_GTID_CHECK_TIMEOUT_ERROR -1
55 #define APPLIER_RELAY_LOG_NOT_INITED -2
56 #define APPLIER_THREAD_ABORTED -3
57 
58 extern char applier_module_channel_name[];
59 
60 /* Types of action packets used in the context of the applier module */
62  TERMINATION_PACKET = 0, // Packet for a termination action
63  SUSPENSION_PACKET, // Packet to signal something to suspend
64  CHECKPOINT_PACKET, // Packet to wait for queue consumption
65  ACTION_NUMBER = 3 // The number of actions
66 };
67 
68 /**
69  @class Action_packet
70  A packet to control the applier in a event oriented way.
71 */
72 class Action_packet : public Packet {
73  public:
74  /**
75  Create a new action packet.
76  @param action the packet action
77  */
80 
82 
84 };
85 
86 /**
87  @class View_change_packet
88  A packet to send view change related info to the applier
89 */
90 class View_change_packet : public Packet {
91  public:
92  /**
93  Create a new data packet with associated data.
94 
95  @param view_id_arg The view id associated to this view
96  */
97  View_change_packet(std::string &view_id_arg)
98  : Packet(VIEW_CHANGE_PACKET_TYPE), view_id(view_id_arg) {}
99 
101 
102  std::string view_id;
103  std::vector<std::string> group_executed_set;
104 };
105 
106 /**
107  @class Single_primary_action_packet
108  A packet to send new primary election related info to the applier
109 */
111  public:
112  enum enum_action { NEW_PRIMARY = 0, QUEUE_APPLIED = 1 };
113 
114  /**
115  Create a new single primary action packet with associated data.
116 
117  @param action_arg the packet action
118  */
120  : Packet(SINGLE_PRIMARY_PACKET_TYPE), action(action_arg) {}
121 
123 
124  enum enum_action action;
125 };
126 
127 /**
128  @class Queue_checkpoint_packet
129  A packet to wait for queue consumption
130 */
132  public:
133  /**
134  Create a new Queue_checkpoint_packet packet.
135  */
137  std::shared_ptr<Continuation> checkpoint_condition_arg)
139  checkpoint_condition(checkpoint_condition_arg) {}
140 
141  void signal_checkpoint_reached() { checkpoint_condition->signal(); }
142 
143  private:
144  /**If we discard a packet */
145  std::shared_ptr<Continuation> checkpoint_condition;
146 };
147 
148 /**
149  @class Transaction_prepared_action_packet
150  A packet to inform that a given member did prepare a given transaction.
151 */
153  public:
154  /**
155  Create a new transaction prepared action.
156 
157  @param sid the prepared transaction sid
158  @param gno the prepared transaction gno
159  @param gcs_member_id the member id that did prepare the
160  transaction
161  */
163  const Gcs_member_identifier &gcs_member_id)
165  m_sid_specified(sid != nullptr ? true : false),
166  m_gno(gno),
167  m_gcs_member_id(gcs_member_id.get_member_id()) {
168  if (sid != nullptr) {
169  m_sid.copy_from(*sid);
170  }
171  }
172 
174 
175  const bool m_sid_specified;
176  const rpl_gno m_gno;
178 
179  const rpl_sid *get_sid() { return m_sid_specified ? &m_sid : nullptr; }
180 
181  private:
183 };
184 
185 /**
186  @class Sync_before_execution_action_packet
187  A packet to request a synchronization point on the global message
188  order on a given member before transaction execution.
189 */
191  public:
192  /**
193  Create a new synchronization point request.
194 
195  @param thread_id the thread that did the request
196  @param gcs_member_id the member id that did the request
197  */
199  my_thread_id thread_id, const Gcs_member_identifier &gcs_member_id)
201  m_thread_id(thread_id),
202  m_gcs_member_id(gcs_member_id.get_member_id()) {}
203 
205 
208 };
209 
210 /**
211  @class Leaving_members_action_packet
212  A packet to inform pipeline listeners of leaving members,
213  this packet will be handled on the global message order,
214  that is, ordered with certification.
215 */
217  public:
218  /**
219  Create a new leaving members packet.
220 
221  @param leaving_members the members that left the group
222  */
224  const std::vector<Gcs_member_identifier> &leaving_members)
226  m_leaving_members(leaving_members) {}
227 
229 
230  const std::vector<Gcs_member_identifier> m_leaving_members;
231 };
232 
233 typedef enum enum_applier_state {
238 
240  public:
242  virtual Certification_handler *get_certification_handler() = 0;
243  virtual int wait_for_applier_complete_suspension(
244  bool *abort_flag, bool wait_for_execution = true) = 0;
245  virtual void awake_applier_module() = 0;
246  virtual void interrupt_applier_suspension_wait() = 0;
247  virtual int wait_for_applier_event_execution(
248  double timeout, bool check_and_purge_partial_transactions) = 0;
249  virtual bool wait_for_current_events_execution(
250  std::shared_ptr<Continuation> checkpoint_condition, bool *abort_flag,
251  bool update_THD_status = true) = 0;
252  virtual bool get_retrieved_gtid_set(std::string &retrieved_set) = 0;
253  virtual int wait_for_applier_event_execution(
254  std::string &retrieved_set, double timeout,
255  bool update_THD_status = true) = 0;
256  virtual size_t get_message_queue_size() = 0;
257  virtual Member_applier_state get_applier_status() = 0;
258  virtual void add_suspension_packet() = 0;
259  virtual void add_view_change_packet(View_change_packet *packet) = 0;
260  virtual void add_single_primary_action_packet(
261  Single_primary_action_packet *packet) = 0;
262  virtual void add_transaction_prepared_action_packet(
264  virtual void add_sync_before_execution_action_packet(
266  virtual void add_leaving_members_action_packet(
267  Leaving_members_action_packet *packet) = 0;
268  virtual int handle(const uchar *data, ulong len,
270  std::list<Gcs_member_identifier> *online_members) = 0;
271  virtual int handle_pipeline_action(Pipeline_action *action) = 0;
272  virtual Flow_control_module *get_flow_control_module() = 0;
273  virtual void run_flow_control_step() = 0;
274  virtual int purge_applier_queue_and_restart_applier_module() = 0;
275  virtual bool queue_and_wait_on_queue_checkpoint(
276  std::shared_ptr<Continuation> checkpoint_condition) = 0;
278  get_pipeline_stats_member_collector() = 0;
279 };
280 
282  public:
283  Applier_module();
284  ~Applier_module();
285 
286  /**
287  Initializes and launches the applier thread
288 
289  @return the operation status
290  @retval 0 OK
291  @retval !=0 Error
292  */
293  int initialize_applier_thread();
294 
295  /**
296  * Return the local applier stats.
297  */
298  Pipeline_member_stats *get_local_pipeline_stats();
299 
300  /**
301  Terminates the applier thread.
302 
303  @return the operation status
304  @retval 0 OK
305  @retval !=0 A timeout occurred
306  */
307  int terminate_applier_thread();
308 
309  /**
310  Is the applier marked for shutdown?
311 
312  @return is the applier on shutdown
313  @retval 0 no
314  @retval !=0 yes
315  */
317  return (applier_aborted || applier_thd->killed);
318  }
319 
320  /**
321  Is the applier running?
322 
323  @return applier running?
324  @retval 0 no
325  @retval !=0 yes
326  */
327  bool is_running() { return (applier_thd_state.is_running()); }
328 
329  /**
330  Configure the applier pipeline according to the given configuration
331 
332  @param[in] pipeline_type the chosen pipeline
333  @param[in] reset_logs if a reset happened in the server
334  @param[in] stop_timeout the timeout when waiting on shutdown
335  @param[in] group_sidno the group configured sidno
336  @param[in] gtid_assignment_block_size the group gtid assignment block size
337  @param[in] shared_stop_lock the lock used to block transactions
338 
339  @return the operation status
340  @retval 0 OK
341  @retval !=0 Error
342  */
343  int setup_applier_module(Handler_pipeline_type pipeline_type, bool reset_logs,
344  ulong stop_timeout, rpl_sidno group_sidno,
345  ulonglong gtid_assignment_block_size,
346  Shared_writelock *shared_stop_lock);
347 
348  /**
349  Configure the applier pipeline handlers
350 
351  @return the operation status
352  @retval 0 OK
353  @retval !=0 Error
354  */
355  int setup_pipeline_handlers();
356 
357  /**
358  Purges the relay logs and restarts the applier thread.
359 
360  @return the operation status
361  @retval 0 OK
362  @retval !=0 Error
363  */
364  virtual int purge_applier_queue_and_restart_applier_module();
365 
366  /**
367  Runs the applier thread process, reading events and processing them.
368 
369  @note When killed, the thread will finish handling the current packet, and
370  then die, ignoring all possible existing events in the incoming queue.
371 
372  @return the operation status
373  @retval 0 OK
374  @retval !=0 Error
375  */
376  int applier_thread_handle();
377 
378  /**
379  Queues the packet coming from the reader for future application.
380 
381  @param[in] data the packet data
382  @param[in] len the packet length
383  @param[in] consistency_level the transaction consistency level
384  @param[in] online_members the ONLINE members when the transaction
385  message was delivered
386 
387  @return the operation status
388  @retval 0 OK
389  @retval !=0 Error on queue
390  */
391  int handle(const uchar *data, ulong len,
393  std::list<Gcs_member_identifier> *online_members) {
394  this->incoming->push(
395  new Data_packet(data, len, consistency_level, online_members));
396  return 0;
397  }
398 
399  /**
400  Gives the pipeline an action for execution.
401 
402  @param[in] action the action to be executed
403 
404  @return the operation status
405  @retval 0 OK
406  @retval !=0 Error executing the action
407  */
409  return this->pipeline->handle_action(action);
410  }
411 
412  /**
413  Injects an event into the pipeline and waits for its handling.
414 
415  @param[in] pevent the event to be injected
416  @param[in] cont the object used to wait
417 
418  @return the operation status
419  @retval 0 OK
420  @retval !=0 Error on queue
421  */
422  int inject_event_into_pipeline(Pipeline_event *pevent, Continuation *cont);
423 
424  /**
425  Terminates the pipeline, shutting down the handlers and deleting them.
426 
427  @note the pipeline will always be deleted even if an error occurs.
428 
429  @return the operation status
430  @retval 0 OK
431  @retval !=0 Error on pipeline termination
432  */
433  int terminate_applier_pipeline();
434 
435  /**
436  Sets the applier shutdown timeout.
437 
438  @param[in] timeout the timeout
439  */
440  void set_stop_wait_timeout(ulong timeout) {
441  stop_wait_timeout = timeout;
442 
443  // Configure any thread based applier
446  pipeline->handle_action(conf_action);
447 
448  delete conf_action;
449  }
450 
451  /**
452  This method informs the applier module that an applying thread stopped
453  */
454  void inform_of_applier_stop(char *channel_name, bool aborted);
455 
456  // Packet based interface methods
457 
458  /**
459  Queues a packet that will eventually make the applier module suspend.
460  This will happen only after all the previous packets are processed.
461 
462  @note This will happen only after all the previous packets are processed.
463  */
464  virtual void add_suspension_packet() {
465  this->incoming->push(new Action_packet(SUSPENSION_PACKET));
466  }
467 
468  /**
469  Queues a packet that will make the applier module terminate it's handling
470  process. Due to the blocking nature of the queue, this method is useful to
471  unblock the handling process on shutdown.
472 
473  @note This will happen only after all the previous packets are processed.
474  */
476  this->incoming->push(new Action_packet(TERMINATION_PACKET));
477  }
478 
479  /**
480  Queues a view change packet into the applier.
481  This packets contain the new view id and they mark the exact frontier
482  between transactions from the old and new views.
483 
484  @note This will happen only after all the previous packets are processed.
485 
486  @param[in] packet The view change packet to be queued
487  */
489  incoming->push(packet);
490  }
491 
492  /**
493  Queues a single primary action packet into the applier.
494 
495  @note This will happen only after all the previous packets are processed.
496 
497  @param[in] packet The packet to be queued
498  */
500  incoming->push(packet);
501  }
502 
503  /**
504  Queues a transaction prepared action packet into the applier.
505 
506  @note This will happen only after all the previous packets are processed.
507 
508  @param[in] packet The packet to be queued
509  */
512  incoming->push(packet);
513  }
514 
515  /**
516  Queues a synchronization before execution action packet into the applier.
517 
518  @note This will happen only after all the previous packets are processed.
519 
520  @param[in] packet The packet to be queued
521  */
524  incoming->push(packet);
525  }
526 
527  /**
528  Queues a leaving members action packet into the applier.
529 
530  @note This will happen only after all the previous packets are processed.
531 
532  @param[in] packet The packet to be queued
533  */
536  incoming->push(packet);
537  }
538 
539  /**
540  Queues a single a packet that will enable certification on this member
541  */
542  virtual void queue_certification_enabling_packet();
543 
544  /**
545  Awakes the applier module
546  */
547  virtual void awake_applier_module() {
548  mysql_mutex_lock(&suspend_lock);
549  suspended = false;
550  mysql_mutex_unlock(&suspend_lock);
551  mysql_cond_broadcast(&suspend_cond);
552  }
553 
554  /**
555  Waits for the applier to suspend and apply all the transactions previous to
556  the suspend request.
557 
558  @param abort_flag a pointer to a flag that the caller can use to
559  cancel the request.
560  @param wait_for_execution specify if the suspension waits for transactions
561  execution
562 
563  @return the operation status
564  @retval 0 OK
565  @retval !=0 Error when accessing the applier module status
566  */
567  virtual int wait_for_applier_complete_suspension(
568  bool *abort_flag, bool wait_for_execution = true);
569 
570  /**
571  Interrupts the current applier waiting process either for it's suspension
572  or it's wait for the consumption of pre suspension events
573  */
574  virtual void interrupt_applier_suspension_wait();
575 
576  /**
577  Checks if the applier, and its workers when parallel applier is
578  enabled, has already consumed all relay log, that is, applier is
579  waiting for transactions to be queued.
580 
581  @return the applier status
582  @retval true the applier is waiting
583  @retval false otherwise
584  */
585  bool is_applier_thread_waiting();
586 
587  /**
588  Waits for the execution of all events by part of the current SQL applier.
589  Due to the possible asynchronous nature of module's applier handler, this
590  method inquires the current handler to check if all transactions queued up
591  to this point are already executed.
592 
593  If no handler exists, then it is assumed that transactions were processed.
594 
595  @param timeout the time (seconds) after which the method returns if the
596  above condition was not satisfied
597  @param check_and_purge_partial_transactions
598  on successful executions, check and purge partial
599  transactions in the relay log
600 
601  @return the operation status
602  @retval 0 All transactions were executed
603  @retval -1 A timeout occurred
604  @retval -2 An error occurred
605  */
606  virtual int wait_for_applier_event_execution(
607  double timeout, bool check_and_purge_partial_transactions);
608 
609  /**
610  Waits for the execution of all current events by part of the current SQL
611  applier.
612 
613  The current gtid retrieved set is extracted and a loop is executed until
614  these transactions are executed.
615 
616  If the applier SQL thread stops, the method will return an error.
617 
618  If no handler exists, then it is assumed that transactions were processed.
619 
620  @param checkpoint_condition the class used to wait for the queue to be
621  consumed. Can be used to cancel the wait.
622  @param abort_flag a pointer to a flag that the caller can use to
623  cancel the request.
624  @param update_THD_status Shall the method update the THD stage
625 
626 
627  @return the operation status
628  @retval false All transactions were executed
629  @retval true An error occurred
630  */
631  virtual bool wait_for_current_events_execution(
632  std::shared_ptr<Continuation> checkpoint_condition, bool *abort_flag,
633  bool update_THD_status = true);
634 
635  /**
636  Returns the retrieved gtid set for the applier channel
637 
638  @param[out] retrieved_set the set in string format.
639 
640  @retval true there was an error.
641  @retval false the operation has succeeded.
642  */
643  virtual bool get_retrieved_gtid_set(std::string &retrieved_set);
644 
645  /**
646  Waits for the execution of all events in the given set by the current SQL
647  applier. If no handler exists, then it is assumed that transactions were
648  processed.
649 
650  @param retrieved_set the set in string format of transaction to wait for
651  @param timeout the time (seconds) after which the method returns if the
652  above condition was not satisfied
653  @param update_THD_status Shall the method update the THD stage
654 
655  @return the operation status
656  @retval 0 All transactions were executed
657  @retval -1 A timeout occurred
658  @retval -2 An error occurred
659  */
660  virtual int wait_for_applier_event_execution(std::string &retrieved_set,
661  double timeout,
662  bool update_THD_status = true);
663 
664  /**
665  Returns the handler instance in the applier module responsible for
666  certification.
667 
668  @note If new certification handlers appear, an interface must be created.
669 
670  @return a pointer to the applier's certification handler.
671  @retval !=NULL The certification handler
672  @retval NULL No certification handler present
673  */
674  virtual Certification_handler *get_certification_handler();
675 
676  /**
677  Returns the applier module's queue size.
678 
679  @return the size of the queue
680  */
681  virtual size_t get_message_queue_size() { return incoming->size(); }
682 
684  if (applier_thd_state.is_running())
685  return APPLIER_STATE_ON;
686  else if (suspended) /* purecov: inspected */
687  return APPLIER_STATE_OFF; /* purecov: inspected */
688  else
689  return APPLIER_ERROR; /* purecov: inspected */
690  }
691 
693  return &pipeline_stats_member_collector;
694  }
695 
697  return &flow_control_module;
698  }
699 
700  virtual void run_flow_control_step() {
701  flow_control_module.flow_control_step(&pipeline_stats_member_collector);
702  }
703 
704  virtual bool queue_and_wait_on_queue_checkpoint(
705  std::shared_ptr<Continuation> checkpoint_condition);
706 
707  private:
708  // Applier packet handlers
709 
710  /**
711  Apply an action packet received by the applier.
712  It can be a order to suspend or terminate.
713 
714  @param action_packet the received action packet
715 
716  @return if the applier should terminate (with no associated error).
717  */
718  bool apply_action_packet(Action_packet *action_packet);
719 
720  /**
721  Apply a View Change packet received by the applier.
722  It executes some certification operations and queues a View Change Event
723 
724  @param view_change_packet the received view change packet
725  @param fde_evt the Format description event associated to the event
726  @param cont the applier Continuation Object
727 
728  @return the operation status
729  @retval 0 OK
730  @retval !=0 Error when injecting event
731  */
732  int apply_view_change_packet(View_change_packet *view_change_packet,
734  Continuation *cont);
735 
736  /**
737  Apply a Data packet received by the applier.
738  It executes some certification operations and queues a View Change Event
739 
740  @param data_packet the received data packet packet
741  @param fde_evt the Format description event associated to the event
742  @param cont the applier Continuation Object
743 
744  @return the operation status
745  @retval 0 OK
746  @retval !=0 Error when injecting event
747  */
748  int apply_data_packet(Data_packet *data_packet,
750  Continuation *cont);
751 
752  /**
753  Apply an single primary action packet received by the applier.
754 
755  @param packet the received action packet
756 
757  @return the operation status
758  @retval 0 OK
759  @retval !=0 Error when applying packet
760  */
761  int apply_single_primary_action_packet(Single_primary_action_packet *packet);
762 
763  /**
764  Apply a transaction prepared action packet received by the applier.
765 
766  @param packet the received action packet
767 
768  @return the operation status
769  @retval 0 OK
770  @retval !=0 Error when applying packet
771  */
772  int apply_transaction_prepared_action_packet(
774 
775  /**
776  Apply a synchronization before execution action packet received
777  by the applier.
778 
779  @param packet the received action packet
780 
781  @return the operation status
782  @retval 0 OK
783  @retval !=0 Error when applying packet
784  */
785  int apply_sync_before_execution_action_packet(
787 
788  /**
789  Apply a leaving members action packet received by the applier.
790 
791  @param packet the received action packet
792 
793  @return the operation status
794  @retval 0 OK
795  @retval !=0 Error when applying packet
796  */
797  int apply_leaving_members_action_packet(
799 
800  /**
801  Suspends the applier module, being transactions still queued in the incoming
802  queue.
803 
804  @note if the proper condition is set, possible listeners can be awaken by
805  this method.
806  */
808  mysql_mutex_lock(&suspend_lock);
809 
810  suspended = true;
811  stage_handler.set_stage(info_GR_STAGE_module_suspending.m_key, __FILE__,
812  __LINE__, 0, 0);
813 
814  // Alert any interested party about the applier suspension
815  mysql_cond_broadcast(&suspension_waiting_condition);
816 
817  while (suspended) {
818  mysql_cond_wait(&suspend_cond, &suspend_lock);
819  }
820  stage_handler.set_stage(info_GR_STAGE_module_executing.m_key, __FILE__,
821  __LINE__, 0, 0);
822 
823  mysql_mutex_unlock(&suspend_lock);
824  }
825 
826  /**
827  Cleans the thread context for the applier thread
828  This includes such tasks as removing the thread from the global thread list
829  */
830  void clean_applier_thread_context();
831 
832  /**
833  Set the thread context for the applier thread.
834  This allows the thread to behave like an slave thread and perform
835  such tasks as queuing to a relay log.
836  */
837  void set_applier_thread_context();
838 
839  /**
840  This method calculates the intersection of the given sets passed as a list
841  of strings.
842 
843  @param[in] gtid_sets the vector containing the GTID sets to intersect
844  @param[out] output_set the final GTID calculated from the intersection
845 
846  @return the operation status
847  @retval 0 all went fine
848  @retval !=0 error
849  */
850  int intersect_group_executed_sets(std::vector<std::string> &gtid_sets,
851  Gtid_set *output_set);
852 
853  // applier thread variables
856 
857  // configuration options
861 
862  // run conditions and locks
865  /* Applier thread state */
867  /* Applier abort flag */
869  /* Applier error during execution */
871  /* Applier killed status */
873 
874  // condition and lock used to suspend/awake the applier module
875  /* The lock for suspending/wait for the awake of the applier module */
877  /* The condition for suspending/wait for the awake of the applier module */
879  /* Suspend flag that informs if the applier is suspended */
880  bool suspended;
881  /* Suspend wait flag used when waiting for the applier to suspend */
883 
884  /* The condition for signaling the applier suspension*/
886 
887  /* The stop lock used when killing transaction/stopping server*/
889 
890  /* The incoming event queue */
892 
893  /* The applier pipeline for event execution */
895 
896  /* Applier timeout on shutdown */
898 
899  /* Applier channel observer to detect failures */
901 
905 };
906 
907 #endif /* APPLIER_INCLUDE */
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Flow_control_module * get_flow_control_module()
Definition: applier.h:696
int rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:95
unsigned char uchar
Definition: my_inttypes.h:51
const rpl_sid * get_sid()
Definition: applier.h:179
The pipeline stats aggregator of all group members stats and flow control module. ...
Definition: pipeline_stats.h:586
THD * applier_thd
Definition: applier.h:855
View_change_packet(std::string &view_id_arg)
Create a new data packet with associated data.
Definition: applier.h:97
A wrapper for pipeline actions.
Definition: pipeline_interfaces.h:500
virtual ~Sync_before_execution_action_packet()
Definition: applier.h:204
virtual ~Single_primary_action_packet()
Definition: applier.h:122
Sync_before_execution_action_packet(my_thread_id thread_id, const Gcs_member_identifier &gcs_member_id)
Create a new synchronization point request.
Definition: applier.h:198
void * handle
Definition: engine_loader.c:19
bool waiting_for_applier_suspension
Definition: applier.h:882
~View_change_packet()
Definition: applier.h:100
Definition: applier_channel_state_observer.h:29
const bool m_sid_specified
Definition: applier.h:175
PSI_stage_info info_GR_STAGE_module_executing
Definition: plugin_psi.cc:198
mysql_cond_t suspend_cond
Definition: applier.h:878
Action_packet(enum_packet_action action)
Create a new action packet.
Definition: applier.h:78
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
const std::vector< Gcs_member_identifier > m_leaving_members
Definition: applier.h:230
Some integer typedefs for easier portability.
#define SINGLE_PRIMARY_PACKET_TYPE
Definition: applier.h:48
Action to configure existing applier handlers.
Definition: pipeline_handlers.h:104
virtual void add_view_change_packet(View_change_packet *packet)
Queues a view change packet into the applier.
Definition: applier.h:488
Pipeline_stats_member_collector pipeline_stats_member_collector
Definition: applier.h:902
mysql_mutex_t run_lock
Definition: applier.h:863
virtual ~Leaving_members_action_packet()
Definition: applier.h:228
void signal_checkpoint_reached()
Definition: applier.h:141
enum enum_applier_state Member_applier_state
bool is_running()
Is the applier running?
Definition: applier.h:327
For binlog version 4.
Definition: log_event.h:1613
std::vector< std::string > group_executed_set
Definition: applier.h:103
const Gcs_member_identifier m_gcs_member_id
Definition: applier.h:177
void add_termination_packet()
Queues a packet that will make the applier module terminate it&#39;s handling process.
Definition: applier.h:475
Plugin_stage_monitor_handler stage_handler
Definition: applier.h:904
Queue_checkpoint_packet(std::shared_ptr< Continuation > checkpoint_condition_arg)
Create a new Queue_checkpoint_packet packet.
Definition: applier.h:136
Applier_channel_state_observer * applier_channel_observer
Definition: applier.h:900
Definition: certification_handler.h:31
Handler_pipeline_type
Definition: pipeline_factory.h:44
#define mysql_cond_wait(C, M)
Definition: mysql_cond.h:47
enum_packet_action
Definition: applier.h:61
const rpl_gno m_gno
Definition: applier.h:176
Class used to wait on the execution of some action.
Definition: pipeline_interfaces.h:405
A wrapper for raw network packets.
Definition: pipeline_interfaces.h:70
void add_sync_before_execution_action_packet(Sync_before_execution_action_packet *packet)
Queues a synchronization before execution action packet into the applier.
Definition: applier.h:522
Pipeline_stats_member_collector * get_pipeline_stats_member_collector()
Definition: applier.h:692
virtual size_t get_message_queue_size()
Returns the applier module&#39;s queue size.
Definition: applier.h:681
mysql_cond_t suspension_waiting_condition
Definition: applier.h:885
A wrapper for log events/packets.
Definition: pipeline_interfaces.h:122
virtual void add_suspension_packet()
Queues a packet that will eventually make the applier module suspend.
Definition: applier.h:464
bool applier_aborted
Definition: applier.h:868
mysql_cond_t run_cond
Definition: applier.h:864
A packet to wait for queue consumption.
Definition: applier.h:131
enum_applier_state
Definition: applier.h:233
bool is_applier_thread_aborted()
Is the applier marked for shutdown?
Definition: applier.h:316
Definition: plugin_utils.h:696
thread_state applier_thd_state
Definition: applier.h:866
Definition: applier.h:281
ulong stop_wait_timeout
Definition: applier.h:897
void set_stop_wait_timeout(ulong timeout)
Sets the applier shutdown timeout.
Definition: applier.h:440
my_thread_handle applier_pthd
Definition: applier.h:854
Synchronized_queue< Packet * > * incoming
Definition: applier.h:891
virtual Member_applier_state get_applier_status()
Definition: applier.h:683
const my_thread_id m_thread_id
Definition: applier.h:206
enum_group_replication_consistency_level
Definition: plugin_group_replication.h:34
Shared_writelock * shared_stop_write_lock
Definition: applier.h:888
The pipeline collector for the local member stats.
Definition: pipeline_stats.h:267
#define SYNC_BEFORE_EXECUTION_PACKET_TYPE
Definition: applier.h:49
Definition: my_thread_bits.h:51
A packet to request a synchronization point on the global message order on a given member before tran...
Definition: applier.h:190
A packet to control the applier in a event oriented way.
Definition: applier.h:72
void suspend_applier_module()
Suspends the applier module, being transactions still queued in the incoming queue.
Definition: applier.h:807
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:39
bool applier_killed_status
Definition: applier.h:872
virtual void awake_applier_module()
Awakes the applier module.
Definition: applier.h:547
rpl_sidno group_replication_sidno
Definition: applier.h:859
PSI_stage_key m_key
The registered stage key.
Definition: psi_stage_bits.h:73
#define true
Definition: config_static.h:44
std::string view_id
Definition: applier.h:102
int(* mysql_cond_broadcast)(mysql_cond_t *that, const char *src_file, unsigned int src_line)
Definition: mysql_cond_service.h:51
Definition: applier.h:65
Definition: applier.h:234
Flow_control_module flow_control_module
Definition: applier.h:903
virtual void run_flow_control_step()
Definition: applier.h:700
A generic interface for different kinds of packets.
Definition: pipeline_interfaces.h:45
Definition: plugin_utils.h:42
virtual ~Transaction_prepared_action_packet()
Definition: applier.h:173
Represents a set of GTIDs.
Definition: rpl_gtid.h:1313
ulonglong gtid_assignment_block_size
Definition: applier.h:860
PSI_stage_info info_GR_STAGE_module_suspending
Definition: plugin_psi.cc:200
Definition: stage_monitor_handler.h:29
A packet to inform that a given member did prepare a given transaction.
Definition: applier.h:152
Single_primary_action_packet(enum enum_action action_arg)
Create a new single primary action packet with associated data.
Definition: applier.h:119
uint32 my_thread_id
Definition: my_thread_local.h:33
void add_leaving_members_action_packet(Leaving_members_action_packet *packet)
Queues a leaving members action packet into the applier.
Definition: applier.h:534
Definition: applier.h:235
A packet to send new primary election related info to the applier.
Definition: applier.h:110
#define TRANSACTION_PREPARED_PACKET_TYPE
Definition: applier.h:50
bool reset_applier_logs
Definition: applier.h:858
A packet to inform pipeline listeners of leaving members, this packet will be handled on the global m...
Definition: applier.h:216
Definition: applier.h:62
Definition: applier.h:64
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
Definition: applier.h:236
enum_action
Definition: applier.h:112
bool suspended
Definition: applier.h:880
Definition: applier.h:239
API for Group Replication plugin.
rpl_sid m_sid
Definition: applier.h:182
#define mysql_mutex_unlock(M)
Definition: mysql_mutex.h:56
#define mysql_mutex_lock(M)
Definition: mysql_mutex.h:49
Definition: plugin_utils.h:176
~Action_packet()
Definition: applier.h:81
This is a POD.
Definition: uuid.h:60
Interface for the application of events, them being packets or log events.
Definition: pipeline_interfaces.h:530
char applier_module_channel_name[]
Definition: applier.cc:45
#define VIEW_CHANGE_PACKET_TYPE
Definition: applier.h:47
int applier_error
Definition: applier.h:870
Leaving_members_action_packet(const std::vector< Gcs_member_identifier > &leaving_members)
Create a new leaving members packet.
Definition: applier.h:223
long long int rpl_gno
Type of GNO, the second (numeric) component of GTID.
Definition: rpl_gtid.h:101
int handle_pipeline_action(Pipeline_action *action)
Gives the pipeline an action for execution.
Definition: applier.h:408
virtual ~Applier_module_interface()
Definition: applier.h:241
#define ACTION_PACKET_TYPE
Definition: applier.h:46
A packet to send view change related info to the applier.
Definition: applier.h:90
#define false
Definition: config_static.h:43
void add_single_primary_action_packet(Single_primary_action_packet *packet)
Queues a single primary action packet into the applier.
Definition: applier.h:499
Event_handler * pipeline
Definition: applier.h:894
#define LEAVING_MEMBERS_PACKET_TYPE
Definition: applier.h:51
int handle(const uchar *data, ulong len, enum_group_replication_consistency_level consistency_level, std::list< Gcs_member_identifier > *online_members)
Queues the packet coming from the reader for future application.
Definition: applier.h:391
enum_packet_action packet_action
Definition: applier.h:83
const Gcs_member_identifier m_gcs_member_id
Definition: applier.h:207
Computed statistics per member.
Definition: pipeline_stats.h:411
mysql_mutex_t suspend_lock
Definition: applier.h:876
static my_thread_id thread_id
Definition: my_thr_init.cc:62
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:765
Dialog Client Authentication nullptr
Definition: dialog.cc:353
std::shared_ptr< Continuation > checkpoint_condition
If we discard a packet.
Definition: applier.h:145
void add_transaction_prepared_action_packet(Transaction_prepared_action_packet *packet)
Queues a transaction prepared action packet into the applier.
Definition: applier.h:510
Definition: applier.h:63
Transaction_prepared_action_packet(const rpl_sid *sid, rpl_gno gno, const Gcs_member_identifier &gcs_member_id)
Create a new transaction prepared action.
Definition: applier.h:162