
[Commits] be5698265a4: MDEV-15607: mysqld crashed few after node is being joined with sst
by jan 27 Jun '18
by jan 27 Jun '18
27 Jun '18
revision-id: be5698265a4195586142d1a34fdd1cce9d95d8a1 (mariadb-10.1.34-10-gbe5698265a4)
parent(s): c6392d52ee2e918a65b05c275286ff4d450eef2c
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-06-27 12:37:21 +0300
message:
MDEV-15607: mysqld crashed few after node is being joined with sst
This is a typical systemd response where it tries to shutdown the
joiner (due to "timeout") before the joiner manages to complete SST.
wsrep_sst_wait
wsrep_SE_init_wait
While waiting the operation to finish use mysql_cond_timedwait
instead of mysql_cond_wait and if operation is not finished
extend systemd timeout (if needed).
---
sql/wsrep_sst.cc | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index 4df969496bc..60683bf740c 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -30,6 +30,10 @@
#include <cstdio>
#include <cstdlib>
+#if MYSQL_VERSION_ID < 100200
+# include <my_service_manager.h>
+#endif
+
static char wsrep_defaults_file[FN_REFLEN * 2 + 10 + 30 +
sizeof(WSREP_SST_OPT_CONF) +
sizeof(WSREP_SST_OPT_CONF_SUFFIX) +
@@ -186,6 +190,9 @@ bool wsrep_before_SE()
static bool sst_complete = false;
static bool sst_needed = false;
+#define WSREP_EXTEND_TIMEOUT_INTERVAL 30
+#define WSREP_TIMEDWAIT_SECONDS 10
+
void wsrep_sst_grab ()
{
WSREP_INFO("wsrep_sst_grab()");
@@ -197,11 +204,25 @@ void wsrep_sst_grab ()
// Wait for end of SST
bool wsrep_sst_wait ()
{
- if (mysql_mutex_lock (&LOCK_wsrep_sst)) abort();
+ struct timespec wtime = {WSREP_TIMEDWAIT_SECONDS, 0};
+ uint32 total_wtime = 0;
+
+ if (mysql_mutex_lock (&LOCK_wsrep_sst))
+ abort();
+
+ WSREP_INFO("Waiting for SST to complete.");
+
while (!sst_complete)
{
- WSREP_INFO("Waiting for SST to complete.");
- mysql_cond_wait (&COND_wsrep_sst, &LOCK_wsrep_sst);
+ mysql_cond_timedwait (&COND_wsrep_sst, &LOCK_wsrep_sst, &wtime);
+
+ if (!sst_complete)
+ {
+ total_wtime += wtime.tv_sec;
+ WSREP_DEBUG("Waiting for SST to complete. waited %u secs.", total_wtime);
+ service_manager_extend_timeout(WSREP_EXTEND_TIMEOUT_INTERVAL,
+ "WSREP state transfer ongoing, current seqno: %ld", local_seqno);
+ }
}
if (local_seqno >= 0)
@@ -1298,10 +1319,22 @@ void wsrep_SE_init_grab()
void wsrep_SE_init_wait()
{
+ struct timespec wtime = {WSREP_TIMEDWAIT_SECONDS, 0};
+ uint32 total_wtime=0;
+
while (SE_initialized == false)
{
- mysql_cond_wait (&COND_wsrep_sst_init, &LOCK_wsrep_sst_init);
+ mysql_cond_timedwait (&COND_wsrep_sst_init, &LOCK_wsrep_sst_init, &wtime);
+
+ if (!SE_initialized)
+ {
+ total_wtime += wtime.tv_sec;
+ WSREP_DEBUG("Waiting for SST to complete. waited %u secs.", total_wtime);
+ service_manager_extend_timeout(WSREP_EXTEND_TIMEOUT_INTERVAL,
+ "WSREP SE initialization ongoing.");
+ }
}
+
mysql_mutex_unlock (&LOCK_wsrep_sst_init);
}
1
0

27 Jun '18
revision-id: b792aa5cd9e816dc3a67ba3105c957017eecd548 (mariadb-10.3.6-37-gb792aa5)
parent(s): d38bc34095cba6ae841efc86894368d4394cb198
author: Igor Babaev
committer: Igor Babaev
timestamp: 2018-06-26 18:20:15 -0700
message:
Post-merge fix: fixed a failure of cte_recursive.test.
---
sql/sql_lex.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 294d503..9ae9abd 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1485,6 +1485,7 @@ class st_select_lex: public st_select_lex_node
if (d && master_unit() && master_unit()->union_distinct != this)
master_unit()->union_distinct= this;
distinct= d;
+ with_all_modifier= !distinct;
DBUG_VOID_RETURN;
}
bool set_nest_level(int new_nest_level);
1
0
revision-id: 6d377a523c78b1e442d69ae6be548bccddd54416 (mariadb-10.2.16-9-g6d377a5)
parent(s): 31c950cca8fa1623d41a8a7784e09fbcd6bc2c71
author: Igor Babaev
committer: Igor Babaev
timestamp: 2018-06-26 10:49:23 -0700
message:
Correction for the patch to fix mdev-16473.
---
sql/sql_base.cc | 2 +-
sql/sql_class.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 062106d..093f7cf 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -3331,7 +3331,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
Not a placeholder: must be a base/temporary table or a view. Let us open it.
*/
- if (tables->db == no_db)
+ if (tables->db[0] == no_db[0])
{
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
error= TRUE;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index ad2d0ab..e79fde0 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3960,8 +3960,8 @@ class THD :public Statement,
return TRUE;
}
/* This will allow to throw an error later for non-CTE references */
- *p_db= (char *) no_db;
*p_db_length= strlen(no_db);
+ *p_db= strmake(no_db, *p_db_length);
}
else
{
1
0

26 Jun '18
revision-id: 36a6787c2bdea95eb3399949a1218a6f7014e6b8 (mariadb-10.0.35-50-g36a6787)
parent(s): cc8772f33e8f94844e32f3aa79e5f41d784f8ec0
author: Vicențiu Ciorbaru
committer: Vicențiu Ciorbaru
timestamp: 2018-06-26 19:39:18 +0300
message:
Fix uninitialized variable warning in spider
'error_num' is used uninitialized whenever 'if' condition is true.
Make sure to report out of memory properly.
---
storage/spider/spd_table.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index 265c64f..0302665 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -6670,8 +6670,10 @@ int spider_db_init(
&spider_udf_table_mon_list_hash, sizeof(HASH) *
spider_param_udf_table_mon_mutex_count(),
NullS))
- )
+ ) {
+ error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_mon_mutxes;
+ }
for (roop_count = 0;
roop_count < (int) spider_param_udf_table_mon_mutex_count();
1
0

[Commits] 7053e26: MDEV-15778: Fix TokuDB build issues on macOS 10.13.4
by vicentiu@mariadb.org 26 Jun '18
by vicentiu@mariadb.org 26 Jun '18
26 Jun '18
revision-id: 7053e26e1869962ef473043686996f40ac0fb88c (mariadb-10.0.35-32-g7053e26)
parent(s): 8f82c4844342f42c27e2336b64f7bdd1a1344cbd
author: Teodor Mircea Ionita
committer: Vicențiu-Marian Ciorbaru
timestamp: 2018-06-10 10:12:34 +0300
message:
MDEV-15778: Fix TokuDB build issues on macOS 10.13.4
Several issues were encountered and fixed as explained bellow:
* missing link to dbug lib;
* user proper fprintf format specifier;
* ZERO_COND_INITIALIZER was using wrong toku_cond_t struct
initializer for first member of type pthread_cond_t and
not considering the TOKU_PTHREAD_DEBUG case which has
one extra struct member of type pfs_key_t;
* Remove likely(!opt_debug_sync_timeout), argument is
declared extern and not available to Toku;
* pthread_mutex_timedlock() is not available in pthreads
for Mac, as it's not part of the POSIX pthreads spec.
The encompassing event_t::wait(ms) methods are unused,
thus have been removed;
---
storage/tokudb/PerconaFT/ft/ft-ops.cc | 4 +-
.../tokudb/PerconaFT/ft/serialize/ft-serialize.cc | 6 +--
.../PerconaFT/ft/serialize/ft_node-serialize.cc | 58 +++++++++++-----------
.../tokudb/PerconaFT/portability/toku_debug_sync.h | 3 --
.../tokudb/PerconaFT/portability/toku_pthread.h | 12 ++++-
storage/tokudb/PerconaFT/src/CMakeLists.txt | 2 +-
storage/tokudb/tokudb_thread.h | 49 ------------------
7 files changed, 46 insertions(+), 88 deletions(-)
diff --git a/storage/tokudb/PerconaFT/ft/ft-ops.cc b/storage/tokudb/PerconaFT/ft/ft-ops.cc
index d036366..d7ea5ef 100644
--- a/storage/tokudb/PerconaFT/ft/ft-ops.cc
+++ b/storage/tokudb/PerconaFT/ft/ft-ops.cc
@@ -821,7 +821,7 @@ int toku_ftnode_fetch_callback(CACHEFILE UU(cachefile),
fprintf(
stderr,
"%s:%d:toku_ftnode_fetch_callback - "
- "file[%s], blocknum[%ld], toku_deserialize_ftnode_from "
+ "file[%s], blocknum[%lld], toku_deserialize_ftnode_from "
"failed with a checksum error.\n",
__FILE__,
__LINE__,
@@ -831,7 +831,7 @@ int toku_ftnode_fetch_callback(CACHEFILE UU(cachefile),
fprintf(
stderr,
"%s:%d:toku_ftnode_fetch_callback - "
- "file[%s], blocknum[%ld], toku_deserialize_ftnode_from "
+ "file[%s], blocknum[%lld], toku_deserialize_ftnode_from "
"failed with %d.\n",
__FILE__,
__LINE__,
diff --git a/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc b/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc
index b24d72a..fe68e1b 100644
--- a/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc
+++ b/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc
@@ -656,9 +656,9 @@ int deserialize_ft_from_fd_into_rbuf(int fd,
fprintf(stderr, \
"%s:%d toku_deserialize_ft_from: " \
"filename[%s] " \
- "r[%d] max_acceptable_lsn[%lu]" \
- "r0[%d] checkpoint_lsn_0[%lu] checkpoint_count_0[%lu] " \
- "r1[%d] checkpoint_lsn_1[%lu] checkpoint_count_1[%lu]\n", \
+ "r[%d] max_acceptable_lsn[%llu]" \
+ "r0[%d] checkpoint_lsn_0[%llu] checkpoint_count_0[%llu] " \
+ "r1[%d] checkpoint_lsn_1[%llu] checkpoint_count_1[%llu]\n", \
__FILE__, \
__LINE__, \
fn, \
diff --git a/storage/tokudb/PerconaFT/ft/serialize/ft_node-serialize.cc b/storage/tokudb/PerconaFT/ft/serialize/ft_node-serialize.cc
index 5589990..02d0cc6 100644
--- a/storage/tokudb/PerconaFT/ft/serialize/ft_node-serialize.cc
+++ b/storage/tokudb/PerconaFT/ft/serialize/ft_node-serialize.cc
@@ -1170,7 +1170,7 @@ int verify_ftnode_sub_block(struct sub_block *sb,
fprintf(
stderr,
"%s:%d:verify_ftnode_sub_block - "
- "file[%s], blocknum[%ld], stored_xsum[%u] != actual_xsum[%u]\n",
+ "file[%s], blocknum[%lld], stored_xsum[%u] != actual_xsum[%u]\n",
__FILE__,
__LINE__,
fname ? fname : "unknown",
@@ -1197,7 +1197,7 @@ static int deserialize_ftnode_info(struct sub_block *sb, FTNODE node) {
fprintf(
stderr,
"%s:%d:deserialize_ftnode_info - "
- "file[%s], blocknum[%ld], verify_ftnode_sub_block failed with %d\n",
+ "file[%s], blocknum[%lld], verify_ftnode_sub_block failed with %d\n",
__FILE__,
__LINE__,
fname ? fname : "unknown",
@@ -1253,7 +1253,7 @@ static int deserialize_ftnode_info(struct sub_block *sb, FTNODE node) {
fprintf(
stderr,
"%s:%d:deserialize_ftnode_info - "
- "file[%s], blocknum[%ld], data_size[%d] != rb.ndone[%d]\n",
+ "file[%s], blocknum[%lld], data_size[%d] != rb.ndone[%d]\n",
__FILE__,
__LINE__,
fname ? fname : "unknown",
@@ -1388,7 +1388,7 @@ static int deserialize_ftnode_partition(
if (r != 0) {
fprintf(stderr,
"%s:%d:deserialize_ftnode_partition - "
- "file[%s], blocknum[%ld], "
+ "file[%s], blocknum[%lld], "
"verify_ftnode_sub_block failed with %d\n",
__FILE__,
__LINE__,
@@ -1410,7 +1410,7 @@ static int deserialize_ftnode_partition(
if (ch != FTNODE_PARTITION_MSG_BUFFER) {
fprintf(stderr,
"%s:%d:deserialize_ftnode_partition - "
- "file[%s], blocknum[%ld], ch[%d] != "
+ "file[%s], blocknum[%lld], ch[%d] != "
"FTNODE_PARTITION_MSG_BUFFER[%d]\n",
__FILE__,
__LINE__,
@@ -1433,7 +1433,7 @@ static int deserialize_ftnode_partition(
if (ch != FTNODE_PARTITION_DMT_LEAVES) {
fprintf(stderr,
"%s:%d:deserialize_ftnode_partition - "
- "file[%s], blocknum[%ld], ch[%d] != "
+ "file[%s], blocknum[%lld], ch[%d] != "
"FTNODE_PARTITION_DMT_LEAVES[%d]\n",
__FILE__,
__LINE__,
@@ -1457,7 +1457,7 @@ static int deserialize_ftnode_partition(
if (rb.ndone != rb.size) {
fprintf(stderr,
"%s:%d:deserialize_ftnode_partition - "
- "file[%s], blocknum[%ld], rb.ndone[%d] != rb.size[%d]\n",
+ "file[%s], blocknum[%lld], rb.ndone[%d] != rb.size[%d]\n",
__FILE__,
__LINE__,
fname ? fname : "unknown",
@@ -1485,7 +1485,7 @@ static int decompress_and_deserialize_worker(struct rbuf curr_rbuf,
const char *fname = toku_ftnode_get_cachefile_fname_in_env(node);
fprintf(stderr,
"%s:%d:decompress_and_deserialize_worker - "
- "file[%s], blocknum[%ld], read_and_decompress_sub_block failed "
+ "file[%s], blocknum[%lld], read_and_decompress_sub_block failed "
"with %d\n",
__FILE__,
__LINE__,
@@ -1502,7 +1502,7 @@ static int decompress_and_deserialize_worker(struct rbuf curr_rbuf,
const char *fname = toku_ftnode_get_cachefile_fname_in_env(node);
fprintf(stderr,
"%s:%d:decompress_and_deserialize_worker - "
- "file[%s], blocknum[%ld], deserialize_ftnode_partition failed "
+ "file[%s], blocknum[%lld], deserialize_ftnode_partition failed "
"with %d\n",
__FILE__,
__LINE__,
@@ -1582,7 +1582,7 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough(
fprintf(
stderr,
"%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - "
- "file[%s], blocknum[%ld], rb->size[%u] < 24\n",
+ "file[%s], blocknum[%lld], rb->size[%u] < 24\n",
__FILE__,
__LINE__,
fname ? fname : "unknown",
@@ -1602,7 +1602,7 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough(
fprintf(
stderr,
"%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - "
- "file[%s], blocknum[%ld], unrecognized magic number "
+ "file[%s], blocknum[%lld], unrecognized magic number "
"%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
__FILE__,
__LINE__,
@@ -1627,7 +1627,7 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough(
fprintf(
stderr,
"%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - "
- "file[%s], blocknum[%ld], node->layout_version_read_from_disk[%d] "
+ "file[%s], blocknum[%lld], node->layout_version_read_from_disk[%d] "
"< FT_FIRST_LAYOUT_VERSION_WITH_BASEMENT_NODES[%d]\n",
__FILE__,
__LINE__,
@@ -1667,7 +1667,7 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough(
fprintf(
stderr,
"%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - "
- "file[%s], blocknum[%ld], needed_size[%d] > rb->size[%d]\n",
+ "file[%s], blocknum[%lld], needed_size[%d] > rb->size[%d]\n",
__FILE__,
__LINE__,
fname ? fname : "unknown",
@@ -1695,7 +1695,7 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough(
fprintf(
stderr,
"%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - "
- "file[%s], blocknum[%ld], stored_checksum[%d] != checksum[%d]\n",
+ "file[%s], blocknum[%lld], stored_checksum[%d] != checksum[%d]\n",
__FILE__,
__LINE__,
fname ? fname : "unknown",
@@ -1717,7 +1717,7 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough(
fprintf(
stderr,
"%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - "
- "file[%s], blocknum[%ld], rb->size[%d] - rb->ndone[%d] < "
+ "file[%s], blocknum[%lld], rb->size[%d] - rb->ndone[%d] < "
"sb_node_info.compressed_size[%d] + 8\n",
__FILE__,
__LINE__,
@@ -1744,7 +1744,7 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough(
fprintf(
stderr,
"%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - "
- "file[%s], blocknum[%ld], sb_node_info.xsum[%d] != actual_xsum[%d]\n",
+ "file[%s], blocknum[%lld], sb_node_info.xsum[%d] != actual_xsum[%d]\n",
__FILE__,
__LINE__,
fname ? fname : "unknown",
@@ -1774,7 +1774,7 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough(
fprintf(
stderr,
"%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - "
- "file[%s], blocknum[%ld], deserialize_ftnode_info failed with "
+ "file[%s], blocknum[%lld], deserialize_ftnode_info failed with "
"%d\n",
__FILE__,
__LINE__,
@@ -1812,7 +1812,7 @@ static int deserialize_ftnode_header_from_rbuf_if_small_enough(
fprintf(
stderr,
"%s:%d:deserialize_ftnode_header_from_rbuf_if_small_enough - "
- "file[%s], blocknum[%ld], toku_ftnode_pf_callback failed with "
+ "file[%s], blocknum[%lld], toku_ftnode_pf_callback failed with "
"%d\n",
__FILE__,
__LINE__,
@@ -2164,7 +2164,7 @@ static int deserialize_and_upgrade_ftnode(FTNODE node,
const char* fname = toku_cachefile_fname_in_env(bfe->ft->cf);
fprintf(stderr,
"%s:%d:deserialize_and_upgrade_ftnode - "
- "file[%s], blocknum[%ld], "
+ "file[%s], blocknum[%lld], "
"read_and_decompress_block_from_fd_into_rbuf failed with %d\n",
__FILE__,
__LINE__,
@@ -2190,7 +2190,7 @@ static int deserialize_and_upgrade_ftnode(FTNODE node,
const char* fname = toku_cachefile_fname_in_env(bfe->ft->cf);
fprintf(stderr,
"%s:%d:deserialize_and_upgrade_ftnode - "
- "file[%s], blocknum[%ld], version[%d] > "
+ "file[%s], blocknum[%lld], version[%d] > "
"FT_LAYOUT_VERSION_14[%d]\n",
__FILE__,
__LINE__,
@@ -2278,7 +2278,7 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode,
memcmp(magic, "tokunode", 8) != 0) {
fprintf(stderr,
"%s:%d:deserialize_ftnode_from_rbuf - "
- "file[%s], blocknum[%ld], unrecognized magic number "
+ "file[%s], blocknum[%lld], unrecognized magic number "
"%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
__FILE__,
__LINE__,
@@ -2309,7 +2309,7 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode,
if (r != 0) {
fprintf(stderr,
"%s:%d:deserialize_ftnode_from_rbuf - "
- "file[%s], blocknum[%ld], deserialize_and_upgrade_ftnode "
+ "file[%s], blocknum[%lld], deserialize_and_upgrade_ftnode "
"failed with %d\n",
__FILE__,
__LINE__,
@@ -2355,7 +2355,7 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode,
fprintf(
stderr,
"%s:%d:deserialize_ftnode_from_rbuf - "
- "file[%s], blocknum[%ld], stored_checksum[%d] != checksum[%d]\n",
+ "file[%s], blocknum[%lld], stored_checksum[%d] != checksum[%d]\n",
__FILE__,
__LINE__,
fname ? fname : "unknown",
@@ -2377,7 +2377,7 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode,
fprintf(
stderr,
"%s:%d:deserialize_ftnode_from_rbuf - "
- "file[%s], blocknum[%ld], read_and_decompress_sub_block failed "
+ "file[%s], blocknum[%lld], read_and_decompress_sub_block failed "
"with %d\n",
__FILE__,
__LINE__,
@@ -2398,7 +2398,7 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode,
fprintf(
stderr,
"%s:%d:deserialize_ftnode_from_rbuf - "
- "file[%s], blocknum[%ld], deserialize_ftnode_info failed with "
+ "file[%s], blocknum[%lld], deserialize_ftnode_info failed with "
"%d\n",
__FILE__,
__LINE__,
@@ -2470,7 +2470,7 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode,
fprintf(
stderr,
"%s:%d:deserialize_ftnode_from_rbuf - "
- "file[%s], blocknum[%ld], childnum[%d], "
+ "file[%s], blocknum[%lld], childnum[%d], "
"decompress_and_deserialize_worker failed with %d\n",
__FILE__,
__LINE__,
@@ -2490,7 +2490,7 @@ static int deserialize_ftnode_from_rbuf(FTNODE *ftnode,
fprintf(
stderr,
"%s:%d:deserialize_ftnode_from_rbuf - "
- "file[%s], blocknum[%ld], childnum[%d], "
+ "file[%s], blocknum[%lld], childnum[%d], "
"check_and_copy_compressed_sub_block_worker failed with "
"%d\n",
__FILE__,
@@ -2641,7 +2641,7 @@ int toku_deserialize_bp_from_compressed(FTNODE node,
const char* fname = toku_cachefile_fname_in_env(bfe->ft->cf);
fprintf(stderr,
"%s:%d:toku_deserialize_bp_from_compressed - "
- "file[%s], blocknum[%ld], "
+ "file[%s], blocknum[%lld], "
"deserialize_ftnode_partition failed with %d\n",
__FILE__,
__LINE__,
@@ -2689,7 +2689,7 @@ static int deserialize_ftnode_from_fd(int fd,
fprintf(
stderr,
"%s:%d:deserialize_ftnode_from_fd - "
- "file[%s], blocknum[%ld], deserialize_ftnode_from_rbuf failed with "
+ "file[%s], blocknum[%lld], deserialize_ftnode_from_rbuf failed with "
"%d\n",
__FILE__,
__LINE__,
diff --git a/storage/tokudb/PerconaFT/portability/toku_debug_sync.h b/storage/tokudb/PerconaFT/portability/toku_debug_sync.h
index b5394e5..493075c 100644
--- a/storage/tokudb/PerconaFT/portability/toku_debug_sync.h
+++ b/storage/tokudb/PerconaFT/portability/toku_debug_sync.h
@@ -62,9 +62,6 @@ inline void toku_debug_sync(struct tokutxn *txn, const char *sync_point_name) {
void *client_extra;
THD *thd;
- if (likely(!opt_debug_sync_timeout))
- return;
-
toku_txn_get_client_id(txn, &client_id, &client_extra);
thd = reinterpret_cast<THD *>(client_extra);
DEBUG_SYNC(thd, sync_point_name);
diff --git a/storage/tokudb/PerconaFT/portability/toku_pthread.h b/storage/tokudb/PerconaFT/portability/toku_pthread.h
index e3bd3bc..a0dfcc2 100644
--- a/storage/tokudb/PerconaFT/portability/toku_pthread.h
+++ b/storage/tokudb/PerconaFT/portability/toku_pthread.h
@@ -162,10 +162,20 @@ typedef struct toku_mutex_aligned {
#define ZERO_COND_INITIALIZER \
{ 0 }
#elif defined(__APPLE__)
+#if TOKU_PTHREAD_DEBUG
+#define ZERO_COND_INITIALIZER \
+ { \
+ { 0 , { 0 } }, \
+ nullptr, \
+ 0 \
+ }
+#else
#define ZERO_COND_INITIALIZER \
{ \
- { 0 } \
+ { 0 , { 0 } }, \
+ nullptr \
}
+#endif
#else // __linux__, at least
#define ZERO_COND_INITIALIZER \
{}
diff --git a/storage/tokudb/PerconaFT/src/CMakeLists.txt b/storage/tokudb/PerconaFT/src/CMakeLists.txt
index 65bf481..bae3738 100644
--- a/storage/tokudb/PerconaFT/src/CMakeLists.txt
+++ b/storage/tokudb/PerconaFT/src/CMakeLists.txt
@@ -18,7 +18,7 @@ set(tokudb_srcs
## make the shared library
add_library(${LIBTOKUDB} SHARED ${tokudb_srcs})
add_dependencies(${LIBTOKUDB} install_tdb_h generate_log_code)
-target_link_libraries(${LIBTOKUDB} LINK_PRIVATE locktree_static ft_static util_static lzma snappy ${LIBTOKUPORTABILITY})
+target_link_libraries(${LIBTOKUDB} LINK_PRIVATE locktree_static ft_static util_static lzma snappy dbug ${LIBTOKUPORTABILITY})
target_link_libraries(${LIBTOKUDB} LINK_PUBLIC ${ZLIB_LIBRARY} )
## make the static library
diff --git a/storage/tokudb/tokudb_thread.h b/storage/tokudb/tokudb_thread.h
index dec58f3..5df0159 100644
--- a/storage/tokudb/tokudb_thread.h
+++ b/storage/tokudb/tokudb_thread.h
@@ -111,7 +111,6 @@ class event_t {
// wait for the event to become signalled
void wait(void);
- int wait(ulonglong microseconds);
// signal the event
void signal(void);
@@ -152,7 +151,6 @@ class semaphore_t {
// wait for the semaphore to become signalled
E_WAIT wait(void);
- E_WAIT wait(ulonglong microseconds);
// signal the semaphore to increase the count
// return true if signalled, false if ignored due to count
@@ -372,28 +370,6 @@ inline void event_t::wait(void) {
assert_debug(r == 0);
return;
}
-inline int event_t::wait(ulonglong microseconds) {
- timespec waittime = time::offset_timespec(microseconds);
- int r = pthread_mutex_timedlock(&_mutex, &waittime);
- if (r == ETIMEDOUT) return ETIMEDOUT;
- assert_debug(r == 0);
- while (_signalled == false && _pulsed == false) {
- r = pthread_cond_timedwait(&_cond, &_mutex, &waittime);
- if (r == ETIMEDOUT) {
- r = pthread_mutex_unlock(&_mutex);
- assert_debug(r == 0);
- return ETIMEDOUT;
- }
- assert_debug(r == 0);
- }
- if (_manual_reset == false)
- _signalled = false;
- if (_pulsed)
- _pulsed = false;
- r = pthread_mutex_unlock(&_mutex);
- assert_debug(r == 0);
- return 0;
-}
inline void event_t::signal(void) {
int r MY_ATTRIBUTE((unused)) = pthread_mutex_lock(&_mutex);
assert_debug(r == 0);
@@ -479,31 +455,6 @@ inline semaphore_t::E_WAIT semaphore_t::wait(void) {
assert_debug(r == 0);
return ret;
}
-inline semaphore_t::E_WAIT semaphore_t::wait(ulonglong microseconds) {
- E_WAIT ret;
- timespec waittime = time::offset_timespec(microseconds);
- int r = pthread_mutex_timedlock(&_mutex, &waittime);
- if (r == ETIMEDOUT) return E_TIMEDOUT;
- assert_debug(r == 0);
- while (_signalled == 0 && _interrupted == false) {
- r = pthread_cond_timedwait(&_cond, &_mutex, &waittime);
- if (r == ETIMEDOUT) {
- r = pthread_mutex_unlock(&_mutex);
- assert_debug(r == 0);
- return E_TIMEDOUT;
- }
- assert_debug(r == 0);
- }
- if (_interrupted) {
- ret = E_INTERRUPTED;
- } else {
- _signalled--;
- ret = E_SIGNALLED;
- }
- r = pthread_mutex_unlock(&_mutex);
- assert_debug(r == 0);
- return ret;
-}
inline bool semaphore_t::signal(void) {
bool ret = false;
int r MY_ATTRIBUTE((unused)) = pthread_mutex_lock(&_mutex);
1
0
revision-id: afedc29f773362f342756e9cdd9bbd9ed0f1abe2 (mariadb-10.3.6-242-gafedc29)
parent(s): 4ec8598c1dcb63499bce998142b8e5b8b09b2d30
committer: Alexey Botchkov
timestamp: 2018-06-26 14:10:46 +0400
message:
MDEV-14024 PCRE2.
Related changes in the server code.
---
CMakeLists.txt | 2 +-
client/CMakeLists.txt | 2 +-
client/mysqltest.cc | 2 +-
cmake/pcre.cmake | 23 +--
config.h.cmake | 1 +
extra/mariabackup/CMakeLists.txt | 4 +-
extra/mariabackup/xb_regex.h | 2 +-
libmysqld/CMakeLists.txt | 2 +-
libmysqld/examples/CMakeLists.txt | 2 +-
mysql-test/main/func_regexp_pcre.test | 1 +
sql/CMakeLists.txt | 2 +-
sql/item_cmpfunc.cc | 164 +++++----------------
sql/item_cmpfunc.h | 32 ++--
sql/item_strfunc.cc | 14 --
sql/item_strfunc.h | 2 -
sql/mysqld.cc | 16 --
sql/mysqld.h | 2 -
sql/sys_vars.cc | 16 +-
storage/mroonga/CMakeLists.txt | 6 +-
storage/mroonga/configure.ac | 6 +-
storage/mroonga/vendor/groonga/configure.ac | 29 ----
.../mroonga/vendor/groonga/tools/travis-install.sh | 1 -
.../cmake_modules/TokuFeatureDetection.cmake | 4 +-
23 files changed, 83 insertions(+), 252 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 52f511e..37e0cdf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -321,7 +321,7 @@ IF(NOT HAVE_CXX_NEW)
ENDIF()
# Find header files from the bundled libraries
-# (yassl, readline, pcre, etc)
+# (yassl, readline, pcre2, etc)
# before the ones installed in the system
SET(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index e0d34b9..02579ca 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -45,7 +45,7 @@ ENDIF(UNIX)
MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc COMPONENT Test)
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
-TARGET_LINK_LIBRARIES(mysqltest ${CLIENT_LIB} pcre pcreposix)
+TARGET_LINK_LIBRARIES(mysqltest ${CLIENT_LIB} pcre2-8 pcre2-posix)
SET_TARGET_PROPERTIES(mysqltest PROPERTIES ENABLE_EXPORTS TRUE)
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index f26ea99..42afaa1 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -45,7 +45,7 @@
#include <stdarg.h>
#include <violite.h>
#define PCRE_STATIC 1 /* Important on Windows */
-#include "pcreposix.h" /* pcreposix regex library */
+#include "pcre2posix.h" /* pcre2posix regex library */
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake
index 4c11392..264f93a 100644
--- a/cmake/pcre.cmake
+++ b/cmake/pcre.cmake
@@ -5,24 +5,17 @@ SET(WITH_PCRE "auto" CACHE STRING
MACRO (CHECK_PCRE)
IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto")
- CHECK_LIBRARY_EXISTS(pcre pcre_stack_guard "" HAVE_PCRE_STACK_GUARD)
- IF(NOT CMAKE_CROSSCOMPILING)
- SET(CMAKE_REQUIRED_LIBRARIES "pcre")
- CHECK_C_SOURCE_RUNS("
- #include <pcre.h>
- int main() {
- return -pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0) < 256;
- }" PCRE_STACK_SIZE_OK)
- SET(CMAKE_REQUIRED_LIBRARIES)
- ENDIF()
+ CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match "" HAVE_PCRE2)
ENDIF()
- IF(NOT HAVE_PCRE_STACK_GUARD OR NOT PCRE_STACK_SIZE_OK OR
- WITH_PCRE STREQUAL "bundled")
+ IF(NOT HAVE_PCRE2 OR WITH_PCRE STREQUAL "bundled")
IF (WITH_PCRE STREQUAL "system")
- MESSAGE(FATAL_ERROR "system pcre is not found or unusable")
+ MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable")
ENDIF()
- SET(PCRE_INCLUDES ${CMAKE_BINARY_DIR}/pcre ${CMAKE_SOURCE_DIR}/pcre)
- ADD_SUBDIRECTORY(pcre)
+ SET(PCRE_INCLUDES ${CMAKE_BINARY_DIR}/pcre2 ${CMAKE_SOURCE_DIR}/pcre2
+ ${CMAKE_BINARY_DIR}/pcre2/src ${CMAKE_SOURCE_DIR}/pcre2/src)
+ SET(PCRE_BUILD_TESTS OFF CACHE BOOL "Disable tests.")
+ SET(PCRE2_BUILD_PCRE2GREP OFF CACHE BOOL "Disable pcre2grep")
+ ADD_SUBDIRECTORY(pcre2)
ENDIF()
ENDMACRO()
diff --git a/config.h.cmake b/config.h.cmake
index 0a4007d..cb9d767 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -552,6 +552,7 @@
#define PACKAGE_VERSION "@VERSION@"
#define VERSION "@VERSION@"
#define PROTOCOL_VERSION 10
+#define PCRE2_CODE_UNIT_WIDTH 8
#define MALLOC_LIBRARY "@MALLOC_LIBRARY@"
diff --git a/extra/mariabackup/CMakeLists.txt b/extra/mariabackup/CMakeLists.txt
index 7df5fa1..a9d7153 100644
--- a/extra/mariabackup/CMakeLists.txt
+++ b/extra/mariabackup/CMakeLists.txt
@@ -37,7 +37,7 @@ INCLUDE_DIRECTORIES(
)
IF(NOT HAVE_SYSTEM_REGEX)
- INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/pcre)
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/pcre2 ${CMAKE_SOURCE_DIR}/pcre2/src)
ENDIF()
IF(WITH_WSREP)
@@ -92,7 +92,7 @@ ADD_SUBDIRECTORY(crc)
TARGET_LINK_LIBRARIES(mariabackup sql crc)
IF(NOT HAVE_SYSTEM_REGEX)
- TARGET_LINK_LIBRARIES(mariabackup pcreposix)
+ TARGET_LINK_LIBRARIES(mariabackup pcre2-posix)
ENDIF()
diff --git a/extra/mariabackup/xb_regex.h b/extra/mariabackup/xb_regex.h
index 2e07e43..6277d04 100644
--- a/extra/mariabackup/xb_regex.h
+++ b/extra/mariabackup/xb_regex.h
@@ -25,7 +25,7 @@ my_regex is used on Windows and native calls are used on POSIX platforms. */
#ifdef HAVE_SYSTEM_REGEX
#include <regex.h>
#else
-#include <pcreposix.h>
+#include <pcre2posix.h>
#endif
typedef regex_t* xb_regex_t;
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index fe20a03..a7d1c71 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -144,7 +144,7 @@ ENDIF()
SET(LIBS
- dbug strings mysys mysys_ssl pcre vio
+ dbug strings mysys mysys_ssl pcre2-8 vio
${ZLIB_LIBRARY} ${SSL_LIBRARIES}
${LIBWRAP} ${LIBCRYPT} ${LIBDL}
${MYSQLD_STATIC_PLUGIN_LIBS}
diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt
index d47638a..c2f7766 100644
--- a/libmysqld/examples/CMakeLists.txt
+++ b/libmysqld/examples/CMakeLists.txt
@@ -34,7 +34,7 @@ ENDIF(UNIX)
MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc
COMPONENT Test)
-TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver pcre pcreposix)
+TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver pcre2-8 pcre2-posix)
IF(CMAKE_GENERATOR MATCHES "Xcode")
# It does not seem possible to tell Xcode the resulting target might need
diff --git a/mysql-test/main/func_regexp_pcre.test b/mysql-test/main/func_regexp_pcre.test
index 2160039..30969b3 100644
--- a/mysql-test/main/func_regexp_pcre.test
+++ b/mysql-test/main/func_regexp_pcre.test
@@ -382,6 +382,7 @@ SELECT 'AB' RLIKE 'A B';
SELECT 'AB' RLIKE 'A# this is a comment\nB';
SET default_regex_flags=DEFAULT;
+--error ER_REGEXP_ERROR
SELECT 'Aq' RLIKE 'A\\q';
SET default_regex_flags='EXTRA';
--error ER_REGEXP_ERROR
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 7253f7b..7a26842 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -176,7 +176,7 @@ ADD_LIBRARY(sql STATIC ${SQL_SOURCE})
ADD_DEPENDENCIES(sql GenServerSource)
DTRACE_INSTRUMENT(sql)
TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
- mysys mysys_ssl dbug strings vio pcre
+ mysys mysys_ssl dbug strings vio pcre2-8
${LIBWRAP} ${LIBCRYPT} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT}
${WSREP_LIB}
${SSL_LIBRARIES}
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 76f4788..450a9c5 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -5396,15 +5396,6 @@ int Regexp_processor_pcre::default_regex_flags()
return default_regex_flags_pcre(current_thd);
}
-void Regexp_processor_pcre::set_recursion_limit(THD *thd)
-{
- long stack_used;
- DBUG_ASSERT(thd == current_thd);
- stack_used= available_stack_size(thd->thread_stack, &stack_used);
- m_pcre_extra.match_limit_recursion=
- (ulong)((my_thread_stack_size - STACK_MIN_SIZE - stack_used)/my_pcre_frame_size);
-}
-
/**
Convert string to lib_charset, if needed.
@@ -5438,8 +5429,8 @@ String *Regexp_processor_pcre::convert_if_needed(String *str, String *converter)
bool Regexp_processor_pcre::compile(String *pattern, bool send_error)
{
- const char *pcreErrorStr;
- int pcreErrorOffset;
+ int pcreErrorNumber;
+ PCRE2_SIZE pcreErrorOffset;
if (is_compiled())
{
@@ -5452,19 +5443,29 @@ bool Regexp_processor_pcre::compile(String *pattern, bool send_error)
if (!(pattern= convert_if_needed(pattern, &pattern_converter)))
return true;
- m_pcre= pcre_compile(pattern->c_ptr_safe(), m_library_flags,
- &pcreErrorStr, &pcreErrorOffset, NULL);
-
+ m_pcre= pcre2_compile((PCRE2_SPTR8) pattern->ptr(), pattern->length(),
+ m_library_flags,
+ &pcreErrorNumber, &pcreErrorOffset, NULL);
if (unlikely(m_pcre == NULL))
{
if (send_error)
{
char buff[MAX_FIELD_WIDTH];
- my_snprintf(buff, sizeof(buff), "%s at offset %d", pcreErrorStr, pcreErrorOffset);
+ int lmsg= pcre2_get_error_message(pcreErrorNumber,
+ (PCRE2_UCHAR8 *)buff, sizeof(buff));
+ if (lmsg >= 0)
+ my_snprintf(buff+lmsg, sizeof(buff)-lmsg,
+ " at offset %d", pcreErrorOffset);
my_error(ER_REGEXP_ERROR, MYF(0), buff);
}
return true;
}
+ m_pcre_match_data= pcre2_match_data_create_from_pattern(m_pcre, NULL);
+ if (m_pcre_match_data == NULL)
+ {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0));
+ return true;
+ }
return false;
}
@@ -5485,124 +5486,44 @@ bool Regexp_processor_pcre::compile(Item *item, bool send_error)
*/
void Regexp_processor_pcre::pcre_exec_warn(int rc) const
{
- char buf[64];
- const char *errmsg= NULL;
+ PCRE2_UCHAR8 buf[128];
THD *thd= current_thd;
- /*
- Make a descriptive message only for those pcre_exec() error codes
- that can actually happen in MariaDB.
- */
- switch (rc)
+ int errlen= pcre2_get_error_message(rc, buf, sizeof(buf));
+ if (errlen <= 0)
{
- case PCRE_ERROR_NULL:
- errmsg= "pcre_exec: null argument passed";
- break;
- case PCRE_ERROR_BADOPTION:
- errmsg= "pcre_exec: bad option";
- break;
- case PCRE_ERROR_BADMAGIC:
- errmsg= "pcre_exec: bad magic - not a compiled regex";
- break;
- case PCRE_ERROR_UNKNOWN_OPCODE:
- errmsg= "pcre_exec: error in compiled regex";
- break;
- case PCRE_ERROR_NOMEMORY:
- errmsg= "pcre_exec: Out of memory";
- break;
- case PCRE_ERROR_NOSUBSTRING:
- errmsg= "pcre_exec: no substring";
- break;
- case PCRE_ERROR_MATCHLIMIT:
- errmsg= "pcre_exec: match limit exceeded";
- break;
- case PCRE_ERROR_CALLOUT:
- errmsg= "pcre_exec: callout error";
- break;
- case PCRE_ERROR_BADUTF8:
- errmsg= "pcre_exec: Invalid utf8 byte sequence in the subject string";
- break;
- case PCRE_ERROR_BADUTF8_OFFSET:
- errmsg= "pcre_exec: Started at invalid location within utf8 byte sequence";
- break;
- case PCRE_ERROR_PARTIAL:
- errmsg= "pcre_exec: partial match";
- break;
- case PCRE_ERROR_INTERNAL:
- errmsg= "pcre_exec: internal error";
- break;
- case PCRE_ERROR_BADCOUNT:
- errmsg= "pcre_exec: ovesize is negative";
- break;
- case PCRE_ERROR_RECURSIONLIMIT:
- my_snprintf(buf, sizeof(buf), "pcre_exec: recursion limit of %ld exceeded",
- m_pcre_extra.match_limit_recursion);
- errmsg= buf;
- break;
- case PCRE_ERROR_BADNEWLINE:
- errmsg= "pcre_exec: bad newline options";
- break;
- case PCRE_ERROR_BADOFFSET:
- errmsg= "pcre_exec: start offset negative or greater than string length";
- break;
- case PCRE_ERROR_SHORTUTF8:
- errmsg= "pcre_exec: ended in middle of utf8 sequence";
- break;
- case PCRE_ERROR_JIT_STACKLIMIT:
- errmsg= "pcre_exec: insufficient stack memory for JIT compile";
- break;
- case PCRE_ERROR_RECURSELOOP:
- errmsg= "pcre_exec: Recursion loop detected";
- break;
- case PCRE_ERROR_BADMODE:
- errmsg= "pcre_exec: compiled pattern passed to wrong bit library function";
- break;
- case PCRE_ERROR_BADENDIANNESS:
- errmsg= "pcre_exec: compiled pattern passed to wrong endianness processor";
- break;
- case PCRE_ERROR_JIT_BADOPTION:
- errmsg= "pcre_exec: bad jit option";
- break;
- case PCRE_ERROR_BADLENGTH:
- errmsg= "pcre_exec: negative length";
- break;
- default:
- /*
- As other error codes should normally not happen,
- we just report the error code without textual description
- of the code.
- */
- my_snprintf(buf, sizeof(buf), "pcre_exec: Internal error (%d)", rc);
- errmsg= buf;
+ my_snprintf((char *)buf, sizeof(buf), "pcre_exec: Internal error (%d)", rc);
}
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
- ER_REGEXP_ERROR, ER_THD(thd, ER_REGEXP_ERROR), errmsg);
+ ER_REGEXP_ERROR, ER_THD(thd, ER_REGEXP_ERROR), buf);
}
/**
Call pcre_exec() and send a warning if pcre_exec() returned with an error.
*/
-int Regexp_processor_pcre::pcre_exec_with_warn(const pcre *code,
- const pcre_extra *extra,
+int Regexp_processor_pcre::pcre_exec_with_warn(const pcre2_code *code,
+ pcre2_match_data *data,
const char *subject,
int length, int startoffset,
- int options, int *ovector,
- int ovecsize)
+ uint options)
{
- int rc= pcre_exec(code, extra, subject, length,
- startoffset, options, ovector, ovecsize);
+ int rc= pcre2_match(code, (PCRE2_SPTR8) subject, (PCRE2_SIZE) length,
+ (PCRE2_SIZE) startoffset, options, data, NULL);
DBUG_EXECUTE_IF("pcre_exec_error_123", rc= -123;);
- if (unlikely(rc < PCRE_ERROR_NOMATCH))
- pcre_exec_warn(rc);
+ if (unlikely(rc < PCRE2_ERROR_NOMATCH))
+ m_SubStrVec= NULL;
+ else
+ m_SubStrVec= pcre2_get_ovector_pointer(data);
+
return rc;
}
bool Regexp_processor_pcre::exec(const char *str, size_t length, size_t offset)
{
- m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, &m_pcre_extra, str, (int)length, (int)offset, 0,
- m_SubStrVec, array_elements(m_SubStrVec));
+ m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, m_pcre_match_data,
+ str, (int)length, (int)offset, 0);
return false;
}
@@ -5612,10 +5533,8 @@ bool Regexp_processor_pcre::exec(String *str, int offset,
{
if (!(str= convert_if_needed(str, &subject_converter)))
return true;
- m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, &m_pcre_extra,
- str->c_ptr_safe(), str->length(),
- offset, 0,
- m_SubStrVec, array_elements(m_SubStrVec));
+ m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, m_pcre_match_data,
+ str->ptr(), str->length(), offset, 0);
if (m_pcre_exec_rc > 0)
{
uint i;
@@ -5665,12 +5584,6 @@ void Regexp_processor_pcre::fix_owner(Item_func *owner,
}
-bool Item_func_regex::fix_fields(THD *thd, Item **ref)
-{
- re.set_recursion_limit(thd);
- return Item_bool_func::fix_fields(thd, ref);
-}
-
void
Item_func_regex::fix_length_and_dec()
{
@@ -5697,13 +5610,6 @@ longlong Item_func_regex::val_int()
}
-bool Item_func_regexp_instr::fix_fields(THD *thd, Item **ref)
-{
- re.set_recursion_limit(thd);
- return Item_int_func::fix_fields(thd, ref);
-}
-
-
void
Item_func_regexp_instr::fix_length_and_dec()
{
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 30d682f..5fa2677 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -25,7 +25,7 @@
#include "item_func.h" /* Item_int_func, Item_bool_func */
#define PCRE_STATIC 1 /* Important on Windows */
-#include "pcre.h" /* pcre header file */
+#include "pcre2.h" /* pcre header file */
#include "item.h"
extern Item_result item_cmp_type(Item_result a,Item_result b);
@@ -2715,8 +2715,8 @@ class Item_func_like :public Item_bool_func2
class Regexp_processor_pcre
{
- pcre *m_pcre;
- pcre_extra m_pcre_extra;
+ pcre2_code *m_pcre;
+ pcre2_match_data *m_pcre_match_data;
bool m_conversion_is_needed;
bool m_is_const;
int m_library_flags;
@@ -2724,34 +2724,32 @@ class Regexp_processor_pcre
CHARSET_INFO *m_library_charset;
String m_prev_pattern;
int m_pcre_exec_rc;
- int m_SubStrVec[30];
+ PCRE2_SIZE *m_SubStrVec;
void pcre_exec_warn(int rc) const;
- int pcre_exec_with_warn(const pcre *code, const pcre_extra *extra,
+ int pcre_exec_with_warn(const pcre2_code *code,
+ pcre2_match_data *data,
const char *subject, int length, int startoffset,
- int options, int *ovector, int ovecsize);
+ uint options);
public:
String *convert_if_needed(String *src, String *converter);
String subject_converter;
String pattern_converter;
String replace_converter;
Regexp_processor_pcre() :
- m_pcre(NULL), m_conversion_is_needed(true), m_is_const(0),
+ m_pcre(NULL), m_pcre_match_data(NULL),
+ m_conversion_is_needed(true), m_is_const(0),
m_library_flags(0),
m_data_charset(&my_charset_utf8_general_ci),
m_library_charset(&my_charset_utf8_general_ci)
- {
- m_pcre_extra.flags= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
- m_pcre_extra.match_limit_recursion= 100L;
- }
+ {}
int default_regex_flags();
- void set_recursion_limit(THD *);
void init(CHARSET_INFO *data_charset, int extra_flags)
{
m_library_flags= default_regex_flags() | extra_flags |
(data_charset != &my_charset_bin ?
- (PCRE_UTF8 | PCRE_UCP) : 0) |
+ (PCRE2_UTF | PCRE2_UCP) : 0) |
((data_charset->state &
- (MY_CS_BINSORT | MY_CS_CSSORT)) ? 0 : PCRE_CASELESS);
+ (MY_CS_BINSORT | MY_CS_CSSORT)) ? 0 : PCRE2_CASELESS);
// Convert text data to utf-8.
m_library_charset= data_charset == &my_charset_bin ?
@@ -2787,11 +2785,13 @@ class Regexp_processor_pcre
void reset()
{
m_pcre= NULL;
+ m_pcre_match_data= NULL;
m_prev_pattern.length(0);
}
void cleanup()
{
- pcre_free(m_pcre);
+ pcre2_match_data_free(m_pcre_match_data);
+ pcre2_code_free(m_pcre);
reset();
}
bool is_compiled() const { return m_pcre != NULL; }
@@ -2816,7 +2816,6 @@ class Item_func_regex :public Item_bool_func
DBUG_VOID_RETURN;
}
longlong val_int();
- bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
const char *func_name() const { return "regexp"; }
enum precedence precedence() const { return CMP_PRECEDENCE; }
@@ -2866,7 +2865,6 @@ class Item_func_regexp_instr :public Item_long_func
DBUG_VOID_RETURN;
}
longlong val_int();
- bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
const char *func_name() const { return "regexp_instr"; }
Item *get_copy(THD *thd)
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index d5911e0..926d2b9 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1276,13 +1276,6 @@ void Item_func_replace::fix_length_and_dec()
/*********************************************************************/
-bool Item_func_regexp_replace::fix_fields(THD *thd, Item **ref)
-{
- re.set_recursion_limit(thd);
- return Item_str_func::fix_fields(thd, ref);
-}
-
-
void Item_func_regexp_replace::fix_length_and_dec()
{
if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 3))
@@ -1418,13 +1411,6 @@ String *Item_func_regexp_replace::val_str(String *str)
}
-bool Item_func_regexp_substr::fix_fields(THD *thd, Item **ref)
-{
- re.set_recursion_limit(thd);
- return Item_str_func::fix_fields(thd, ref);
-}
-
-
void Item_func_regexp_substr::fix_length_and_dec()
{
if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 2))
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index eb084c3..85811f4 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -377,7 +377,6 @@ class Item_func_regexp_replace :public Item_str_func
DBUG_VOID_RETURN;
}
String *val_str(String *str);
- bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
const char *func_name() const { return "regexp_replace"; }
Item *get_copy(THD *thd) { return 0;}
@@ -399,7 +398,6 @@ class Item_func_regexp_substr :public Item_str_func
DBUG_VOID_RETURN;
}
String *val_str(String *str);
- bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
const char *func_name() const { return "regexp_substr"; }
Item *get_copy(THD *thd) { return 0; }
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index dd79cb3..96caee0 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -111,7 +111,6 @@
#include "sp_rcontext.h"
#include "sp_cache.h"
#include "sql_reload.h" // reload_acl_and_cache
-#include "pcre.h"
#ifdef HAVE_POLL_H
#include <poll.h>
@@ -3760,20 +3759,6 @@ static void init_libstrings()
#endif
}
-ulonglong my_pcre_frame_size;
-
-static void init_pcre()
-{
- pcre_malloc= pcre_stack_malloc= my_str_malloc_mysqld;
- pcre_free= pcre_stack_free= my_free;
- pcre_stack_guard= check_enough_stack_size_slow;
- /* See http://pcre.org/original/doc/html/pcrestack.html */
- my_pcre_frame_size= -pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0);
- // pcre can underestimate its stack usage. Use a safe value, as in the manual
- set_if_bigger(my_pcre_frame_size, 500);
- my_pcre_frame_size += 16; // Again, safety margin, see the manual
-}
-
/**
Initialize one of the global date/time format variables.
@@ -4576,7 +4561,6 @@ static int init_common_variables()
if (item_create_init())
return 1;
item_init();
- init_pcre();
/*
Process a comma-separated character set list and choose
the first available character set. This is mostly for
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 4a392ea..25d9a57 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -574,8 +574,6 @@ extern pthread_t signal_thread;
extern struct st_VioSSLFd * ssl_acceptor_fd;
#endif /* HAVE_OPENSSL */
-extern ulonglong my_pcre_frame_size;
-
/*
The following variables were under INNODB_COMPABILITY_HOOKS
*/
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index ccb7d3b..e8abae3 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -5692,19 +5692,21 @@ static const char *default_regex_flags_names[]=
"DOTALL", // (?s) . matches anything including NL
"DUPNAMES", // (?J) Allow duplicate names for subpatterns
"EXTENDED", // (?x) Ignore white space and # comments
- "EXTRA", // (?X) extra features (e.g. error on unknown escape character)
+ "EXTENDED_MORE",//(?xx) Ignore white space and # comments inside cheracter
+ "EXTRA", // means nothing since PCRE2
"MULTILINE", // (?m) ^ and $ match newlines within data
"UNGREEDY", // (?U) Invert greediness of quantifiers
0
};
static const int default_regex_flags_to_pcre[]=
{
- PCRE_DOTALL,
- PCRE_DUPNAMES,
- PCRE_EXTENDED,
- PCRE_EXTRA,
- PCRE_MULTILINE,
- PCRE_UNGREEDY,
+ PCRE2_DOTALL,
+ PCRE2_DUPNAMES,
+ PCRE2_EXTENDED,
+ PCRE2_EXTENDED_MORE,
+ 0, /* EXTRA flag not available since PCRE2 */
+ PCRE2_MULTILINE,
+ PCRE2_UNGREEDY,
0
};
int default_regex_flags_pcre(const THD *thd)
diff --git a/storage/mroonga/CMakeLists.txt b/storage/mroonga/CMakeLists.txt
index 5a7d469..d321b7d 100644
--- a/storage/mroonga/CMakeLists.txt
+++ b/storage/mroonga/CMakeLists.txt
@@ -189,11 +189,7 @@ else()
set(MYSQL_VARIANT "MySQL")
endif()
-if(EXISTS "${MYSQL_SOURCE_DIR}/pcre")
- set(MYSQL_REGEX_INCLUDE_DIR "${MYSQL_SOURCE_DIR}/pcre")
-else()
- set(MYSQL_REGEX_INCLUDE_DIR "${MYSQL_SOURCE_DIR}/regex")
-endif()
+set(MYSQL_REGEX_INCLUDE_DIR "${MYSQL_SOURCE_DIR}/regex")
if(EXISTS "${MYSQL_SOURCE_DIR}/extra/rapidjson")
set(MYSQL_RAPIDJSON_INCLUDE_DIR "${MYSQL_SOURCE_DIR}/extra/rapidjson/include")
diff --git a/storage/mroonga/configure.ac b/storage/mroonga/configure.ac
index b1e6690..3ef31bd 100644
--- a/storage/mroonga/configure.ac
+++ b/storage/mroonga/configure.ac
@@ -186,11 +186,7 @@ AC_DEFUN([CONFIG_OPTION_MYSQL],[
mysql_regex_include_dir="$ac_mysql_source_dir/extra/regex"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$mysql_regex_include_dir"
else
- if test -d "$ac_mysql_source_dir/pcre"; then
- mysql_regex_include_dir="$ac_mysql_source_dir/pcre"
- else
- mysql_regex_include_dir="$ac_mysql_source_dir/regex"
- fi
+ mysql_regex_include_dir="$ac_mysql_source_dir/regex"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$mysql_regex_include_dir"
fi
if test -d "$ac_mysql_source_dir/libbinlogevents"; then
diff --git a/storage/mroonga/vendor/groonga/configure.ac b/storage/mroonga/vendor/groonga/configure.ac
index 414876c..cab122a 100644
--- a/storage/mroonga/vendor/groonga/configure.ac
+++ b/storage/mroonga/vendor/groonga/configure.ac
@@ -1613,30 +1613,6 @@ AC_SUBST(ONIGMO_CFLAGS)
AC_SUBST(ONIGMO_LIBS)
AM_CONDITIONAL(WITH_BUNDLED_ONIGMO, test "$with_onigmo" != "no" -a "x$have_onigmo" != "xyes")
-# PCRE
-GRN_WITH_PCRE=no
-AC_ARG_WITH(pcre,
- [AS_HELP_STRING([--without-pcre],
- [Don't use PCRE for groonga-httpd. [default=auto-detect]])],
- [with_pcre="$withval"],
- [with_pcre="auto"])
-if test "x$with_pcre" != "xno"; then
- m4_ifdef([PKG_CHECK_MODULES], [
- PKG_CHECK_MODULES([PCRE], [libpcre],
- [_PKG_CONFIG(PCRE_LIBS_ONLY_L, [libs-only-L], [libpcre])
- PCRE_LIBS_ONLY_L="$pkg_cv_PCRE_LIBS_ONLY_L"
- GRN_WITH_PCRE=yes],
- [GRN_WITH_PCRE=no])
- ],
- [GRN_WITH_PCRE=no])
- if test "x$with_pcre" = "xyes" -a "$GRN_WITH_PCRE" != "yes"; then
- AC_MSG_ERROR("No PCRE found")
- fi
-fi
-AC_SUBST(GRN_WITH_PCRE)
-AC_SUBST(PCRE_CFLAGS)
-AC_SUBST(PCRE_LIBS_ONLY_L)
-
# SSL
GRN_WITH_SSL=no
AC_ARG_WITH(ssl,
@@ -1788,11 +1764,6 @@ echo "groonga-httpd:"
echo " enable: $enable_groonga_httpd"
if test "$enable_groonga_httpd" = "yes"; then
echo " default database path: $GROONGA_HTTPD_DEFAULT_DATABASE_PATH"
- echo " PCRE: $GRN_WITH_PCRE"
- if test "$GRN_WITH_PCRE" = "yes"; then
- echo " CFLAGS: $PCRE_CFLAGS"
- echo " LIBS only -L: $PCRE_LIBS_ONLY_L"
- fi
echo " SSL: $GRN_WITH_SSL"
if test "$GRN_WITH_SSL" = "yes"; then
echo " CFLAGS: $SSL_CFLAGS"
diff --git a/storage/mroonga/vendor/groonga/tools/travis-install.sh b/storage/mroonga/vendor/groonga/tools/travis-install.sh
index 72240ec..d7ac400 100755
--- a/storage/mroonga/vendor/groonga/tools/travis-install.sh
+++ b/storage/mroonga/vendor/groonga/tools/travis-install.sh
@@ -23,7 +23,6 @@ case "${TRAVIS_OS_NAME}" in
brew outdated pkg-config || brew upgrade pkg-config
brew reinstall libtool
brew outdated libevent || brew upgrade libevent
- brew outdated pcre || brew upgrade pcre
brew install \
autoconf-archive \
msgpack \
diff --git a/storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake b/storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake
index 2f04a33..51257fe 100644
--- a/storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake
+++ b/storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake
@@ -1,6 +1,8 @@
## feature detection
find_package(Threads)
-find_package(ZLIB REQUIRED)
+IF(WITH_EXTERNAL_ZLIB)
+ find_package(ZLIB REQUIRED)
+ENDIF()
option(USE_VALGRIND "Build to run safely under valgrind (often slower)." ON)
if(USE_VALGRIND)
1
0

[Commits] 44692f17a62: MDEV-15436: If log_bin and log_bin_index is different SST with rsync fails.
by jan 26 Jun '18
by jan 26 Jun '18
26 Jun '18
revision-id: 44692f17a621d7f0261d84b97a7334352463038c (mariadb-10.2.15-101-g44692f17a62)
parent(s): 7d0d934ca642e485b2c008727dc20c83e26cce10
author: Jan Lindström
committer: Jan Lindström
timestamp: 2018-06-26 12:56:19 +0300
message:
MDEV-15436: If log_bin and log_bin_index is different SST with rsync fails.
Problem was that in SST log_bin_index name and directory was not
handled and passed to rsync SST script.
wsrep_sst_common.sh
Read binlog index dirname and filename if --binlog-index
parameter is provided. Read binlog filenames from that file
from donor and write transfered binlog filenames to that
file in joiner.
mysqld.cc, mysqld.h
Moved opt_binlog_index_name from static to global and added
it to extern.
wsrep_sst.cc
generate_binlog_index_opt_val
New function to generate binlog index name if opt_binlog_index_name is
given on configuration.
sst_prepare_other
Add binlog index configuration to SST command.
wsrep_sst.h
Add new SST parameter --binlog-index
Add test case.
---
mysql-test/suite/galera/r/galera_sst_rsync2.result | 396 +++++++++++++++++++++
mysql-test/suite/galera/t/galera_sst_rsync2.cnf | 15 +
mysql-test/suite/galera/t/galera_sst_rsync2.test | 12 +
scripts/wsrep_sst_common.sh | 6 +
scripts/wsrep_sst_rsync.sh | 22 +-
sql/mysqld.cc | 2 +-
sql/mysqld.h | 1 +
sql/wsrep_sst.cc | 33 +-
sql/wsrep_sst.h | 1 +
9 files changed, 483 insertions(+), 5 deletions(-)
diff --git a/mysql-test/suite/galera/r/galera_sst_rsync2.result b/mysql-test/suite/galera/r/galera_sst_rsync2.result
new file mode 100644
index 00000000000..d5c6a11f61f
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_sst_rsync2.result
@@ -0,0 +1,396 @@
+connection node_1;
+connection node_2;
+Performing State Transfer on a server that has been shut down cleanly and restarted
+connection node_1;
+CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+COMMIT;
+connection node_2;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+COMMIT;
+Shutting down server ...
+connection node_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+connect node_1a_galera_st_shutdown_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+connection node_2;
+Starting server ...
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+COMMIT;
+connection node_1;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+COMMIT;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+COMMIT;
+connection node_1a_galera_st_shutdown_slave;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+ROLLBACK;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+COMMIT;
+SET AUTOCOMMIT=ON;
+connection node_1;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+DROP TABLE t1;
+COMMIT;
+SET AUTOCOMMIT=ON;
+Performing State Transfer on a server that starts from a clean var directory
+This is accomplished by shutting down node #2 and removing its var directory before restarting it
+connection node_1;
+CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+COMMIT;
+connection node_2;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+COMMIT;
+Shutting down server ...
+connection node_1;
+Cleaning var directory ...
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+connect node_1a_galera_st_clean_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+connection node_2;
+Starting server ...
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+COMMIT;
+connection node_1;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+COMMIT;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+COMMIT;
+connection node_1a_galera_st_clean_slave;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+ROLLBACK;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+COMMIT;
+SET AUTOCOMMIT=ON;
+connection node_1;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+DROP TABLE t1;
+COMMIT;
+SET AUTOCOMMIT=ON;
+Performing State Transfer on a server that has been killed and restarted
+connection node_1;
+CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+COMMIT;
+connection node_2;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+COMMIT;
+Killing server ...
+connection node_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+INSERT INTO t1 VALUES ('node1_committed_during');
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+connect node_1a_galera_st_kill_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+connection node_2;
+Performing --wsrep-recover ...
+Starting server ...
+Using --wsrep-start-position when starting mysqld ...
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+INSERT INTO t1 VALUES ('node2_committed_after');
+COMMIT;
+connection node_1;
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 VALUES ('node1_to_be_committed_after');
+COMMIT;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+INSERT INTO t1 VALUES ('node1_committed_after');
+COMMIT;
+connection node_1a_galera_st_kill_slave;
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
+ROLLBACK;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+COMMIT;
+SET AUTOCOMMIT=ON;
+connection node_1;
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+DROP TABLE t1;
+COMMIT;
+SET AUTOCOMMIT=ON;
+Performing State Transfer on a server that has been killed and restarted
+while a DDL was in progress on it
+connection node_1;
+CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before');
+connection node_2;
+START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before');
+COMMIT;
+SET GLOBAL debug_dbug = 'd,sync.alter_opened_table';
+connection node_1;
+ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+connection node_2;
+SET wsrep_sync_wait = 0;
+Killing server ...
+connection node_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+INSERT INTO t1 (f1) VALUES ('node1_committed_during');
+COMMIT;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+connect node_1a_galera_st_kill_slave_ddl, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+connection node_2;
+Performing --wsrep-recover ...
+connection node_2;
+Starting server ...
+Using --wsrep-start-position when starting mysqld ...
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+COMMIT;
+connection node_1;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+COMMIT;
+SET AUTOCOMMIT=OFF;
+START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+COMMIT;
+connection node_1a_galera_st_kill_slave_ddl;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+ROLLBACK;
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+COUNT(*) = 2
+1
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+COMMIT;
+SET AUTOCOMMIT=ON;
+connection node_1;
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+COUNT(*) = 2
+1
+SELECT COUNT(*) = 35 FROM t1;
+COUNT(*) = 35
+1
+SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
+COUNT(*) = 0
+1
+DROP TABLE t1;
+COMMIT;
+SET AUTOCOMMIT=ON;
+SET GLOBAL debug_dbug = $debug_orig;
diff --git a/mysql-test/suite/galera/t/galera_sst_rsync2.cnf b/mysql-test/suite/galera/t/galera_sst_rsync2.cnf
new file mode 100644
index 00000000000..deac8f348c2
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_sst_rsync2.cnf
@@ -0,0 +1,15 @@
+!include ../galera_2nodes.cnf
+
+[mysqld]
+wsrep_sst_method=rsync
+
+[mysqld.1]
+wsrep_provider_options='base_port=(a)mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true'
+log_bin = server1_binlog
+log_bin_index = server1_binlog_index.index
+
+[mysqld.2]
+wsrep_provider_options='base_port=(a)mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'
+log_bin = server2_binlog
+log_bin_index = server2_binlog_index.index
+
diff --git a/mysql-test/suite/galera/t/galera_sst_rsync2.test b/mysql-test/suite/galera/t/galera_sst_rsync2.test
new file mode 100644
index 00000000000..f796356cac7
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_sst_rsync2.test
@@ -0,0 +1,12 @@
+--source include/galera_cluster.inc
+
+--let $node_1=node_1
+--let $node_2=node_2
+--source include/auto_increment_offset_save.inc
+
+--source suite/galera/include/galera_st_shutdown_slave.inc
+--source suite/galera/include/galera_st_clean_slave.inc
+
+--source suite/galera/include/galera_st_kill_slave.inc
+--source suite/galera/include/galera_st_kill_slave_ddl.inc
+--source include/auto_increment_offset_restore.inc
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh
index 3367f3e244e..e9cc4b72359 100644
--- a/scripts/wsrep_sst_common.sh
+++ b/scripts/wsrep_sst_common.sh
@@ -20,6 +20,7 @@ set -u
WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_BINLOG=""
+WSREP_SST_OPT_BINLOG_INDEX=""
WSREP_SST_OPT_DATA=""
WSREP_SST_OPT_AUTH=${WSREP_SST_OPT_AUTH:-}
WSREP_SST_OPT_USER=${WSREP_SST_OPT_USER:-}
@@ -118,6 +119,10 @@ case "$1" in
WSREP_SST_OPT_BINLOG="$2"
shift
;;
+ '--binlog-index')
+ WSREP_SST_OPT_BINLOG_INDEX="$2"
+ shift
+ ;;
'--gtid-domain-id')
readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2"
shift
@@ -131,6 +136,7 @@ shift
done
readonly WSREP_SST_OPT_BYPASS
readonly WSREP_SST_OPT_BINLOG
+readonly WSREP_SST_OPT_BINLOG_INDEX
if [ -n "${WSREP_SST_OPT_ADDR_PORT:-}" ]; then
if [ -n "${WSREP_SST_OPT_PORT:-}" ]; then
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index 05c99880d75..6886d2ce1e1 100644
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -132,6 +132,12 @@ then
BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
fi
+if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
+then
+ BINLOG_INDEX_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG_INDEX)
+ BINLOG_INDEX_FILENAME=$(basename $WSREP_SST_OPT_BINLOG_INDEX)
+fi
+
WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
# if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf
if [ -z "$WSREP_LOG_DIR" ]; then
@@ -204,12 +210,20 @@ then
OLD_PWD="$(pwd)"
cd $BINLOG_DIRNAME
- binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_FILENAME}.index)
+ if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
+ binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_FILENAME}.index)
+ then
+ cd $BINLOG_INDEX_DIRNAME
+ binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_INDEX_FILENAME}.index)
+ fi
+
+ cd $BINLOG_DIRNAME
binlog_files=""
for ii in $binlog_files_full
do
binlog_files="$binlog_files $(basename $ii)"
done
+
if ! [ -z "$binlog_files" ]
then
wsrep_log_info "Preparing binlog files for transfer:"
@@ -391,7 +405,11 @@ EOF
tar -xvf $BINLOG_TAR_FILE >&2
for ii in $(ls -1 ${BINLOG_FILENAME}.*)
do
- echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_FILENAME}.index
+ if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
+ echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_FILENAME}.index
+ then
+ echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_INDEX_DIRNAME}/${BINLOG_INDEX_FILENAME}.index
+ fi
done
fi
cd "$OLD_PWD"
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 8dd178108b9..b2d093298ed 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -798,6 +798,7 @@ char *master_info_file;
char *relay_log_info_file, *report_user, *report_password, *report_host;
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
char *opt_logname, *opt_slow_logname, *opt_bin_logname;
+char *opt_binlog_index_name=0;
/* Static variables */
@@ -807,7 +808,6 @@ my_bool opt_expect_abort= 0, opt_bootstrap= 0;
static my_bool opt_myisam_log;
static int cleanup_done;
static ulong opt_specialflag;
-static char *opt_binlog_index_name;
char *mysql_home_ptr, *pidfile_name_ptr;
/** Initial command line arguments (count), after load_defaults().*/
static int defaults_argc;
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 5a2dc6dce8d..df6f9de836c 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -171,6 +171,7 @@ extern uint protocol_version, mysqld_port, dropping_tables;
extern ulong delay_key_write_options;
extern char *opt_logname, *opt_slow_logname, *opt_bin_logname,
*opt_relay_logname;
+extern char *opt_binlog_index_name;
extern char *opt_backup_history_logname, *opt_backup_progress_logname,
*opt_backup_settings_name;
extern const char *log_output_str;
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index a4832ce913b..ac10b4c7ba1 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -426,6 +426,22 @@ static int generate_binlog_opt_val(char** ret)
return 0;
}
+static int generate_binlog_index_opt_val(char** ret)
+{
+ DBUG_ASSERT(ret);
+ *ret= NULL;
+ if (opt_binlog_index_name) {
+ *ret= strcmp(opt_binlog_index_name, "0") ?
+ my_strdup(opt_binlog_index_name, MYF(0)) : my_strdup("", MYF(0));
+ }
+ else
+ {
+ *ret= my_strdup("", MYF(0));
+ }
+ if (!*ret) return -ENOMEM;
+ return 0;
+}
+
static void* sst_joiner_thread (void* a)
{
sst_thread_arg* arg= (sst_thread_arg*) a;
@@ -590,7 +606,9 @@ static ssize_t sst_prepare_other (const char* method,
}
const char* binlog_opt= "";
+ const char* binlog_index_opt= "";
char* binlog_opt_val= NULL;
+ char* binlog_index_opt_val= NULL;
int ret;
if ((ret= generate_binlog_opt_val(&binlog_opt_val)))
@@ -599,7 +617,15 @@ static ssize_t sst_prepare_other (const char* method,
ret);
return ret;
}
+
+ if ((ret= generate_binlog_index_opt_val(&binlog_index_opt_val)))
+ {
+ WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d",
+ ret);
+ }
+
if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG;
+ if (strlen(binlog_index_opt_val)) binlog_index_opt=WSREP_SST_OPT_BINLOG_INDEX;
make_wsrep_defaults_file();
@@ -610,11 +636,14 @@ static ssize_t sst_prepare_other (const char* method,
WSREP_SST_OPT_DATA " '%s' "
" %s "
WSREP_SST_OPT_PARENT " '%d'"
- " %s '%s' ",
+ " %s '%s'"
+ " %s '%s'",
method, addr_in, mysql_real_data_home,
wsrep_defaults_file,
- (int)getpid(), binlog_opt, binlog_opt_val);
+ (int)getpid(), binlog_opt, binlog_opt_val,
+ binlog_index_opt, binlog_index_opt_val);
my_free(binlog_opt_val);
+ my_free(binlog_index_opt_val);
if (ret < 0 || ret >= cmd_len)
{
diff --git a/sql/wsrep_sst.h b/sql/wsrep_sst.h
index 8bf6dc31464..cc0f1f5389d 100644
--- a/sql/wsrep_sst.h
+++ b/sql/wsrep_sst.h
@@ -31,6 +31,7 @@
#define WSREP_SST_OPT_CONF_EXTRA "--defaults-extra-file"
#define WSREP_SST_OPT_PARENT "--parent"
#define WSREP_SST_OPT_BINLOG "--binlog"
+#define WSREP_SST_OPT_BINLOG_INDEX "--binlog-index"
// mysqldump-specific options
#define WSREP_SST_OPT_USER "--user"
1
0

[Commits] 9a8baa6: MDEV-16473 WITH statement throws 'no database selected' error
by IgorBabaev 26 Jun '18
by IgorBabaev 26 Jun '18
26 Jun '18
revision-id: 9a8baa6829847ee4c4c81a4bf3fd19f7c2e8b103 (mariadb-10.2.15-80-g9a8baa6)
parent(s): fe3f9fa9183ea3d10397b6f7f4d422ae9bba00a4
author: Igor Babaev
committer: Igor Babaev
timestamp: 2018-06-25 19:19:10 -0700
message:
MDEV-16473 WITH statement throws 'no database selected' error
Before this patch if no default database was set the server threw
an error for any table name reference that was not fully qualified by
database name. In particular it happened for table names referenced
CTE tables. This was incorrect.
The error message was thrown at the parser stage when the names referencing
different tables were not resolved yet.
Now if no default database is set and a with clause is used in the
processed statement any table reference is just supplied with a dummy
database name "*none*" at the parser stage. Later after a call
of check_dependencies_in_with_clauses() when the names for CTE tables
can be resolved error messages are thrown only for those names that
refer to non-CTE tables. This is done in open_and_process_table().
---
mysql-test/r/cte_nonrecursive.result | 34 ++++++++++++++++++++++++++++++++++
mysql-test/t/cte_nonrecursive.test | 29 ++++++++++++++++++++++++++++-
sql/sql_base.cc | 8 ++++++++
sql/sql_class.h | 25 +++++++++++++++++++++----
sql/sql_lex.h | 2 ++
sql/sql_parse.cc | 1 +
6 files changed, 94 insertions(+), 5 deletions(-)
diff --git a/mysql-test/r/cte_nonrecursive.result b/mysql-test/r/cte_nonrecursive.result
index 1d079c3..f6b8015 100644
--- a/mysql-test/r/cte_nonrecursive.result
+++ b/mysql-test/r/cte_nonrecursive.result
@@ -1478,3 +1478,37 @@ select 2 as f;
f
2
drop table t1;
+#
+# MDEV-16473: query with CTE when no database is set
+#
+create database db_mdev_16473;
+use db_mdev_16473;
+drop database db_mdev_16473;
+# Now no default database is set
+select database();
+database()
+NULL
+with cte as (select 1 as a) select * from cte;
+a
+1
+create database db_mdev_16473;
+create table db_mdev_16473.t1 (a int);
+insert into db_mdev_16473.t1 values (2), (7), (3), (1);
+with cte as (select * from db_mdev_16473.t1) select * from cte;
+a
+2
+7
+3
+1
+with cte as (select * from db_mdev_16473.t1)
+select * from cte, t1 as t where cte.a=t.a;
+ERROR 3D000: No database selected
+with cte as (select * from db_mdev_16473.t1)
+select * from cte, db_mdev_16473.t1 as t where cte.a=t.a;
+a a
+2 2
+7 7
+3 3
+1 1
+drop database db_mdev_16473;
+use test;
diff --git a/mysql-test/t/cte_nonrecursive.test b/mysql-test/t/cte_nonrecursive.test
index 98a7794..11c864b 100644
--- a/mysql-test/t/cte_nonrecursive.test
+++ b/mysql-test/t/cte_nonrecursive.test
@@ -1029,4 +1029,31 @@ with cte as
select 2 as f;
drop table t1;
-
\ No newline at end of file
+
+--echo #
+--echo # MDEV-16473: query with CTE when no database is set
+--echo #
+
+create database db_mdev_16473;
+use db_mdev_16473;
+drop database db_mdev_16473;
+
+--echo # Now no default database is set
+select database();
+
+with cte as (select 1 as a) select * from cte;
+
+create database db_mdev_16473;
+create table db_mdev_16473.t1 (a int);
+insert into db_mdev_16473.t1 values (2), (7), (3), (1);
+with cte as (select * from db_mdev_16473.t1) select * from cte;
+
+--error ER_NO_DB_ERROR
+with cte as (select * from db_mdev_16473.t1)
+select * from cte, t1 as t where cte.a=t.a;
+with cte as (select * from db_mdev_16473.t1)
+select * from cte, db_mdev_16473.t1 as t where cte.a=t.a;
+
+drop database db_mdev_16473;
+
+use test;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 9dfaf82..2e57686 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -3330,6 +3330,14 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables,
/*
Not a placeholder: must be a base/temporary table or a view. Let us open it.
*/
+
+ if (tables->db == no_db)
+ {
+ my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
+ error= TRUE;
+ goto end;
+ }
+
if (tables->table)
{
/*
diff --git a/sql/sql_class.h b/sql/sql_class.h
index a12015e..cb0893d 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3945,11 +3945,28 @@ class THD :public Statement,
{
if (db == NULL)
{
- my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
- return TRUE;
+ /*
+ No default database is set. In this case if it's guaranteed that
+ no CTE can be used in the statement then we can throw an error right
+ now at the parser stage. Otherwise the decision about throwing such
+ a message must be postponed until a post-parser stage when we are able
+ to resolve all CTE names as we don't need this message to be thrown
+ for any CTE references.
+ */
+ if (!lex->with_clauses_list)
+ {
+ my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
+ return TRUE;
+ }
+ /* This will allow to throw an error later for non-CTE references */
+ *p_db= (char *) no_db;
+ *p_db_length= strlen(no_db);
+ }
+ else
+ {
+ *p_db= strmake(db, db_length);
+ *p_db_length= db_length;
}
- *p_db= strmake(db, db_length);
- *p_db_length= db_length;
return FALSE;
}
thd_scheduler event_scheduler;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index a1f6b20..ae010a8 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -156,6 +156,8 @@ struct LEX_TYPE
extern const LEX_STRING null_lex_str;
extern const LEX_STRING empty_lex_str;
+extern const char *no_db;
+
enum enum_sp_suid_behaviour
{
SP_IS_DEFAULT_SUID= 0,
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a5973b9..0f74755 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -139,6 +139,7 @@ static bool execute_show_status(THD *, TABLE_LIST *);
static bool check_rename_table(THD *, TABLE_LIST *, TABLE_LIST *);
const char *any_db="*any*"; // Special symbol for check_access
+const char *no_db="*none*"; // Used when no default db is set
const LEX_STRING command_name[257]={
{ C_STRING_WITH_LEN("Sleep") }, //0
1
0

[Commits] 1c288c2: MDEV-16428: Concurrent DML on RocksDB tables makes optimistic parallel replication abort
by psergey@askmonty.org 25 Jun '18
by psergey@askmonty.org 25 Jun '18
25 Jun '18
revision-id: 1c288c266e0208e98d55e5348fa78c27517022c9
parent(s): a107c79fcdde80d1dea0a1caf5859647f77b48c9
committer: Sergei Petrunia
branch nick: 10.2-r12-new-submodule
timestamp: 2018-06-25 23:15:18 +0300
message:
MDEV-16428: Concurrent DML on RocksDB tables makes optimistic parallel replication abort
DRAFT:
Make MyRocks call thd_rpl_deadlock_check(X, Y) whenever a transaction X
is about to wait on a row that's locked by transaction Y.
This allows the SQL layer to check if transaction Y has "ran ahead" of
transaction X and abort it if it is necessary.
The patch includes adding a hook into RocksDB to detect the waits.
---
.gitmodules | 2 +-
storage/rocksdb/ha_rocksdb.cc | 132 ++++++++++++++++++++++++++++++++++++++++++
storage/rocksdb/rocksdb | 2 +-
3 files changed, 134 insertions(+), 2 deletions(-)
diff --git a/.gitmodules b/.gitmodules
index 6419657..2ef79a2 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -3,4 +3,4 @@
url = https://github.com/MariaDB/mariadb-connector-c
[submodule "storage/rocksdb/rocksdb"]
path = storage/rocksdb/rocksdb
- url = https://github.com/facebook/rocksdb.git
+ url = https://github.com/spetrunia/rocksdb.git
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 96bc7da..bd2e0bf 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -53,6 +53,9 @@
#endif
#include <mysys_err.h>
+#include "my_sys.h"
+#include "lf.h"
+
// Both MySQL and RocksDB define the same constant. To avoid compilation errors
// till we make the fix in RocksDB, we'll temporary undefine it here.
#undef CACHE_LINE_SIZE
@@ -116,6 +119,101 @@ MYSQL_PLUGIN_IMPORT bool my_disable_leak_check;
void ignore_db_dirs_append(const char *dirname_arg);
+////////////////////////////////////////////////////////////////////////
+
+
+/*
+ A thread-safe, concurrent way to maintain a map from RocksDB's
+ TransactionIDs to MariaDB's THD*.
+*/
+
+class Transaction_id_map
+{
+ typedef rocksdb::TransactionID key_type;
+ typedef THD* value_type;
+
+ typedef struct
+ {
+ key_type key;
+ value_type val;
+ } ELEMENT;
+
+ LF_HASH lf_hash;
+
+public:
+ void init();
+ void cleanup();
+
+ /*
+ Before using the LockTable, each thread should get its own "pins".
+ */
+ LF_PINS* get_pins() { return lf_hash_get_pins(&lf_hash); }
+ void put_pins(LF_PINS *pins) { return lf_hash_put_pins(pins); }
+
+ void put(LF_PINS *pins, key_type key, value_type value);
+ value_type get(LF_PINS *pins, key_type key);
+ void remove(LF_PINS *pins, key_type key);
+};
+
+void Transaction_id_map::init()
+{
+ lf_hash_init(&lf_hash,
+ sizeof(ELEMENT),
+ LF_HASH_UNIQUE,
+ 0 /* key offset */,
+ sizeof(key_type)/*key_len*/, NULL /*get_hash_key*/,
+ NULL /*charset*/);
+
+ lf_hash.alloc.constructor= NULL;
+ lf_hash.alloc.destructor= NULL;
+ lf_hash.element_size= sizeof(ELEMENT);
+}
+
+
+void Transaction_id_map::cleanup()
+{
+ DBUG_ASSERT(lf_hash.count == 0);
+ lf_hash_destroy(&lf_hash);
+}
+
+
+void Transaction_id_map::put(LF_PINS *pins, key_type key, value_type value)
+{
+ ELEMENT new_elem;
+ new_elem.key= key;
+ new_elem.val= value;
+
+ /*
+ The following call may return:
+ 0: OK
+ 1: Element already exists (should not happen)
+ -1: out-of-memory condition.
+ Dont do error handling as we don't have any way to do it.
+ */
+ lf_hash_insert(&lf_hash, pins, &new_elem);
+}
+
+
+void Transaction_id_map::remove(LF_PINS *pins, key_type key)
+{
+ lf_hash_delete(&lf_hash, pins, &key, sizeof(key_type));
+}
+
+
+Transaction_id_map::value_type Transaction_id_map::get(LF_PINS *pins, key_type key)
+{
+ ELEMENT *ptr= (ELEMENT*)lf_hash_search(&lf_hash, pins, &key, sizeof(key_type));
+
+ if (ptr)
+ return ptr->val;
+
+ return NULL;
+}
+
+Transaction_id_map trx_id_map;
+///////////////////////////////////////////////////////////////////////////
+
+
namespace myrocks {
static st_global_stats global_stats;
@@ -2492,6 +2590,7 @@ class Rdb_transaction_impl : public Rdb_transaction {
rocksdb::Transaction *m_rocksdb_reuse_tx = nullptr;
public:
+ LF_PINS *lf_pins; // LF-hash pins to use with trx_id_map
void set_lock_timeout(int timeout_sec_arg) override {
if (m_rocksdb_tx)
m_rocksdb_tx->SetLockTimeout(rdb_convert_sec_to_ms(m_timeout_sec));
@@ -2555,6 +2654,7 @@ class Rdb_transaction_impl : public Rdb_transaction {
release_snapshot();
s = m_rocksdb_tx->Commit();
+ trx_id_map.remove(lf_pins, m_rocksdb_tx->GetID());
if (!s.ok()) {
rdb_handle_io_error(s, RDB_IO_ERROR_TX_COMMIT);
res = true;
@@ -2589,6 +2689,7 @@ class Rdb_transaction_impl : public Rdb_transaction {
/* This will also release all of the locks: */
m_rocksdb_tx->Rollback();
+ trx_id_map.remove(lf_pins, m_rocksdb_tx->GetID());
/* Save the transaction object to be reused */
release_tx();
@@ -2743,6 +2844,8 @@ class Rdb_transaction_impl : public Rdb_transaction {
rdb->BeginTransaction(write_opts, tx_opts, m_rocksdb_reuse_tx);
m_rocksdb_reuse_tx = nullptr;
+ trx_id_map.put(lf_pins, m_rocksdb_tx->GetID(), m_thd);
+
m_read_opts = rocksdb::ReadOptions();
set_initial_savepoint();
@@ -2801,6 +2904,7 @@ class Rdb_transaction_impl : public Rdb_transaction {
: Rdb_transaction(thd), m_rocksdb_tx(nullptr) {
// Create a notifier that can be called when a snapshot gets generated.
m_notifier = std::make_shared<Rdb_snapshot_notifier>(this);
+ lf_pins= trx_id_map.get_pins();
}
virtual ~Rdb_transaction_impl() {
@@ -2813,6 +2917,7 @@ class Rdb_transaction_impl : public Rdb_transaction {
// Free any transaction memory that is still hanging around.
delete m_rocksdb_reuse_tx;
+ trx_id_map.put_pins(lf_pins);
DBUG_ASSERT(m_rocksdb_tx == nullptr);
}
};
@@ -4131,6 +4236,28 @@ static int rocksdb_start_tx_and_assign_read_view(
return HA_EXIT_SUCCESS;
}
+
+/* There is no prototype of this function in any header */
+extern "C" int thd_rpl_deadlock_check(MYSQL_THD thd, MYSQL_THD other_thd);
+
+
+/* A row_wait_callback_t-Compatible function */
+void rdb_row_wait_callback(rocksdb::TransactionID waiter,
+ rocksdb::TransactionID waitee)
+{
+ Rdb_transaction *&tx = get_tx_from_thd(current_thd);
+
+ if (!tx->is_writebatch_trx()) {
+ const auto tx_impl = static_cast<const Rdb_transaction_impl *>(tx);
+
+ THD *waiter_thd= trx_id_map.get(tx_impl->lf_pins, waiter);
+ THD *waitee_thd= trx_id_map.get(tx_impl->lf_pins, waitee);
+ //DBUG_ASSERT(waiter_thd == tx->m_thd);
+ thd_rpl_deadlock_check(waiter_thd, waitee_thd);
+ }
+}
+
+
/* Dummy SAVEPOINT support. This is needed for long running transactions
* like mysqldump (https://bugs.mysql.com/bug.php?id=71017)
* Current SAVEPOINT does not correctly handle ROLLBACK and does not return
@@ -4663,6 +4790,10 @@ static int rocksdb_init_func(void *const p) {
Rdb_sst_info::init(rdb);
+ trx_id_map.init();
+
+ rdb->SetRowWaitCallback(&rdb_row_wait_callback);
+
/*
Enable auto compaction, things needed for compaction filter are finished
initializing
@@ -4887,6 +5018,7 @@ static int rocksdb_done_func(void *const p) {
delete rdb;
rdb = nullptr;
+ trx_id_map.cleanup();
delete commit_latency_stats;
commit_latency_stats = nullptr;
diff --git a/storage/rocksdb/rocksdb b/storage/rocksdb/rocksdb
index ba295cd..38080be 160000
--- a/storage/rocksdb/rocksdb
+++ b/storage/rocksdb/rocksdb
@@ -1 +1 @@
-Subproject commit ba295cda29daee3ffe58549542804efdfd969784
+Subproject commit 38080be88bf20e8956754d62322de1c98ab5d736
1
0

[Commits] 38080be: MDEV-16428: Make optimistic parallel replication work
by psergey@askmonty.org 25 Jun '18
by psergey@askmonty.org 25 Jun '18
25 Jun '18
revision-id: 38080be88bf20e8956754d62322de1c98ab5d736
parent(s): ba295cda29daee3ffe58549542804efdfd969784
committer: Sergei Petrunia
branch nick: rocksdb-10.2-r12-new-submodule
timestamp: 2018-06-25 22:43:23 +0300
message:
MDEV-16428: Make optimistic parallel replication work
DRAFT PATCH, RocksDB part of it:
Add a callback function that is used to inform the SQL layer
that transaction X is waiting on a row lock that is held by transaction Y.
Optimistic parallel slave uses it to determine that transaction Y has
ran ahead of transaction X. If they need to be committed in the other
order (first X, then Y), then Y will be rolled back to allow X to proceed
(and Y will be retried later on).
---
include/rocksdb/utilities/transaction_db.h | 7 +++++++
utilities/transactions/pessimistic_transaction_db.h | 4 ++++
utilities/transactions/transaction_lock_mgr.cc | 15 ++++++++++++++-
utilities/transactions/transaction_lock_mgr.h | 3 +++
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/include/rocksdb/utilities/transaction_db.h b/include/rocksdb/utilities/transaction_db.h
index b5a33d1..1d5d3dd 100644
--- a/include/rocksdb/utilities/transaction_db.h
+++ b/include/rocksdb/utilities/transaction_db.h
@@ -156,6 +156,11 @@ struct DeadlockPath {
bool empty() { return path.empty() && !limit_exceeded; }
};
+
+typedef void (*row_wait_callback_t)(rocksdb::TransactionID waiter,
+ rocksdb::TransactionID waitee);
+
+
class TransactionDB : public StackableDB {
public:
// Open a TransactionDB similar to DB::Open().
@@ -217,6 +222,8 @@ class TransactionDB : public StackableDB {
virtual std::vector<DeadlockPath> GetDeadlockInfoBuffer() = 0;
virtual void SetDeadlockInfoBufferSize(uint32_t target_size) = 0;
+ virtual void SetRowWaitCallback(row_wait_callback_t callback) {}
+
protected:
// To Create an TransactionDB, call Open()
explicit TransactionDB(DB* db) : StackableDB(db) {}
diff --git a/utilities/transactions/pessimistic_transaction_db.h b/utilities/transactions/pessimistic_transaction_db.h
index 4311e88..8a47cbd 100644
--- a/utilities/transactions/pessimistic_transaction_db.h
+++ b/utilities/transactions/pessimistic_transaction_db.h
@@ -113,6 +113,10 @@ class PessimisticTransactionDB : public TransactionDB {
std::vector<DeadlockPath> GetDeadlockInfoBuffer() override;
void SetDeadlockInfoBufferSize(uint32_t target_size) override;
+ virtual void SetRowWaitCallback(row_wait_callback_t callback) override {
+ lock_mgr_.SetRowWaitCallback(callback);
+ }
+
protected:
DBImpl* db_impl_;
std::shared_ptr<Logger> info_log_;
diff --git a/utilities/transactions/transaction_lock_mgr.cc b/utilities/transactions/transaction_lock_mgr.cc
index 9485067..e6593b0 100644
--- a/utilities/transactions/transaction_lock_mgr.cc
+++ b/utilities/transactions/transaction_lock_mgr.cc
@@ -173,7 +173,8 @@ TransactionLockMgr::TransactionLockMgr(
max_num_locks_(max_num_locks),
lock_maps_cache_(new ThreadLocalPtr(&UnrefLockMapsCache)),
dlock_buffer_(max_num_deadlocks),
- mutex_factory_(mutex_factory) {
+ mutex_factory_(mutex_factory),
+ row_wait_callback(NULL) {
assert(txn_db);
txn_db_impl_ =
static_cast_with_check<PessimisticTransactionDB, TransactionDB>(txn_db);
@@ -383,6 +384,18 @@ Status TransactionLockMgr::AcquireWithTimeout(
}
TEST_SYNC_POINT("TransactionLockMgr::AcquireWithTimeout:WaitingTxn");
+
+ //psergey: Call the MariaDB callback to inform it that
+ // transaction X is doing a row lock wait for a lock that
+ // is held by transaction Y.
+ //
+ // Transaction Y
+ if (row_wait_callback)
+ {
+ for (auto it= wait_ids.begin(); it != wait_ids.end(); it++)
+ row_wait_callback(txn->GetID(), *it);
+ }
+
if (cv_end_time < 0) {
// Wait indefinitely
result = stripe->stripe_cv->Wait(stripe->stripe_mutex);
diff --git a/utilities/transactions/transaction_lock_mgr.h b/utilities/transactions/transaction_lock_mgr.h
index abf7c5d..86a9904 100644
--- a/utilities/transactions/transaction_lock_mgr.h
+++ b/utilities/transactions/transaction_lock_mgr.h
@@ -84,6 +84,8 @@ class TransactionLockMgr {
std::vector<DeadlockPath> GetDeadlockInfoBuffer();
void Resize(uint32_t);
+ void SetRowWaitCallback(row_wait_callback_t callback) { row_wait_callback= callback; }
+
private:
PessimisticTransactionDB* txn_db_impl_;
@@ -149,6 +151,7 @@ class TransactionLockMgr {
void DecrementWaitersImpl(const PessimisticTransaction* txn,
const autovector<TransactionID>& wait_ids);
+ row_wait_callback_t row_wait_callback;
// No copying allowed
TransactionLockMgr(const TransactionLockMgr&);
void operator=(const TransactionLockMgr&);
1
0