From 163b34fe25919b25ff83860f30f2440b44c8b53b Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 9 Oct 2018 18:55:18 +0300 Subject: Optimize flush tables with read lock (FTWRL) to not wait for select's Part of MDEV-5336 Implement LOCK FOR BACKUP The idea is that instead of waiting in close_cached_tables() for all tables to be closed, we instead call flush_tables() that does: - Flush not used objects in table cache to free memory - Collect all tables that are open - Call HA_EXTRA_FLUSH on the objects, to get them into "closed state" - Added HA_EXTRA_FLUSH support to archive and CSV - Added multi-user protection to HA_EXTRA_FLUSH in MyISAM and Aria The benefit compared to old code is: - FTWRL doesn't have to wait for long running read operations or open HANDLER's --- storage/archive/azio.c | 5 ++++- storage/archive/ha_archive.cc | 14 ++++++++++++++ storage/archive/ha_archive.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'storage/archive') diff --git a/storage/archive/azio.c b/storage/archive/azio.c index 0f66b999c94..3529d875f72 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -866,7 +866,10 @@ int azclose (azio_stream *s) if (s->mode == 'w') { if (do_flush(s, Z_FINISH) != Z_OK) - return destroy(s); + { + destroy(s); + return Z_ERRNO; + } putLong(s->file, s->crc); putLong(s->file, (uLong)(s->in & 0xffffffff)); diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index bb15aa9297d..f97bc52b6a9 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1737,6 +1737,20 @@ int ha_archive::info(uint flag) } +int ha_archive::extra(enum ha_extra_function operation) +{ + switch (operation) { + case HA_EXTRA_FLUSH: + mysql_mutex_lock(&share->mutex); + share->close_archive_writer(); + mysql_mutex_unlock(&share->mutex); + break; + default: + break; + } + return 0; +} + /* This method tells us that a bulk insert operation is about to occur. We set a flag which will keep write_row from saying that its data is dirty. This in diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h index 1f25fba4eed..17649c9c110 100644 --- a/storage/archive/ha_archive.h +++ b/storage/archive/ha_archive.h @@ -148,6 +148,7 @@ public: int read_data_header(azio_stream *file_to_read); void position(const uchar *record); int info(uint); + int extra(enum ha_extra_function operation); void update_create_info(HA_CREATE_INFO *create_info); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); int optimize(THD* thd, HA_CHECK_OPT* check_opt); -- cgit v1.2.1