Skip to content

Commit

Permalink
Merge 10.4 into 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Lindström committed Sep 5, 2022
2 parents 244fdc4 + 2917bd0 commit ba987a4
Show file tree
Hide file tree
Showing 40 changed files with 207 additions and 149 deletions.
78 changes: 37 additions & 41 deletions include/wsrep.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,58 @@
#define WSREP_INCLUDED

#include <my_config.h>
#include "log.h"

#ifdef WITH_WSREP

#define IF_WSREP(A,B) A

#define DBUG_ASSERT_IF_WSREP(A) DBUG_ASSERT(A)

#define WSREP_MYSQL_DB (char *)"mysql"

#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \
if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \
goto wsrep_error_label;

#define WSREP_TO_ISOLATION_BEGIN_CREATE(db_, table_, table_list_, create_info_) \
if (WSREP_ON && WSREP(thd) && \
wsrep_to_isolation_begin(thd, db_, table_, \
table_list_, nullptr, nullptr, create_info_))\
goto wsrep_error_label;

#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_, create_info_) \
if (WSREP(thd) && wsrep_thd_is_local(thd) && \
wsrep_to_isolation_begin(thd, db_, table_, \
table_list_, alter_info_, \
fk_tables_, create_info_))

#define WSREP_TO_ISOLATION_END \
if ((WSREP(thd) && wsrep_thd_is_local_toi(thd)) || \
wsrep_thd_is_in_rsu(thd)) \
wsrep_to_isolation_end(thd);

/*
Checks if lex->no_write_to_binlog is set for statements that use LOCAL or
NO_WRITE_TO_BINLOG.
*/
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \
if (WSREP(thd) && !thd->lex->no_write_to_binlog \
&& wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto wsrep_error_label;
extern ulong wsrep_debug; // wsrep_mysqld.cc
extern void WSREP_LOG(void (*fun)(const char* fmt, ...), const char* fmt, ...);

#define WSREP_DEBUG(...) \
if (wsrep_debug) WSREP_LOG(sql_print_information, ##__VA_ARGS__)
#define WSREP_INFO(...) WSREP_LOG(sql_print_information, ##__VA_ARGS__)
#define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__)
#define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__)
#define WSREP_UNKNOWN(fmt, ...) WSREP_ERROR("UNKNOWN: " fmt, ##__VA_ARGS__)

#define WSREP_LOG_CONFLICT_THD(thd, role) \
WSREP_INFO("%s: \n " \
" THD: %lu, mode: %s, state: %s, conflict: %s, seqno: %lld\n " \
" SQL: %s", \
role, \
thd_get_thread_id(thd), \
wsrep_thd_client_mode_str(thd), \
wsrep_thd_client_state_str(thd), \
wsrep_thd_transaction_state_str(thd), \
wsrep_thd_trx_seqno(thd), \
wsrep_thd_query(thd) \
);

#define WSREP_LOG_CONFLICT(bf_thd, victim_thd, bf_abort) \
if (wsrep_debug || wsrep_log_conflicts) \
{ \
WSREP_INFO("cluster conflict due to %s for threads:", \
(bf_abort) ? "high priority abort" : "certification failure" \
); \
if (bf_thd) WSREP_LOG_CONFLICT_THD(bf_thd, "Winning thread"); \
if (victim_thd) WSREP_LOG_CONFLICT_THD(victim_thd, "Victim thread"); \
WSREP_INFO("context: %s:%d", __FILE__, __LINE__); \
}

#define WSREP_SYNC_WAIT(thd_, before_) \
{ if (WSREP_CLIENT(thd_) && \
wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; }

#else /* !WITH_WSREP */

/* These macros are needed to compile MariaDB without WSREP support
* (e.g. embedded) */

#define IF_WSREP(A,B) B
//#define DBUG_ASSERT_IF_WSREP(A)
#define WSREP_DEBUG(...)
//#define WSREP_INFO(...)
//#define WSREP_WARN(...)
#define WSREP_ERROR(...)
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0)
#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_, create_info_)
#define WSREP_TO_ISOLATION_END
#define WSREP_TO_ISOLATION_BEGIN_CREATE(db_, table_, table_list_, create_info_)
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
#define WSREP_SYNC_WAIT(thd_, before_)
#endif /* WITH_WSREP */

#endif /* WSREP_INCLUDED */
4 changes: 3 additions & 1 deletion sql/backup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
#include "sql_insert.h" // kill_delayed_threads
#include "sql_handler.h" // mysql_ha_cleanup_no_free
#include <my_sys.h>
#include "wsrep_mysqld.h"
#ifdef WITH_WSREP
#include "wsrep_server_state.h"
#endif /* WITH_WSREP */

static const char *stage_names[]=
{"START", "FLUSH", "BLOCK_DDL", "BLOCK_COMMIT", "END", 0};
Expand Down
1 change: 1 addition & 0 deletions sql/event_data_objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "sp_head.h"
#include "sql_show.h" // append_definer, append_identifier
#include "mysql/psi/mysql_sp.h"
#include "wsrep_mysqld.h"
#ifdef WITH_WSREP
#include "wsrep_trans_observer.h"
#endif /* WITH_WSREP */
Expand Down
1 change: 1 addition & 0 deletions sql/events.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "set_var.h"
#include "lock.h" // lock_object_name
#include "mysql/psi/mysql_sp.h"
#include "wsrep_mysqld.h"

/**
@addtogroup Event_Scheduler
Expand Down
3 changes: 3 additions & 0 deletions sql/item_func.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
#include "debug_sync.h"
#include "sql_base.h"
#include "sql_cte.h"
#ifdef WITH_WSREP
#include "mysql/service_wsrep.h"
#endif /* WITH_WSREP */

#ifdef NO_EMBEDDED_ACCESS_CHECKS
#define sp_restore_security_context(A,B) while (0) {}
Expand Down
2 changes: 1 addition & 1 deletion sql/item_strfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5273,8 +5273,8 @@ String *Item_temptable_rowid::val_str(String *str)
}

#ifdef WITH_WSREP

#include "wsrep_mysqld.h"
#include "wsrep_server_state.h"
/* Format is %d-%d-%llu */
#define WSREP_MAX_WSREP_SERVER_GTID_STR_LEN 10+1+10+1+20

Expand Down
3 changes: 3 additions & 0 deletions sql/lock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@
#include "sql_parse.h" // is_log_table_write_query
#include "sql_handler.h"
#include <hash.h>
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
#include "wsrep_server_state.h"
#endif

/**
@defgroup Locking Locking
Expand Down
1 change: 0 additions & 1 deletion sql/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define LOG_H

#include "handler.h" /* my_xid */
#include "wsrep_mysqld.h"
#include "rpl_constants.h"

class Relay_log_info;
Expand Down
3 changes: 3 additions & 0 deletions sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#include <strfunc.h>
#include "compat56.h"
#include "sql_insert.h"
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
#endif /* WITH_WSREP */
#else
#include "mysqld_error.h"
#endif /* MYSQL_CLIENT */
Expand Down
3 changes: 3 additions & 0 deletions sql/mdl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include <mysql/psi/mysql_mdl.h>
#include <algorithm>
#include <array>
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
#endif

static PSI_memory_key key_memory_MDL_context_acquire_locks;

Expand Down
1 change: 1 addition & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#ifdef WITH_WSREP
#include "wsrep_thd.h"
#include "wsrep_sst.h"
#include "wsrep_server_state.h"
#endif /* WITH_WSREP */
#include "proxy_protocol.h"

Expand Down
1 change: 1 addition & 0 deletions sql/sp_head.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "sql_audit.h"
#include "debug_sync.h"
#ifdef WITH_WSREP
#include "wsrep.h"
#include "wsrep_trans_observer.h"
#endif /* WITH_WSREP */

Expand Down
1 change: 1 addition & 0 deletions sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "password.h"

#include "sql_plugin_compat.h"
#include "wsrep_mysqld.h"

#define MAX_SCRAMBLE_LENGTH 1024

Expand Down
3 changes: 3 additions & 0 deletions sql/sql_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ TODO list:
#include "probes_mysql.h"
#include "transaction.h"
#include "strfunc.h"
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
#endif

const uchar *query_state_map;

Expand Down
1 change: 1 addition & 0 deletions sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#ifdef WITH_WSREP
#include "wsrep_thd.h"
#include "wsrep_trans_observer.h"
#include "wsrep_server_state.h"
#else
static inline bool wsrep_is_bf_aborted(THD* thd) { return false; }
#endif /* WITH_WSREP */
Expand Down
8 changes: 7 additions & 1 deletion sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ void set_thd_stage_info(void *thd,
#include "my_apc.h"
#include "rpl_gtid.h"

#include "wsrep_mysqld.h"
#include "wsrep.h"
#include "wsrep_on.h"
#ifdef WITH_WSREP
#include <inttypes.h>
/* wsrep-lib */
Expand All @@ -75,6 +76,11 @@ void set_thd_stage_info(void *thd,
#include "wsrep_condition_variable.h"

class Wsrep_applier_service;
enum wsrep_consistency_check_mode {
NO_CONSISTENCY_CHECK,
CONSISTENCY_CHECK_DECLARED,
CONSISTENCY_CHECK_RUNNING,
};
#endif /* WITH_WSREP */

class Reprepare_observer;
Expand Down
3 changes: 3 additions & 0 deletions sql/sql_lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include "sql_partition.h"
#include "sql_partition_admin.h" // Sql_cmd_alter_table_*_part
#include "event_parse_data.h"
#ifdef WITH_WSREP
#include "mysql/service_wsrep.h"
#endif

void LEX::parse_error(uint err_number)
{
Expand Down
1 change: 1 addition & 0 deletions sql/sql_partition_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "ha_partition.h" // ha_partition
#endif
#include "sql_base.h" // open_and_lock_tables
#include "wsrep_mysqld.h"

#ifndef WITH_PARTITION_STORAGE_ENGINE

Expand Down
1 change: 1 addition & 0 deletions sql/sql_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <mysql/plugin_data_type.h>
#include <mysql/plugin_function.h>
#include "sql_plugin_compat.h"
#include "wsrep_mysqld.h"

static PSI_memory_key key_memory_plugin_mem_root;
static PSI_memory_key key_memory_plugin_int_mem_root;
Expand Down
3 changes: 3 additions & 0 deletions sql/sql_reload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include "debug_sync.h"
#include "des_key_file.h"
#include "transaction.h"
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
#endif

static void disable_checkpoints(THD *thd);

Expand Down
3 changes: 2 additions & 1 deletion sql/sql_rename.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
#include "sql_trigger.h"
#include "sql_base.h" // tdc_remove_table, lock_table_names,
#include "sql_handler.h" // mysql_ha_rm_tables
#include "sql_statistics.h"
#include "sql_statistics.h"
#include "wsrep_mysqld.h"

static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list,
bool skip_error, bool if_exits,
Expand Down
3 changes: 3 additions & 0 deletions sql/sql_sequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "transaction.h"
#include "lock.h"
#include "sql_acl.h"
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
#endif

struct Field_definition
{
Expand Down
1 change: 1 addition & 0 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "tztime.h"
#include "sql_insert.h" // binlog_drop_table
#include <algorithm>
#include "wsrep_mysqld.h"

#ifdef __WIN__
#include <io.h>
Expand Down
1 change: 1 addition & 0 deletions sql/sql_trigger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <mysys_err.h>
#include "debug_sync.h"
#include "mysql/psi/mysql_sp.h"
#include "wsrep_mysqld.h"

/*************************************************************************/

Expand Down
3 changes: 3 additions & 0 deletions sql/sys_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
#include "semisync_master.h"
#include "semisync_slave.h"
#include <ssl_compat.h>
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
#endif

#define PCRE2_STATIC 1 /* Important on Windows */
#include "pcre2.h" /* pcre2 header file */
Expand Down
2 changes: 1 addition & 1 deletion sql/wsrep_binlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#include "mariadb.h"
#include "mysql/service_wsrep.h"
#include "wsrep_binlog.h"
#include "wsrep_priv.h"
#include "log.h"
#include "slave.h"
#include "log_event.h"
#include "wsrep_applier.h"
#include "wsrep_mysqld.h"

#include "transaction.h"

Expand Down
1 change: 1 addition & 0 deletions sql/wsrep_check_opts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "sys_vars_shared.h"
#include "wsrep.h"
#include "wsrep_sst.h"
#include "wsrep_mysqld.h"

extern char *my_bind_addr_str;

Expand Down
4 changes: 3 additions & 1 deletion sql/wsrep_client_service.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2018-2021 Codership Oy <info@codership.com>
/* Copyright 2018-2022 Codership Oy <info@codership.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -20,6 +20,8 @@
#include "wsrep_thd.h"
#include "wsrep_xid.h"
#include "wsrep_trans_observer.h"
#include "wsrep_server_state.h"
#include "wsrep_mysqld.h"

#include "sql_base.h" /* close_temporary_table() */
#include "sql_class.h" /* THD */
Expand Down
1 change: 1 addition & 0 deletions sql/wsrep_high_priority_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "wsrep_schema.h"
#include "wsrep_xid.h"
#include "wsrep_trans_observer.h"
#include "wsrep_server_state.h"

#include "sql_class.h" /* THD */
#include "transaction.h"
Expand Down
Loading

0 comments on commit ba987a4

Please sign in to comment.