Added backup handler calls
Part of MDEV-5336 Implement LOCK FOR BACKUP Added support for backup calls in Aria to protect removal of redo logs.
This commit is contained in:
parent
ecdf97924c
commit
1077f320e4
@ -822,6 +822,43 @@ void ha_kill_query(THD* thd, enum thd_kill_levels level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
Backup functions
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
static my_bool plugin_prepare_for_backup(THD *unused1, plugin_ref plugin,
|
||||||
|
void *not_used)
|
||||||
|
{
|
||||||
|
handlerton *hton= plugin_hton(plugin);
|
||||||
|
if (hton->state == SHOW_OPTION_YES && hton->prepare_for_backup)
|
||||||
|
hton->prepare_for_backup();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ha_prepare_for_backup()
|
||||||
|
{
|
||||||
|
plugin_foreach_with_mask(0, plugin_prepare_for_backup,
|
||||||
|
MYSQL_STORAGE_ENGINE_PLUGIN,
|
||||||
|
PLUGIN_IS_DELETED|PLUGIN_IS_READY, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static my_bool plugin_end_backup(THD *unused1, plugin_ref plugin,
|
||||||
|
void *not_used)
|
||||||
|
{
|
||||||
|
handlerton *hton= plugin_hton(plugin);
|
||||||
|
if (hton->state == SHOW_OPTION_YES && hton->end_backup)
|
||||||
|
hton->end_backup();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ha_end_backup()
|
||||||
|
{
|
||||||
|
plugin_foreach_with_mask(0, plugin_end_backup,
|
||||||
|
MYSQL_STORAGE_ENGINE_PLUGIN,
|
||||||
|
PLUGIN_IS_DELETED|PLUGIN_IS_READY, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
======================= TRANSACTIONS ===================================*/
|
======================= TRANSACTIONS ===================================*/
|
||||||
|
|
||||||
|
@ -1613,6 +1613,10 @@ struct handlerton
|
|||||||
@return transaction commit ID
|
@return transaction commit ID
|
||||||
@retval 0 if no system-versioned data was affected by the transaction */
|
@retval 0 if no system-versioned data was affected by the transaction */
|
||||||
ulonglong (*prepare_commit_versioned)(THD *thd, ulonglong *trx_id);
|
ulonglong (*prepare_commit_versioned)(THD *thd, ulonglong *trx_id);
|
||||||
|
|
||||||
|
/* backup */
|
||||||
|
void (*prepare_for_backup)(void);
|
||||||
|
void (*end_backup)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -4676,6 +4680,7 @@ public:
|
|||||||
{ DBUG_ASSERT(ht); return partition_ht()->flags & HTON_NATIVE_SYS_VERSIONING; }
|
{ DBUG_ASSERT(ht); return partition_ht()->flags & HTON_NATIVE_SYS_VERSIONING; }
|
||||||
virtual void update_partition(uint part_id)
|
virtual void update_partition(uint part_id)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Handler_share *get_ha_share_ptr();
|
Handler_share *get_ha_share_ptr();
|
||||||
void set_ha_share_ptr(Handler_share *arg_ha_share);
|
void set_ha_share_ptr(Handler_share *arg_ha_share);
|
||||||
@ -4754,6 +4759,8 @@ int ha_create_table(THD *thd, const char *path,
|
|||||||
HA_CREATE_INFO *create_info, LEX_CUSTRING *frm);
|
HA_CREATE_INFO *create_info, LEX_CUSTRING *frm);
|
||||||
int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
|
int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
|
||||||
const LEX_CSTRING *db, const LEX_CSTRING *alias, bool generate_warning);
|
const LEX_CSTRING *db, const LEX_CSTRING *alias, bool generate_warning);
|
||||||
|
void ha_prepare_for_backup();
|
||||||
|
void ha_end_backup();
|
||||||
|
|
||||||
/* statistics and info */
|
/* statistics and info */
|
||||||
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
|
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
|
||||||
|
@ -3443,6 +3443,21 @@ int maria_checkpoint_state(handlerton *hton, bool disabled)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Handle backup calls
|
||||||
|
*/
|
||||||
|
|
||||||
|
void maria_prepare_for_backup()
|
||||||
|
{
|
||||||
|
translog_disable_purge();
|
||||||
|
}
|
||||||
|
|
||||||
|
void maria_end_backup()
|
||||||
|
{
|
||||||
|
translog_enable_purge();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SHOW_MSG_LEN (FN_REFLEN + 20)
|
#define SHOW_MSG_LEN (FN_REFLEN + 20)
|
||||||
/**
|
/**
|
||||||
@ -3643,6 +3658,9 @@ static int ha_maria_init(void *p)
|
|||||||
#endif
|
#endif
|
||||||
maria_hton->flush_logs= maria_flush_logs;
|
maria_hton->flush_logs= maria_flush_logs;
|
||||||
maria_hton->show_status= maria_show_status;
|
maria_hton->show_status= maria_show_status;
|
||||||
|
maria_hton->prepare_for_backup= maria_prepare_for_backup;
|
||||||
|
maria_hton->end_backup= maria_end_backup;
|
||||||
|
|
||||||
/* TODO: decide if we support Maria being used for log tables */
|
/* TODO: decide if we support Maria being used for log tables */
|
||||||
maria_hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES;
|
maria_hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES;
|
||||||
bzero(maria_log_pagecache, sizeof(*maria_log_pagecache));
|
bzero(maria_log_pagecache, sizeof(*maria_log_pagecache));
|
||||||
|
@ -56,6 +56,8 @@ static mysql_cond_t COND_soft_sync;
|
|||||||
static MA_SERVICE_THREAD_CONTROL soft_sync_control=
|
static MA_SERVICE_THREAD_CONTROL soft_sync_control=
|
||||||
{0, FALSE, FALSE, &LOCK_soft_sync, &COND_soft_sync};
|
{0, FALSE, FALSE, &LOCK_soft_sync, &COND_soft_sync};
|
||||||
|
|
||||||
|
uint log_purge_disabled= 0;
|
||||||
|
|
||||||
|
|
||||||
/* transaction log file descriptor */
|
/* transaction log file descriptor */
|
||||||
typedef struct st_translog_file
|
typedef struct st_translog_file
|
||||||
@ -3620,6 +3622,7 @@ my_bool translog_init_with_table(const char *directory,
|
|||||||
translog_syncs= 0;
|
translog_syncs= 0;
|
||||||
flush_start= 0;
|
flush_start= 0;
|
||||||
id_to_share= NULL;
|
id_to_share= NULL;
|
||||||
|
log_purge_disabled= 0;
|
||||||
|
|
||||||
log_descriptor.directory_fd= -1;
|
log_descriptor.directory_fd= -1;
|
||||||
log_descriptor.is_everything_flushed= 1;
|
log_descriptor.is_everything_flushed= 1;
|
||||||
@ -8668,7 +8671,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
|
|||||||
mysql_rwlock_unlock(&log_descriptor.open_files_lock);
|
mysql_rwlock_unlock(&log_descriptor.open_files_lock);
|
||||||
translog_close_log_file(file);
|
translog_close_log_file(file);
|
||||||
}
|
}
|
||||||
if (log_purge_type == TRANSLOG_PURGE_IMMIDIATE)
|
if (log_purge_type == TRANSLOG_PURGE_IMMIDIATE && ! log_purge_disabled)
|
||||||
{
|
{
|
||||||
char path[FN_REFLEN], *file_name;
|
char path[FN_REFLEN], *file_name;
|
||||||
file_name= translog_filename_by_fileno(i, path);
|
file_name= translog_filename_by_fileno(i, path);
|
||||||
@ -8721,7 +8724,7 @@ my_bool translog_purge_at_flush()
|
|||||||
|
|
||||||
mysql_mutex_lock(&log_descriptor.purger_lock);
|
mysql_mutex_lock(&log_descriptor.purger_lock);
|
||||||
|
|
||||||
if (unlikely(log_descriptor.min_need_file == 0))
|
if (unlikely(log_descriptor.min_need_file == 0 || log_purge_disabled))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("No info about min need file => exit"));
|
DBUG_PRINT("info", ("No info about min need file => exit"));
|
||||||
mysql_mutex_unlock(&log_descriptor.purger_lock);
|
mysql_mutex_unlock(&log_descriptor.purger_lock);
|
||||||
@ -9285,3 +9288,22 @@ void dump_page(uchar *buffer, File handler)
|
|||||||
}
|
}
|
||||||
dump_datapage(buffer, handler);
|
dump_datapage(buffer, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Handle backup calls
|
||||||
|
*/
|
||||||
|
|
||||||
|
void translog_disable_purge()
|
||||||
|
{
|
||||||
|
mysql_mutex_lock(&log_descriptor.purger_lock);
|
||||||
|
log_purge_disabled++;
|
||||||
|
mysql_mutex_unlock(&log_descriptor.purger_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void translog_enable_purge()
|
||||||
|
{
|
||||||
|
mysql_mutex_lock(&log_descriptor.purger_lock);
|
||||||
|
log_purge_disabled--;
|
||||||
|
mysql_mutex_unlock(&log_descriptor.purger_lock);
|
||||||
|
}
|
||||||
|
@ -367,6 +367,8 @@ extern void dump_page(uchar *buffer, File handler);
|
|||||||
extern my_bool translog_log_debug_info(TRN *trn,
|
extern my_bool translog_log_debug_info(TRN *trn,
|
||||||
enum translog_debug_info_type type,
|
enum translog_debug_info_type type,
|
||||||
uchar *info, size_t length);
|
uchar *info, size_t length);
|
||||||
|
extern void translog_disable_purge(void);
|
||||||
|
extern void translog_enable_purge(void);
|
||||||
|
|
||||||
enum enum_translog_status
|
enum enum_translog_status
|
||||||
{
|
{
|
||||||
@ -520,6 +522,7 @@ typedef enum
|
|||||||
} enum_maria_translog_purge_type;
|
} enum_maria_translog_purge_type;
|
||||||
extern ulong log_purge_type;
|
extern ulong log_purge_type;
|
||||||
extern ulong log_file_size;
|
extern ulong log_file_size;
|
||||||
|
extern uint log_purge_disabled; /* For backup */
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user