1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-27862 Galera should replicate nextval()-related changes in sequences with INCREMENT <> 0, at least NOCACHE ones with engine=InnoDB

Sequence storage engine is not transactionl so cache will be written in
stmt_cache that is not replicated in cluster. To fix this replicate
what is available in both trans_cache and stmt_cache.

Sequences will only work when NOCACHE keyword is used when sequnce is
created. If WSREP is enabled and we don't have this keyword report error
indicting that sequence will not work correctly in cluster.

When binlog is enabled statement cache will be cleared in transaction
before COMMIT so cache generated from sequence will not be replicated.
We need to keep cache until replication.

Tests are re-recorded because of replication changes that were
introducted with this PR.

Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
This commit is contained in:
mkaruza
2022-05-10 11:15:32 +02:00
committed by Jan Lindström
parent c8fabbed42
commit ebbd5ef6e2
13 changed files with 197 additions and 13 deletions

View File

@ -86,18 +86,37 @@ int Wsrep_client_service::prepare_data_for_replication()
DBUG_ASSERT(m_thd == current_thd);
DBUG_ENTER("Wsrep_client_service::prepare_data_for_replication");
size_t data_len= 0;
IO_CACHE* cache= wsrep_get_trans_cache(m_thd);
IO_CACHE* transactional_cache= wsrep_get_cache(m_thd, true);
IO_CACHE* stmt_cache= wsrep_get_cache(m_thd, false);
if (cache)
if (transactional_cache || stmt_cache)
{
m_thd->binlog_flush_pending_rows_event(true);
if (wsrep_write_cache(m_thd, cache, &data_len))
size_t transactional_data_len= 0;
size_t stmt_data_len= 0;
// Write transactional cache
if (transactional_cache &&
wsrep_write_cache(m_thd, transactional_cache, &transactional_data_len))
{
WSREP_ERROR("rbr write fail, data_len: %zu",
data_len);
// wsrep_override_error(m_thd, ER_ERROR_DURING_COMMIT);
DBUG_RETURN(1);
}
// Write stmt cache
if (stmt_cache && wsrep_write_cache(m_thd, stmt_cache, &stmt_data_len))
{
WSREP_ERROR("rbr write fail, data_len: %zu",
data_len);
// wsrep_override_error(m_thd, ER_ERROR_DURING_COMMIT);
DBUG_RETURN(1);
}
// Complete data written from both caches
data_len = transactional_data_len + stmt_data_len;
}
if (data_len == 0)
@ -139,7 +158,7 @@ int Wsrep_client_service::prepare_fragment_for_replication(
DBUG_ASSERT(m_thd == current_thd);
THD* thd= m_thd;
DBUG_ENTER("Wsrep_client_service::prepare_fragment_for_replication");
IO_CACHE* cache= wsrep_get_trans_cache(thd);
IO_CACHE* cache= wsrep_get_cache(thd, true);
thd->binlog_flush_pending_rows_event(true);
if (!cache)
@ -221,7 +240,7 @@ bool Wsrep_client_service::statement_allowed_for_streaming() const
size_t Wsrep_client_service::bytes_generated() const
{
IO_CACHE* cache= wsrep_get_trans_cache(m_thd);
IO_CACHE* cache= wsrep_get_cache(m_thd, true);
if (cache)
{
size_t pending_rows_event_length= 0;