[Commits] 88ca6562b48: MDEV-25447: MyRocks use "tmpdir" rather than using "rocksdb_tmpdir"
revision-id: 88ca6562b48d701128372a51287d2adb13b61db1 (mariadb-10.2.40-236-g88ca6562b48) parent(s): c1d7b4575e67bd0ef458457859cdf7de32b3d4f9 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2022-01-21 19:47:24 +0300 message: MDEV-25447: MyRocks use "tmpdir" rather than using "rocksdb_tmpdir" - Move mysql_tmpfile_path() from inside InnoDB onto the SQL layer. - Make MyRocks use it, like its upstream does. --- sql/handler.h | 7 +++++++ sql/sql_class.cc | 28 ++++++++++++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 27 --------------------------- storage/rocksdb/rdb_index_merge.cc | 4 ---- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/sql/handler.h b/sql/handler.h index 02a4a76c6c1..40c84cf51e3 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -4410,6 +4410,13 @@ void print_keydup_error(TABLE *table, KEY *key, myf errflag); int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info); int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table); + +/* + TODO: Starting with next release, make this a part of Plugin API in + include/mysql/plugin.h +*/ +extern "C" int mysql_tmpfile_path(const char *path, const char *prefix); + #ifndef DBUG_OFF /** Converts XID to string. diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 479578679f1..17932fe7d6f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -340,6 +340,34 @@ extern "C" int mysql_tmpfile(const char *prefix) } +extern "C" int mysql_tmpfile_path(const char *path, const char *prefix) +{ + DBUG_ASSERT(path != NULL); + DBUG_ASSERT((strlen(path) + strlen(prefix)) <= FN_REFLEN); + + char filename[FN_REFLEN]; + File fd = create_temp_file(filename, path, prefix, +#ifdef __WIN__ + O_BINARY | O_TRUNC | O_SEQUENTIAL | + O_SHORT_LIVED | +#endif /* __WIN__ */ + O_CREAT | O_EXCL | O_RDWR | O_TEMPORARY, + MYF(MY_WME)); + if (fd >= 0) { +#ifndef __WIN__ + /* + This can be removed once the following bug is fixed: + Bug #28903 create_temp_file() doesn't honor O_TEMPORARY option + (file not removed) (Unix) + */ + unlink(filename); +#endif /* !__WIN__ */ + } + + return fd; +} + + extern "C" int thd_in_lock_tables(const THD *thd) { diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 889aee0d47e..01244514744 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2391,33 +2391,6 @@ static bool is_mysql_datadir_path(const char *path) TRUE)); } -static int mysql_tmpfile_path(const char *path, const char *prefix) -{ - DBUG_ASSERT(path != NULL); - DBUG_ASSERT((strlen(path) + strlen(prefix)) <= FN_REFLEN); - - char filename[FN_REFLEN]; - File fd = create_temp_file(filename, path, prefix, -#ifdef __WIN__ - O_BINARY | O_TRUNC | O_SEQUENTIAL | - O_SHORT_LIVED | -#endif /* __WIN__ */ - O_CREAT | O_EXCL | O_RDWR | O_TEMPORARY, - MYF(MY_WME)); - if (fd >= 0) { -#ifndef __WIN__ - /* - This can be removed once the following bug is fixed: - Bug #28903 create_temp_file() doesn't honor O_TEMPORARY option - (file not removed) (Unix) - */ - unlink(filename); -#endif /* !__WIN__ */ - } - - return fd; -} - /** Creates a temporary file in the location specified by the parameter path. If the path is NULL, then it will be created in tmpdir. @param[in] path location for creating temporary file diff --git a/storage/rocksdb/rdb_index_merge.cc b/storage/rocksdb/rdb_index_merge.cc index 424a998548a..c2742d482ee 100644 --- a/storage/rocksdb/rdb_index_merge.cc +++ b/storage/rocksdb/rdb_index_merge.cc @@ -107,16 +107,12 @@ int Rdb_index_merge::merge_file_create() { DBUG_ASSERT(m_merge_file.m_fd == -1); int fd; -#ifdef MARIAROCKS_NOT_YET // mysql_tmpfile_path use /* If no path set for tmpfile, use mysql_tmpdir by default */ if (m_tmpfile_path == nullptr) { fd = mysql_tmpfile("myrocks"); } else { fd = mysql_tmpfile_path(m_tmpfile_path, "myrocks"); } -#else - fd = mysql_tmpfile("myrocks"); -#endif if (fd < 0) { // NO_LINT_DEBUG sql_print_error("Failed to create temp file during fast index creation.");
participants (1)
-
psergey