MXS-1506: Combine housekeeper task types

The tasks themselves now control whether they are executed again. To
compare it to the old system, oneshot tasks now return `false` and
repeating tasks return `true`.

Letting the housekeeper remove the tasks makes the code simpler and
removes the possibility of the task being removed while it is being
executed. It does introduce a deadlock possibility if a housekeeper
function is called inside a housekeeper task.
This commit is contained in:
Markus Mäkelä
2018-04-03 15:12:33 +03:00
parent 96a0aae7fe
commit c70216390f
10 changed files with 105 additions and 105 deletions

View File

@ -77,7 +77,7 @@ static void errorReply(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session,
static uint64_t getCapabilities(MXS_ROUTER* instance);
extern int MaxScaleUptime();
extern void avro_get_used_tables(AVRO_INSTANCE *router, DCB *dcb);
void converter_func(void* data);
bool converter_func(void* data);
bool binlog_next_file_exists(const char* binlogdir, const char* binlog);
int blr_file_get_next_binlogname(const char *router);
bool avro_load_conversion_state(AVRO_INSTANCE *router);
@ -1177,7 +1177,7 @@ stats_func(void *inst)
/**
* Conversion task: MySQL binlogs to AVRO files
*/
void converter_func(void* data)
bool converter_func(void* data)
{
AVRO_INSTANCE* router = (AVRO_INSTANCE*) data;
bool ok = true;
@ -1227,6 +1227,8 @@ void converter_func(void* data)
router->binlog_name, router->current_pos, router->task_delay);
}
}
return true;
}
/**

View File

@ -97,7 +97,7 @@ bool blr_get_encryption_key(ROUTER_INSTANCE *router);
int blr_parse_key_file(ROUTER_INSTANCE *router);
static bool blr_open_gtid_maps_storage(ROUTER_INSTANCE *inst);
static void stats_func(void *);
static bool stats_func(void *);
static bool rses_begin_locked_router_action(ROUTER_SLAVE *);
static void rses_end_locked_router_action(ROUTER_SLAVE *);
@ -2505,7 +2505,7 @@ static uint64_t getCapabilities(MXS_ROUTER* instance)
*
* @param inst The router instance
*/
static void
static bool
stats_func(void *inst)
{
ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)inst;
@ -2531,6 +2531,8 @@ stats_func(void *inst)
slave = slave->next;
}
spinlock_release(&router->lock);
return true;
}
/**

View File

@ -1018,7 +1018,7 @@ extern const char *blr_skip_leading_sql_comments(const char *);
extern bool blr_fetch_mariadb_gtid(ROUTER_SLAVE *,
const char *,
MARIADB_GTID_INFO *);
extern void blr_start_master_in_main(void* data);
extern bool blr_start_master_in_main(void* data);
extern bool blr_binlog_file_exists(ROUTER_INSTANCE *router,
const MARIADB_GTID_INFO *info_file);

View File

@ -64,7 +64,7 @@ static void blr_log_packet(int priority, char *msg, uint8_t *ptr, int len);
void blr_master_close(ROUTER_INSTANCE *);
char *blr_extract_column(GWBUF *buf, int col);
void poll_fake_write_event(DCB *dcb);
static void blr_check_last_master_event(void *inst);
static bool blr_check_last_master_event(void *inst);
extern int blr_check_heartbeat(ROUTER_INSTANCE *router);
static void blr_log_identity(ROUTER_INSTANCE *router);
static void blr_extract_header_semisync(uint8_t *pkt, REP_HEADER *hdr);
@ -251,10 +251,10 @@ static void blr_start_master(void* data)
if (name)
{
sprintf(name, "%s %s", router->service->name, master);
hktask_oneshot(name,
blr_start_master_in_main,
router,
connect_retry);
hktask_add(name,
blr_start_master_in_main,
router,
connect_retry);
MXS_FREE(name);
}
@ -324,7 +324,7 @@ static void worker_cb_start_master(int worker_id, void* data)
*
* @param data Data intended for `blr_start_master`.
*/
void blr_start_master_in_main(void* data)
bool blr_start_master_in_main(void* data)
{
// The master should be connected to in the main worker, so we post it a
// message and call `blr_start_master` there.
@ -339,6 +339,8 @@ void blr_start_master_in_main(void* data)
{
MXS_ERROR("Could not post 'blr_start_master' message to main worker.");
}
return false;
}
/**
@ -423,10 +425,10 @@ blr_restart_master(ROUTER_INSTANCE *router)
if (name)
{
sprintf(name, "%s %s", router->service->name, master);
hktask_oneshot(name,
blr_start_master_in_main,
router,
connect_retry);
hktask_add(name,
blr_start_master_in_main,
router,
connect_retry);
MXS_FREE(name);
MXS_ERROR("%s: failed to connect to master server '%s', "
@ -529,10 +531,10 @@ blr_master_delayed_connect(ROUTER_INSTANCE *router)
if (name)
{
sprintf(name, "%s %s", router->service->name, master);
hktask_oneshot(name,
blr_start_master_in_main,
router,
router->retry_interval);
hktask_add(name,
blr_start_master_in_main,
router,
router->retry_interval);
MXS_FREE(name);
}
}
@ -1917,9 +1919,10 @@ blr_stop_start_master(ROUTER_INSTANCE *router)
* @param router Current router instance
*/
static void
static bool
blr_check_last_master_event(void *inst)
{
bool rval = true;
ROUTER_INSTANCE *router = (ROUTER_INSTANCE *)inst;
int master_check = 1;
int master_state = BLRM_UNCONNECTED;
@ -1953,8 +1956,10 @@ blr_check_last_master_event(void *inst)
"%s heartbeat",
router->service->name);
hktask_remove(task_name);
rval = false;
}
return rval;
}
/**

View File

@ -279,7 +279,7 @@ static int blr_slave_send_columndef_with_status_schema(ROUTER_INSTANCE *router,
int type,
int len,
uint8_t seqno);
static void blr_send_slave_heartbeat(void *inst);
static bool blr_send_slave_heartbeat(void *inst);
static int blr_slave_send_heartbeat(ROUTER_INSTANCE *router,
ROUTER_SLAVE *slave);
static int blr_set_master_ssl(ROUTER_INSTANCE *router,
@ -6099,7 +6099,7 @@ blr_slave_send_columndef_with_status_schema(ROUTER_INSTANCE *router,
* @param router Current router instance
*/
static void
static bool
blr_send_slave_heartbeat(void *inst)
{
ROUTER_SLAVE *sptr = NULL;
@ -6136,6 +6136,8 @@ blr_send_slave_heartbeat(void *inst)
}
spinlock_release(&router->lock);
return true;
}
/**