summaryrefslogtreecommitdiff
path: root/storage/rocksdb/rdb_sst_info.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2017-03-11 07:17:42 +0300
committerSergei Petrunia <psergey@askmonty.org>2017-03-11 07:17:42 +0300
commit65d01da29c03c44f3c059a999c7c1cc6e001ead8 (patch)
treec653e6aa2ecda5ba106872380b502e221f11c353 /storage/rocksdb/rdb_sst_info.cc
parent7468ccfadf27a0c5f87c8909ee8514bdd52dc4a7 (diff)
downloadmariadb-git-65d01da29c03c44f3c059a999c7c1cc6e001ead8.tar.gz
Copy of
commit ba00e640f658ad8d0a4dff09a497a51b8a4de935 Author: Herman Lee <herman@fb.com> Date: Wed Feb 22 06:30:06 2017 -0800 Improve add_index_alter_cardinality test Summary: Split add_index_inplace_cardinality test out and add a debug_sync point to it so that the flush of the memtable occurs while the alter is running. Closes https://github.com/facebook/mysql-5.6/pull/539 Reviewed By: alxyang Differential Revision: D4597887 Pulled By: hermanlee fbshipit-source-id: faedda2
Diffstat (limited to 'storage/rocksdb/rdb_sst_info.cc')
-rw-r--r--storage/rocksdb/rdb_sst_info.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/storage/rocksdb/rdb_sst_info.cc b/storage/rocksdb/rdb_sst_info.cc
index cfbefb2ce6d..b6fd14f3ccb 100644
--- a/storage/rocksdb/rdb_sst_info.cc
+++ b/storage/rocksdb/rdb_sst_info.cc
@@ -191,6 +191,10 @@ Rdb_sst_info::Rdb_sst_info(rocksdb::DB *const db, const std::string &tablename,
m_prefix += normalized_table + "_" + indexname + "_";
}
+ // Unique filename generated to prevent collisions when the same table
+ // is loaded in parallel
+ m_prefix += std::to_string(m_prefix_counter.fetch_add(1)) + "_";
+
rocksdb::ColumnFamilyDescriptor cf_descr;
const rocksdb::Status s = m_cf->GetDescriptor(&cf_descr);
if (!s.ok()) {
@@ -221,7 +225,7 @@ int Rdb_sst_info::open_new_sst_file() {
// Open the sst file
const rocksdb::Status s = m_sst_file->open();
if (!s.ok()) {
- set_error_msg(s.ToString());
+ set_error_msg(m_sst_file->get_name(), s.ToString());
delete m_sst_file;
m_sst_file = nullptr;
return HA_EXIT_FAILURE;
@@ -255,7 +259,7 @@ void Rdb_sst_info::close_curr_sst_file() {
#else
const rocksdb::Status s = m_sst_file->commit();
if (!s.ok()) {
- set_error_msg(s.ToString());
+ set_error_msg(m_sst_file->get_name(), s.ToString());
}
delete m_sst_file;
@@ -293,7 +297,7 @@ int Rdb_sst_info::put(const rocksdb::Slice &key, const rocksdb::Slice &value) {
// Add the key/value to the current sst file
const rocksdb::Status s = m_sst_file->put(key, value);
if (!s.ok()) {
- set_error_msg(s.ToString());
+ set_error_msg(m_sst_file->get_name(), s.ToString());
return HA_EXIT_FAILURE;
}
@@ -329,16 +333,18 @@ int Rdb_sst_info::commit() {
return HA_EXIT_SUCCESS;
}
-void Rdb_sst_info::set_error_msg(const std::string &msg) {
+void Rdb_sst_info::set_error_msg(const std::string &sst_file_name,
+ const std::string &msg) {
#if defined(RDB_SST_INFO_USE_THREAD)
// Both the foreground and background threads can set the error message
// so lock the mutex to protect it. We only want the first error that
// we encounter.
const std::lock_guard<std::mutex> guard(m_mutex);
#endif
- my_printf_error(ER_UNKNOWN_ERROR, "bulk load error: %s", MYF(0), msg.c_str());
+ my_printf_error(ER_UNKNOWN_ERROR, "[%s] bulk load error: %s", MYF(0),
+ sst_file_name.c_str(), msg.c_str());
if (m_error_msg.empty()) {
- m_error_msg = msg;
+ m_error_msg = "[" + sst_file_name + "] " + msg;
}
}
@@ -366,7 +372,7 @@ void Rdb_sst_info::run_thread() {
// Close out the sst file and add it to the database
const rocksdb::Status s = sst_file->commit();
if (!s.ok()) {
- set_error_msg(s.ToString());
+ set_error_msg(sst_file->get_name(), s.ToString());
}
delete sst_file;
@@ -412,5 +418,6 @@ void Rdb_sst_info::init(const rocksdb::DB *const db) {
my_dirend(dir_info);
}
+std::atomic<uint64_t> Rdb_sst_info::m_prefix_counter(0);
std::string Rdb_sst_info::m_suffix = ".bulk_load.tmp";
} // namespace myrocks