Skip to content

Commit c568e25

Browse files
author
Jan Lindström
authored
Merge pull request #1185 from codership/10.4-wsrep_schema_cleanup
Cleanup wsrep_schema and remove all references to wsrep_thd_pool
2 parents 677a1e7 + 047754a commit c568e25

File tree

3 files changed

+46
-54
lines changed

3 files changed

+46
-54
lines changed

sql/wsrep_mysqld.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ extern mysql_mutex_t LOCK_wsrep_slave_threads;
303303
extern mysql_mutex_t LOCK_wsrep_desync;
304304
extern mysql_mutex_t LOCK_wsrep_SR_pool;
305305
extern mysql_mutex_t LOCK_wsrep_SR_store;
306-
extern mysql_mutex_t LOCK_wsrep_thd_pool;
307306
extern mysql_mutex_t LOCK_wsrep_config_state;
308307
extern my_bool wsrep_emulate_bin_log;
309308
extern int wsrep_to_isolation;
@@ -330,7 +329,6 @@ extern PSI_mutex_key key_LOCK_wsrep_slave_threads;
330329
extern PSI_mutex_key key_LOCK_wsrep_desync;
331330
extern PSI_mutex_key key_LOCK_wsrep_SR_pool;
332331
extern PSI_mutex_key key_LOCK_wsrep_SR_store;
333-
extern PSI_mutex_key key_LOCK_wsrep_thd_pool;
334332
extern PSI_mutex_key key_LOCK_wsrep_global_seqno;
335333
extern PSI_mutex_key key_LOCK_wsrep_thd_queue;
336334
extern PSI_cond_key key_COND_wsrep_thd_queue;

sql/wsrep_schema.cc

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2015-2017 Codership Oy <info@codership.com>
1+
/* Copyright (C) 2015-2019 Codership Oy <info@codership.com>
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -584,8 +584,6 @@ static void wsrep_init_thd_for_schema(THD *thd)
584584

585585
thd->real_id=pthread_self(); // Keep purify happy
586586

587-
WSREP_DEBUG("Wsrep_thd_pool: creating system thread: %lld",
588-
(long long)thd->thread_id);
589587
thd->prior_thr_create_utime= thd->start_utime= thd->thr_create_utime;
590588
(void) mysql_mutex_unlock(&LOCK_thread_count);
591589

@@ -1115,16 +1113,21 @@ int Wsrep_schema::remove_fragments(THD* thd,
11151113
DBUG_RETURN(ret);
11161114
}
11171115

1118-
int Wsrep_schema::replay_transaction(THD* thd,
1116+
int Wsrep_schema::replay_transaction(THD* orig_thd,
11191117
Relay_log_info* rli,
11201118
const wsrep::ws_meta& ws_meta,
11211119
const std::vector<wsrep::seqno>& fragments)
11221120
{
11231121
DBUG_ENTER("Wsrep_schema::replay_transaction");
11241122
DBUG_ASSERT(!fragments.empty());
11251123

1126-
Wsrep_schema_impl::wsrep_off wsrep_off(thd);
1127-
Wsrep_schema_impl::binlog_off binlog_off(thd);
1124+
THD thd(next_thread_id(), true);
1125+
thd.thread_stack= (orig_thd ? orig_thd->thread_stack :
1126+
(char*) &thd);
1127+
1128+
Wsrep_schema_impl::wsrep_off wsrep_off(&thd);
1129+
Wsrep_schema_impl::binlog_off binlog_off(&thd);
1130+
Wsrep_schema_impl::thd_context_switch thd_context_switch(orig_thd, &thd);
11281131

11291132
int ret= 1;
11301133
int error;
@@ -1135,11 +1138,11 @@ int Wsrep_schema::replay_transaction(THD* thd,
11351138
for (std::vector<wsrep::seqno>::const_iterator i= fragments.begin();
11361139
i != fragments.end(); ++i)
11371140
{
1138-
Wsrep_schema_impl::init_stmt(thd);
1139-
if ((error= Wsrep_schema_impl::open_for_read(thd, sr_table_str.c_str(), &frag_table)))
1141+
Wsrep_schema_impl::init_stmt(&thd);
1142+
if ((error= Wsrep_schema_impl::open_for_read(&thd, sr_table_str.c_str(), &frag_table)))
11401143
{
11411144
WSREP_WARN("Could not open SR table for read: %d", error);
1142-
Wsrep_schema_impl::finish_stmt(thd);
1145+
Wsrep_schema_impl::finish_stmt(&thd);
11431146
DBUG_RETURN(1);
11441147
}
11451148

@@ -1169,20 +1172,28 @@ int Wsrep_schema::replay_transaction(THD* thd,
11691172
String buf;
11701173
frag_table->field[4]->val_str(&buf);
11711174

1172-
Wsrep_schema_impl::end_index_scan(frag_table);
1173-
Wsrep_schema_impl::finish_stmt(thd);
1174-
ret= wsrep_apply_events(thd, rli, buf.c_ptr_safe(), buf.length());
1175-
if (ret)
11761175
{
1177-
WSREP_WARN("Wsrep_schema::replay_transaction: failed to apply fragments");
1178-
break;
1176+
Wsrep_schema_impl::thd_context_switch thd_context_switch(&thd, orig_thd);
1177+
1178+
ret= wsrep_apply_events(orig_thd, rli, buf.c_ptr_quick(), buf.length());
1179+
if (ret)
1180+
{
1181+
WSREP_WARN("Wsrep_schema::replay_transaction: failed to apply fragments");
1182+
break;
1183+
}
11791184
}
1180-
Wsrep_schema_impl::init_stmt(thd);
11811185

1182-
if ((error= Wsrep_schema_impl::open_for_write(thd, sr_table_str.c_str(), &frag_table)))
1186+
Wsrep_schema_impl::end_index_scan(frag_table);
1187+
Wsrep_schema_impl::finish_stmt(&thd);
1188+
1189+
Wsrep_schema_impl::init_stmt(&thd);
1190+
1191+
if ((error= Wsrep_schema_impl::open_for_write(&thd,
1192+
sr_table_str.c_str(),
1193+
&frag_table)))
11831194
{
11841195
WSREP_WARN("Could not open SR table for write: %d", error);
1185-
Wsrep_schema_impl::finish_stmt(thd);
1196+
Wsrep_schema_impl::finish_stmt(&thd);
11861197
DBUG_RETURN(1);
11871198
}
11881199
error= Wsrep_schema_impl::init_for_index_scan(frag_table,
@@ -1206,7 +1217,7 @@ int Wsrep_schema::replay_transaction(THD* thd,
12061217
break;
12071218
}
12081219
Wsrep_schema_impl::end_index_scan(frag_table);
1209-
Wsrep_schema_impl::finish_stmt(thd);
1220+
Wsrep_schema_impl::finish_stmt(&thd);
12101221
}
12111222

12121223
DBUG_RETURN(ret);
@@ -1215,14 +1226,14 @@ int Wsrep_schema::replay_transaction(THD* thd,
12151226
int Wsrep_schema::recover_sr_transactions(THD *orig_thd)
12161227
{
12171228
DBUG_ENTER("Wsrep_schema::recover_sr_transactions");
1218-
THD storage_thd(true, true);
1229+
THD storage_thd(next_thread_id(), true);
12191230
storage_thd.thread_stack= (orig_thd ? orig_thd->thread_stack :
12201231
(char*) &storage_thd);
12211232
TABLE* frag_table= 0;
12221233
TABLE* cluster_table= 0;
12231234
Wsrep_storage_service storage_service(&storage_thd);
12241235
Wsrep_schema_impl::binlog_off binlog_off(&storage_thd);
1225-
Wsrep_schema_impl::wsrep_off binglog_off(&storage_thd);
1236+
Wsrep_schema_impl::wsrep_off wsrep_off(&storage_thd);
12261237
Wsrep_schema_impl::thd_context_switch thd_context_switch(orig_thd,
12271238
&storage_thd);
12281239
Wsrep_server_state& server_state(Wsrep_server_state::instance());
@@ -1233,13 +1244,9 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd)
12331244

12341245
Wsrep_schema_impl::init_stmt(&storage_thd);
12351246
storage_thd.wsrep_skip_locking= FALSE;
1236-
/*
1237-
Open the table for reading and writing so that fragments without
1238-
valid seqno can be deleted.
1239-
*/
1240-
if (Wsrep_schema_impl::open_for_write(&storage_thd,
1241-
cluster_table_str.c_str(),
1242-
&cluster_table) ||
1247+
if (Wsrep_schema_impl::open_for_read(&storage_thd,
1248+
cluster_table_str.c_str(),
1249+
&cluster_table) ||
12431250
Wsrep_schema_impl::init_for_scan(cluster_table))
12441251
{
12451252
Wsrep_schema_impl::finish_stmt(&storage_thd);
@@ -1273,10 +1280,15 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd)
12731280

12741281
storage_thd.wsrep_skip_locking= TRUE;
12751282
Wsrep_schema_impl::init_stmt(&storage_thd);
1276-
if (Wsrep_schema_impl::open_for_read(&storage_thd, sr_table_str.c_str(), &frag_table) ||
1283+
1284+
/*
1285+
Open the table for reading and writing so that fragments without
1286+
valid seqno can be deleted.
1287+
*/
1288+
if (Wsrep_schema_impl::open_for_write(&storage_thd, sr_table_str.c_str(), &frag_table) ||
12771289
Wsrep_schema_impl::init_for_scan(frag_table))
12781290
{
1279-
WSREP_ERROR("Failed to open SR table for read");
1291+
WSREP_ERROR("Failed to open SR table for write");
12801292
goto out;
12811293
}
12821294

@@ -1309,7 +1321,7 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd)
13091321
String data_str;
13101322

13111323
(void)frag_table->field[4]->val_str(&data_str);
1312-
wsrep::const_buffer data(data_str.c_ptr(), data_str.length());
1324+
wsrep::const_buffer data(data_str.c_ptr_quick(), data_str.length());
13131325
wsrep::ws_meta ws_meta(gtid,
13141326
wsrep::stid(server_id,
13151327
transaction_id,
@@ -1319,14 +1331,13 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd)
13191331

13201332
wsrep::high_priority_service* applier;
13211333
if (!(applier= server_state.find_streaming_applier(server_id,
1322-
transaction_id)))
1334+
transaction_id)))
13231335
{
13241336
DBUG_ASSERT(wsrep::starts_transaction(flags));
1325-
THD* thd= new THD(true, true);
1337+
THD* thd= new THD(next_thread_id(), true);
13261338
thd->thread_stack= (char*)&storage_thd;
13271339

13281340
mysql_mutex_lock(&LOCK_thread_count);
1329-
thd->thread_id= next_thread_id();
13301341
thd->real_id= pthread_self();
13311342
mysql_mutex_unlock(&LOCK_thread_count);
13321343

sql/wsrep_schema.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2015-2018 Codership Oy <info@codership.com>
1+
/* Copyright (C) 2015-2019 Codership Oy <info@codership.com>
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -20,13 +20,9 @@
2020
/* wsrep-lib */
2121
#include "wsrep_types.h"
2222

23-
2423
#include "mysqld.h"
25-
#include "thr_lock.h" /* enum thr_lock_type */
2624
#include "wsrep_mysqld.h"
2725

28-
#include <string>
29-
3026
/*
3127
Forward decls
3228
*/
@@ -64,14 +60,6 @@ class Wsrep_schema
6460
*/
6561
Wsrep_view restore_view(THD* thd, const Wsrep_id& own_id) const;
6662

67-
/*
68-
Append transaction fragment to fragment storage.
69-
Starts a trx using a THD from thd_pool, does not commit.
70-
Should be followed by a call to update_frag_seqno(), or
71-
release_SR_thd() if wsrep->certify() fails.
72-
*/
73-
THD* append_frag(const wsrep_trx_meta_t&, uint32_t,
74-
const unsigned char*, size_t);
7563
/**
7664
Append transaction fragment to fragment storage.
7765
Transaction must have been started for THD before this call.
@@ -145,11 +133,6 @@ class Wsrep_schema
145133
*/
146134
int recover_sr_transactions(THD* orig_thd);
147135

148-
/*
149-
Close wsrep schema.
150-
*/
151-
void close();
152-
153136
private:
154137
/* Non-copyable */
155138
Wsrep_schema(const Wsrep_schema&);

0 commit comments

Comments
 (0)