Commit 7537854b authored by Kristian Nielsen's avatar Kristian Nielsen

MDEV-34705: Binlog in Engine: Pre-allocate binlog tablespaces in background thread

Signed-off-by: default avatarKristian Nielsen <knielsen@knielsen-hq.org>
parent 8a1e1f61
......@@ -1530,6 +1530,7 @@ struct handlerton
void *optimizer_costs; /* Costs are stored here */
/* Optional implementation of binlog in the engine. */
bool (*binlog_init)(size_t binlog_size);
bool (*binlog_write_direct)(IO_CACHE *cache, size_t main_size);
handler_binlog_reader * (*get_binlog_reader)();
......
......@@ -5470,13 +5470,21 @@ static int init_server_components()
if (opt_bin_log)
{
int error;
mysql_mutex_t *log_lock= mysql_bin_log.get_log_lock();
mysql_mutex_lock(log_lock);
error= mysql_bin_log.open(opt_bin_logname, 0, 0,
WRITE_CACHE, max_binlog_size, 0, TRUE);
mysql_mutex_unlock(log_lock);
if (unlikely(error))
unireg_abort(1);
if (opt_binlog_engine_hton)
{
if ((*opt_binlog_engine_hton->binlog_init)((size_t)max_binlog_size))
error= 1;
}
if (true) /* ToDo: `else` branch (don't open legacy binlog if using engine implementation). */
{
mysql_mutex_t *log_lock= mysql_bin_log.get_log_lock();
mysql_mutex_lock(log_lock);
error= mysql_bin_log.open(opt_bin_logname, 0, 0,
WRITE_CACHE, max_binlog_size, 0, TRUE);
mysql_mutex_unlock(log_lock);
if (unlikely(error))
unireg_abort(1);
}
}
#ifdef HAVE_REPLICATION
......
This diff is collapsed.
......@@ -527,6 +527,7 @@ mysql_pfs_key_t lock_wait_mutex_key;
mysql_pfs_key_t trx_sys_mutex_key;
mysql_pfs_key_t srv_threads_mutex_key;
mysql_pfs_key_t tpool_cache_mutex_key;
mysql_pfs_key_t fsp_active_binlog_mutex_key;
/* all_innodb_mutexes array contains mutexes that are
performance schema instrumented if "UNIV_PFS_MUTEX"
......@@ -4093,6 +4094,7 @@ static int innodb_init(void* p)
= innodb_prepare_commit_versioned;
innobase_hton->update_optimizer_costs= innobase_update_optimizer_costs;
innobase_hton->binlog_init= innodb_binlog_init;
innobase_hton->binlog_write_direct= innobase_binlog_write_direct;
innobase_hton->get_binlog_reader= innodb_get_binlog_reader;
......
......@@ -584,6 +584,8 @@ extern void fsp_binlog_trx(trx_t *trx, mtr_t *mtr);
class handler_binlog_reader;
extern bool innobase_binlog_write_direct(IO_CACHE *cache, size_t main_size);
extern handler_binlog_reader *innodb_get_binlog_reader();
extern void fsp_binlog_init();
extern bool innodb_binlog_init(size_t binlog_size);
extern void fsp_binlog_close();
#ifndef UNIV_DEBUG
......
......@@ -482,6 +482,7 @@ extern mysql_pfs_key_t trx_pool_mutex_key;
extern mysql_pfs_key_t trx_pool_manager_mutex_key;
extern mysql_pfs_key_t lock_wait_mutex_key;
extern mysql_pfs_key_t srv_threads_mutex_key;
extern mysql_pfs_key_t fsp_active_binlog_mutex_key;
# endif /* UNIV_PFS_MUTEX */
# ifdef UNIV_PFS_RWLOCK
......
......@@ -1904,6 +1904,8 @@ dberr_t srv_start(bool create_new_db)
return(srv_init_abort(err));
}
fsp_binlog_init();
if (!srv_read_only_mode
&& srv_operation <= SRV_OPERATION_EXPORT_RESTORED) {
/* Initialize the innodb_temporary tablespace and keep
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment