Rechercher dans le manuel MySQL
17.4.1.21 Replication and MEMORY Tables
When a master server shuts down and restarts, its
MEMORY
tables become empty. To
replicate this effect to slaves, the first time that the master
uses a given MEMORY
table after
startup, it logs an event that notifies slaves that the table
must be emptied by writing a
DELETE
statement for that table
to the binary log. This generated event is identifiable by a
comment in the binary log, and if GTIDs are in use on the
server, it has a GTID assigned.
When a slave server shuts down and restarts, its
MEMORY
tables become empty. This
causes the slave to be out of synchrony with the master and may
lead to other failures or cause the slave to stop:
Row-format updates and deletes received from the master may fail with
Can't find record in '
.memory_table
'Statements such as
INSERT INTO ... SELECT FROM
may insert a different set of rows on the master and slave.memory_table
The safe way to restart a slave that is replicating
MEMORY
tables is to first drop or
delete all rows from the MEMORY
tables on the master and wait until those changes have
replicated to the slave. Then it is safe to restart the slave.
An alternative restart method may apply in some cases. When
binlog_format=ROW
, you can
prevent the slave from stopping if you set
slave_exec_mode=IDEMPOTENT
before you start the slave again. This allows the slave to
continue to replicate, but its
MEMORY
tables will still be
different from those on the master. This can be okay if the
application logic is such that the contents of
MEMORY
tables can be safely lost
(for example, if the MEMORY
tables
are used for caching).
slave_exec_mode=IDEMPOTENT
applies globally to all tables, so it may hide other replication
errors in non-MEMORY
tables.
(The method just described is not applicable in NDB Cluster,
where slave_exec_mode
is always
IDEMPOTENT
, and cannot be changed.)
The size of MEMORY
tables is
limited by the value of the
max_heap_table_size
system
variable, which is not replicated (see
Section 17.4.1.38, “Replication and Variables”). A change in
max_heap_table_size
takes effect for
MEMORY
tables that are created or updated
using ALTER TABLE
... ENGINE = MEMORY
or TRUNCATE
TABLE
following the change, or for all
MEMORY
tables following a server
restart. If you increase the value of this variable on the
master without doing so on the slave, it becomes possible for a
table on the master to grow larger than its counterpart on the
slave, leading to inserts that succeed on the master but fail on
the slave with Table is full errors. This
is a known issue (Bug #48666). In such cases, you must set the
global value of
max_heap_table_size
on the
slave as well as on the master, then restart replication. It is
also recommended that you restart both the master and slave
MySQL servers, to insure that the new value takes complete
(global) effect on each of them.
See Section 16.3, “The MEMORY Storage Engine”, for more
information about MEMORY
tables.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-replication-features-memory.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.