summaryrefslogtreecommitdiff
path: root/storage/tokudb/PerconaFT/ft
diff options
context:
space:
mode:
Diffstat (limited to 'storage/tokudb/PerconaFT/ft')
-rw-r--r--storage/tokudb/PerconaFT/ft/cachetable/background_job_manager.cc9
-rw-r--r--storage/tokudb/PerconaFT/ft/cachetable/cachetable.cc82
-rw-r--r--storage/tokudb/PerconaFT/ft/cachetable/checkpoint.cc36
-rw-r--r--storage/tokudb/PerconaFT/ft/ft-ops.cc304
-rw-r--r--storage/tokudb/PerconaFT/ft/ft.cc17
-rw-r--r--storage/tokudb/PerconaFT/ft/loader/callbacks.cc6
-rw-r--r--storage/tokudb/PerconaFT/ft/loader/dbufio.cc163
-rw-r--r--storage/tokudb/PerconaFT/ft/loader/loader-internal.h37
-rw-r--r--storage/tokudb/PerconaFT/ft/loader/loader.cc365
-rw-r--r--storage/tokudb/PerconaFT/ft/loader/loader.h5
-rw-r--r--storage/tokudb/PerconaFT/ft/logger/log-internal.h8
-rw-r--r--storage/tokudb/PerconaFT/ft/logger/logcursor.cc8
-rw-r--r--storage/tokudb/PerconaFT/ft/logger/logger.cc79
-rw-r--r--storage/tokudb/PerconaFT/ft/logger/recover.cc14
-rw-r--r--storage/tokudb/PerconaFT/ft/serialize/block_allocator.cc1
-rw-r--r--storage/tokudb/PerconaFT/ft/serialize/block_table.cc13
-rw-r--r--storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc10
-rw-r--r--storage/tokudb/PerconaFT/ft/serialize/sub_block.cc3
-rw-r--r--storage/tokudb/PerconaFT/ft/serialize/workset.h14
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-4357.cc31
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-4365.cc42
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-5097.cc11
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-5978-2.cc20
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-5978.cc6
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-checkpoint-pending.cc24
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-cleaner-thread-attrs-accumulate.cc2
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-clone-checkpoint.cc11
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-pin-checkpoint.cc21
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-put-checkpoint.cc21
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-rwlock-test.cc47
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin-nonblocking.cc30
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin.cc30
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-test.cc8
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/cachetable-unpin-remove-and-checkpoint.cc17
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/ftloader-test-extractor-errors.cc4
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/ftloader-test-merge-files-dbufio.cc12
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/ftloader-test-writer-errors.cc4
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/log-test4.cc13
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/log-test5.cc16
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/log-test6.cc13
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/recovery-bad-last-entry.cc15
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/test-bjm.cc14
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-flush.cc8
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-merge.cc8
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-rebalance.cc8
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-split.cc8
-rw-r--r--storage/tokudb/PerconaFT/ft/tests/test3681.cc34
-rw-r--r--storage/tokudb/PerconaFT/ft/txn/roll.cc6
-rw-r--r--storage/tokudb/PerconaFT/ft/txn/rollback_log_node_cache.cc6
-rw-r--r--storage/tokudb/PerconaFT/ft/txn/txn.cc119
-rw-r--r--storage/tokudb/PerconaFT/ft/txn/txn_child_manager.cc4
-rw-r--r--storage/tokudb/PerconaFT/ft/txn/txn_manager.cc10
52 files changed, 1210 insertions, 587 deletions
diff --git a/storage/tokudb/PerconaFT/ft/cachetable/background_job_manager.cc b/storage/tokudb/PerconaFT/ft/cachetable/background_job_manager.cc
index 9119a49b081..c109185f973 100644
--- a/storage/tokudb/PerconaFT/ft/cachetable/background_job_manager.cc
+++ b/storage/tokudb/PerconaFT/ft/cachetable/background_job_manager.cc
@@ -42,6 +42,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "cachetable/background_job_manager.h"
+toku_instr_key *bjm_jobs_lock_mutex_key;
+toku_instr_key *bjm_jobs_wait_key;
+
struct background_job_manager_struct {
bool accepting_jobs;
uint32_t num_jobs;
@@ -49,10 +52,10 @@ struct background_job_manager_struct {
toku_mutex_t jobs_lock;
};
-void bjm_init(BACKGROUND_JOB_MANAGER* pbjm) {
+void bjm_init(BACKGROUND_JOB_MANAGER *pbjm) {
BACKGROUND_JOB_MANAGER XCALLOC(bjm);
- toku_mutex_init(&bjm->jobs_lock, 0);
- toku_cond_init(&bjm->jobs_wait, NULL);
+ toku_mutex_init(*bjm_jobs_lock_mutex_key, &bjm->jobs_lock, nullptr);
+ toku_cond_init(*bjm_jobs_wait_key, &bjm->jobs_wait, nullptr);
bjm->accepting_jobs = true;
bjm->num_jobs = 0;
*pbjm = bjm;
diff --git a/storage/tokudb/PerconaFT/ft/cachetable/cachetable.cc b/storage/tokudb/PerconaFT/ft/cachetable/cachetable.cc
index 54ef11eb1eb..b72edc8d231 100644
--- a/storage/tokudb/PerconaFT/ft/cachetable/cachetable.cc
+++ b/storage/tokudb/PerconaFT/ft/cachetable/cachetable.cc
@@ -58,6 +58,25 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "util/status.h"
#include "util/context.h"
+toku_instr_key *cachetable_m_mutex_key;
+toku_instr_key *cachetable_ev_thread_lock_mutex_key;
+
+toku_instr_key *cachetable_m_list_lock_key;
+toku_instr_key *cachetable_m_pending_lock_expensive_key;
+toku_instr_key *cachetable_m_pending_lock_cheap_key;
+toku_instr_key *cachetable_m_lock_key;
+
+toku_instr_key *cachetable_value_key;
+toku_instr_key *cachetable_disk_nb_rwlock_key;
+
+toku_instr_key *cachetable_p_refcount_wait_key;
+toku_instr_key *cachetable_m_flow_control_cond_key;
+toku_instr_key *cachetable_m_ev_thread_cond_key;
+
+toku_instr_key *cachetable_disk_nb_mutex_key;
+toku_instr_key *log_internal_lock_mutex_key;
+toku_instr_key *eviction_thread_key;
+
///////////////////////////////////////////////////////////////////////////////////
// Engine status
//
@@ -780,18 +799,25 @@ void pair_init(PAIR p,
p->checkpoint_complete_callback = write_callback.checkpoint_complete_callback;
p->write_extraargs = write_callback.write_extraargs;
- p->count = 0; // <CER> Is zero the correct init value?
+ p->count = 0; // <CER> Is zero the correct init value?
p->refcount = 0;
p->num_waiting_on_refs = 0;
- toku_cond_init(&p->refcount_wait, NULL);
+ toku_cond_init(*cachetable_p_refcount_wait_key, &p->refcount_wait, nullptr);
p->checkpoint_pending = false;
p->mutex = list->get_mutex_for_pair(fullhash);
assert(p->mutex);
- p->value_rwlock.init(p->mutex);
- nb_mutex_init(&p->disk_nb_mutex);
+ p->value_rwlock.init(p->mutex
+#ifdef TOKU_MYSQL_WITH_PFS
+ ,
+ *cachetable_value_key
+#endif
+ );
+ nb_mutex_init(*cachetable_disk_nb_mutex_key,
+ *cachetable_disk_nb_rwlock_key,
+ &p->disk_nb_mutex);
- p->size_evicting_estimate = 0; // <CER> Is zero the correct init value?
+ p->size_evicting_estimate = 0; // <CER> Is zero the correct init value?
p->ev = ev;
p->list = list;
@@ -3230,16 +3256,26 @@ void pair_list::init() {
#if defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
#else
- // TODO: need to figure out how to make writer-preferential rwlocks
- // happen on osx
+// TODO: need to figure out how to make writer-preferential rwlocks
+// happen on osx
#endif
- toku_pthread_rwlock_init(&m_list_lock, &attr);
- toku_pthread_rwlock_init(&m_pending_lock_expensive, &attr);
- toku_pthread_rwlock_init(&m_pending_lock_cheap, &attr);
+ toku_pthread_rwlock_init(*cachetable_m_list_lock_key, &m_list_lock, &attr);
+ toku_pthread_rwlock_init(*cachetable_m_pending_lock_expensive_key,
+ &m_pending_lock_expensive,
+ &attr);
+ toku_pthread_rwlock_init(
+ *cachetable_m_pending_lock_cheap_key, &m_pending_lock_cheap, &attr);
XCALLOC_N(m_table_size, m_table);
XCALLOC_N(m_num_locks, m_mutexes);
for (uint64_t i = 0; i < m_num_locks; i++) {
- toku_mutex_init(&m_mutexes[i].aligned_mutex, NULL);
+ toku_mutex_init(
+#ifdef TOKU_PFS_MUTEX_EXTENDED_CACHETABLEMMUTEX
+ *cachetable_m_mutex_key,
+#else
+ toku_uninstrumented,
+#endif
+ &m_mutexes[i].aligned_mutex,
+ nullptr);
}
}
@@ -3579,9 +3615,9 @@ ENSURE_POD(evictor);
// This is the function that runs eviction on its own thread.
//
static void *eviction_thread(void *evictor_v) {
- evictor* CAST_FROM_VOIDP(evictor, evictor_v);
+ evictor *CAST_FROM_VOIDP(evictor, evictor_v);
evictor->run_eviction_thread();
- return evictor_v;
+ return toku_pthread_done(evictor_v);
}
//
@@ -3630,11 +3666,14 @@ int evictor::init(long _size_limit, pair_list* _pl, cachefile_list* _cf_list, KI
m_pl = _pl;
m_cf_list = _cf_list;
- m_kibbutz = _kibbutz;
- toku_mutex_init(&m_ev_thread_lock, NULL);
- toku_cond_init(&m_flow_control_cond, NULL);
- toku_cond_init(&m_ev_thread_cond, NULL);
- m_num_sleepers = 0;
+ m_kibbutz = _kibbutz;
+ toku_mutex_init(
+ *cachetable_ev_thread_lock_mutex_key, &m_ev_thread_lock, nullptr);
+ toku_cond_init(
+ *cachetable_m_flow_control_cond_key, &m_flow_control_cond, nullptr);
+ toku_cond_init(
+ *cachetable_m_ev_thread_cond_key, &m_ev_thread_cond, nullptr);
+ m_num_sleepers = 0;
m_ev_thread_is_running = false;
m_period_in_seconds = eviction_period;
@@ -3642,11 +3681,12 @@ int evictor::init(long _size_limit, pair_list* _pl, cachefile_list* _cf_list, KI
int r = myinitstate_r(seed, m_random_statebuf, sizeof m_random_statebuf, &m_random_data);
assert_zero(r);
- // start the background thread
+ // start the background thread
m_run_thread = true;
m_num_eviction_thread_runs = 0;
m_ev_thread_init = false;
- r = toku_pthread_create(&m_ev_thread, NULL, eviction_thread, this);
+ r = toku_pthread_create(
+ *eviction_thread_key, &m_ev_thread, nullptr, eviction_thread, this);
if (r == 0) {
m_ev_thread_init = true;
}
@@ -4703,7 +4743,7 @@ static_assert(std::is_pod<cachefile_list>::value, "cachefile_list isn't POD");
void cachefile_list::init() {
m_next_filenum_to_use.fileid = 0;
m_next_hash_id_to_use = 0;
- toku_pthread_rwlock_init(&m_lock, NULL);
+ toku_pthread_rwlock_init(*cachetable_m_lock_key, &m_lock, nullptr);
m_active_filenum.create();
m_active_fileid.create();
m_stale_fileid.create();
diff --git a/storage/tokudb/PerconaFT/ft/cachetable/checkpoint.cc b/storage/tokudb/PerconaFT/ft/cachetable/checkpoint.cc
index 4d54962fe9c..aad018f4097 100644
--- a/storage/tokudb/PerconaFT/ft/cachetable/checkpoint.cc
+++ b/storage/tokudb/PerconaFT/ft/cachetable/checkpoint.cc
@@ -87,8 +87,16 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "util/frwlock.h"
#include "util/status.h"
-void
-toku_checkpoint_get_status(CACHETABLE ct, CHECKPOINT_STATUS statp) {
+toku_instr_key *checkpoint_safe_mutex_key;
+toku_instr_key *checkpoint_safe_rwlock_key;
+toku_instr_key *multi_operation_lock_key;
+toku_instr_key *low_priority_multi_operation_lock_key;
+
+toku_instr_key *rwlock_cond_key;
+toku_instr_key *rwlock_wait_read_key;
+toku_instr_key *rwlock_wait_write_key;
+
+void toku_checkpoint_get_status(CACHETABLE ct, CHECKPOINT_STATUS statp) {
cp_status.init();
CP_STATUS_VAL(CP_PERIOD) = toku_get_checkpoint_period_unlocked(ct);
*statp = cp_status;
@@ -117,11 +125,14 @@ multi_operation_lock_init(void) {
#if defined(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
#else
- // TODO: need to figure out how to make writer-preferential rwlocks
- // happen on osx
+// TODO: need to figure out how to make writer-preferential rwlocks
+// happen on osx
#endif
- toku_pthread_rwlock_init(&multi_operation_lock, &attr);
- toku_pthread_rwlock_init(&low_priority_multi_operation_lock, &attr);
+ toku_pthread_rwlock_init(
+ *multi_operation_lock_key, &multi_operation_lock, &attr);
+ toku_pthread_rwlock_init(*low_priority_multi_operation_lock_key,
+ &low_priority_multi_operation_lock,
+ &attr);
pthread_rwlockattr_destroy(&attr);
locked_mo = false;
}
@@ -146,10 +157,15 @@ multi_operation_checkpoint_unlock(void) {
toku_pthread_rwlock_wrunlock(&low_priority_multi_operation_lock);
}
-static void
-checkpoint_safe_lock_init(void) {
- toku_mutex_init(&checkpoint_safe_mutex, NULL);
- checkpoint_safe_lock.init(&checkpoint_safe_mutex);
+static void checkpoint_safe_lock_init(void) {
+ toku_mutex_init(
+ *checkpoint_safe_mutex_key, &checkpoint_safe_mutex, nullptr);
+ checkpoint_safe_lock.init(&checkpoint_safe_mutex
+#ifdef TOKU_MYSQL_WITH_PFS
+ ,
+ *checkpoint_safe_rwlock_key
+#endif
+ );
locked_cs = false;
}
diff --git a/storage/tokudb/PerconaFT/ft/ft-ops.cc b/storage/tokudb/PerconaFT/ft/ft-ops.cc
index 20035b1d02f..ef2009db1b1 100644
--- a/storage/tokudb/PerconaFT/ft/ft-ops.cc
+++ b/storage/tokudb/PerconaFT/ft/ft-ops.cc
@@ -187,9 +187,35 @@ basement nodes, bulk fetch, and partial fetch:
*/
static toku_mutex_t ft_open_close_lock;
-
-void
-toku_ft_get_status(FT_STATUS s) {
+static toku_instr_key *ft_open_close_lock_mutex_key;
+// FIXME: the instrumentation keys below are defined here even though they
+// belong to other modules, because they are registered here. If desired, they
+// can be moved to their proper modules and registration done there in a
+// one-time init function
+// locktree
+toku_instr_key *treenode_mutex_key;
+toku_instr_key *manager_mutex_key;
+toku_instr_key *manager_escalation_mutex_key;
+toku_instr_key *manager_escalator_mutex_key;
+// src
+toku_instr_key *db_txn_struct_i_txn_mutex_key;
+toku_instr_key *indexer_i_indexer_lock_mutex_key;
+toku_instr_key *indexer_i_indexer_estimate_lock_mutex_key;
+toku_instr_key *result_i_open_dbs_rwlock_key;
+// locktree
+toku_instr_key *lock_request_m_wait_cond_key;
+toku_instr_key *manager_m_escalator_done_key;
+toku_instr_key *locktree_request_info_mutex_key;
+toku_instr_key *locktree_request_info_retry_mutex_key;
+toku_instr_key *locktree_request_info_retry_cv_key;
+
+// this is a sample probe for custom instrumentation
+static toku_instr_key *fti_probe_1_key;
+
+// This is a sample probe for custom instrumentation
+toku_instr_probe *toku_instr_probe_1;
+
+void toku_ft_get_status(FT_STATUS s) {
ft_status.init();
*s = ft_status;
@@ -2644,11 +2670,14 @@ void toku_ft_set_direct_io (bool direct_io_on) {
use_direct_io = direct_io_on;
}
-static inline int ft_open_maybe_direct(const char *filename, int oflag, int mode) {
+static inline int ft_open_maybe_direct(const char *filename,
+ int oflag,
+ int mode) {
if (use_direct_io) {
- return toku_os_open_direct(filename, oflag, mode);
+ return toku_os_open_direct(
+ filename, oflag, mode, *tokudb_file_data_key);
} else {
- return toku_os_open(filename, oflag, mode);
+ return toku_os_open(filename, oflag, mode, *tokudb_file_data_key);
}
}
@@ -2722,7 +2751,7 @@ bool toku_create_subdirs_if_needed(const char *path) {
if (!subdir.get())
return true;
- if (toku_stat(subdir.get(), &stat) == -1) {
+ if (toku_stat(subdir.get(), &stat, toku_uninstrumented) == -1) {
if (ENOENT == get_error_errno())
subdir_exists = false;
else
@@ -2934,6 +2963,8 @@ ft_handle_open(FT_HANDLE ft_h, const char *fname_in_env, int is_create, int only
CACHEFILE cf = NULL;
FT ft = NULL;
bool did_create = false;
+ bool was_already_open = false;
+
toku_ft_open_close_lock();
if (ft_h->did_set_flags) {
@@ -2945,7 +2976,6 @@ ft_handle_open(FT_HANDLE ft_h, const char *fname_in_env, int is_create, int only
FILENUM reserved_filenum;
reserved_filenum = use_filenum;
fname_in_cwd = toku_cachetable_get_fname_in_cwd(cachetable, fname_in_env);
- bool was_already_open;
{
int fd = -1;
r = ft_open_file(fname_in_cwd, &fd);
@@ -4615,20 +4645,265 @@ int toku_dump_ft(FILE *f, FT_HANDLE ft_handle) {
return toku_dump_ftnode(f, ft_handle, root_key, 0, 0, 0);
}
+
+static void toku_pfs_keys_init(const char *toku_instr_group_name) {
+ kibbutz_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name, "kibbutz_mutex");
+ minicron_p_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "minicron_p_mutex");
+ queue_result_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "queue_result_mutex");
+ tpool_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "tpool_lock_mutex");
+ workset_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "workset_lock_mutex");
+ bjm_jobs_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "bjm_jobs_lock_mutex");
+ log_internal_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "log_internal_lock_mutex");
+ cachetable_ev_thread_lock_mutex_key =
+ new toku_instr_key(toku_instr_object_type::mutex,
+ toku_instr_group_name,
+ "cachetable_ev_thread_lock_mutex");
+ cachetable_disk_nb_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "cachetable_disk_nb_mutex");
+ safe_file_size_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "safe_file_size_lock_mutex");
+ cachetable_m_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "cachetable_m_mutex_key");
+ checkpoint_safe_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "checkpoint_safe_mutex");
+ ft_ref_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "ft_ref_lock_mutex");
+ ft_open_close_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "ft_open_close_lock_mutex");
+ loader_error_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "loader_error_mutex");
+ bfs_mutex_key =
+ new toku_instr_key(toku_instr_object_type::mutex, toku_instr_group_name,
+ "bfs_mutex");
+ loader_bl_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "loader_bl_mutex");
+ loader_fi_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "loader_fi_lock_mutex");
+ loader_out_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "loader_out_mutex");
+ result_output_condition_lock_mutex_key =
+ new toku_instr_key(toku_instr_object_type::mutex,
+ toku_instr_group_name,
+ "result_output_condition_lock_mutex");
+ block_table_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "block_table_mutex");
+ rollback_log_node_cache_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "rollback_log_node_cache_mutex");
+ txn_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name, "txn_lock_mutex");
+ txn_state_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "txn_state_lock_mutex");
+ txn_child_manager_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "txn_child_manager_mutex");
+ txn_manager_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "txn_manager_lock_mutex");
+ treenode_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name, "treenode_mutex");
+ locktree_request_info_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "locktree_request_info_mutex");
+ locktree_request_info_retry_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "locktree_request_info_retry_mutex_key");
+ manager_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name, "manager_mutex");
+ manager_escalation_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "manager_escalation_mutex");
+ db_txn_struct_i_txn_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "db_txn_struct_i_txn_mutex");
+ manager_escalator_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "manager_escalator_mutex");
+ indexer_i_indexer_lock_mutex_key = new toku_instr_key(
+ toku_instr_object_type::mutex, toku_instr_group_name,
+ "indexer_i_indexer_lock_mutex");
+ indexer_i_indexer_estimate_lock_mutex_key =
+ new toku_instr_key(toku_instr_object_type::mutex,
+ toku_instr_group_name,
+ "indexer_i_indexer_estimate_lock_mutex");
+
+ tokudb_file_data_key = new toku_instr_key(
+ toku_instr_object_type::file, toku_instr_group_name, "tokudb_data_file");
+ tokudb_file_load_key = new toku_instr_key(
+ toku_instr_object_type::file, toku_instr_group_name, "tokudb_load_file");
+ tokudb_file_tmp_key = new toku_instr_key(
+ toku_instr_object_type::file, toku_instr_group_name, "tokudb_tmp_file");
+ tokudb_file_log_key = new toku_instr_key(
+ toku_instr_object_type::file, toku_instr_group_name, "tokudb_log_file");
+
+ fti_probe_1_key =
+ new toku_instr_key(toku_instr_object_type::mutex, toku_instr_group_name,
+ "fti_probe_1");
+
+ extractor_thread_key = new toku_instr_key(
+ toku_instr_object_type::thread, toku_instr_group_name,
+ "extractor_thread");
+ fractal_thread_key = new toku_instr_key(
+ toku_instr_object_type::thread, toku_instr_group_name, "fractal_thread");
+ io_thread_key =
+ new toku_instr_key(toku_instr_object_type::thread, toku_instr_group_name,
+ "io_thread");
+ eviction_thread_key = new toku_instr_key(
+ toku_instr_object_type::thread, toku_instr_group_name,
+ "eviction_thread");
+ kibbutz_thread_key = new toku_instr_key(
+ toku_instr_object_type::thread, toku_instr_group_name, "kibbutz_thread");
+ minicron_thread_key = new toku_instr_key(
+ toku_instr_object_type::thread, toku_instr_group_name,
+ "minicron_thread");
+ tp_internal_thread_key = new toku_instr_key(
+ toku_instr_object_type::thread, toku_instr_group_name,
+ "tp_internal_thread");
+
+ result_state_cond_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "result_state_cond");
+ bjm_jobs_wait_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name, "bjm_jobs_wait");
+ cachetable_p_refcount_wait_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "cachetable_p_refcount_wait");
+ cachetable_m_flow_control_cond_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "cachetable_m_flow_control_cond");
+ cachetable_m_ev_thread_cond_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "cachetable_m_ev_thread_cond");
+ bfs_cond_key =
+ new toku_instr_key(toku_instr_object_type::cond, toku_instr_group_name,
+ "bfs_cond");
+ result_output_condition_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "result_output_condition");
+ manager_m_escalator_done_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "manager_m_escalator_done");
+ lock_request_m_wait_cond_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "lock_request_m_wait_cond");
+ queue_result_cond_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "queue_result_cond");
+ ws_worker_wait_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name, "ws_worker_wait");
+ rwlock_wait_read_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name, "rwlock_wait_read");
+ rwlock_wait_write_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "rwlock_wait_write");
+ rwlock_cond_key =
+ new toku_instr_key(toku_instr_object_type::cond, toku_instr_group_name,
+ "rwlock_cond");
+ tp_thread_wait_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name, "tp_thread_wait");
+ tp_pool_wait_free_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "tp_pool_wait_free");
+ frwlock_m_wait_read_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "frwlock_m_wait_read");
+ kibbutz_k_cond_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name, "kibbutz_k_cond");
+ minicron_p_condvar_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "minicron_p_condvar");
+ locktree_request_info_retry_cv_key = new toku_instr_key(
+ toku_instr_object_type::cond, toku_instr_group_name,
+ "locktree_request_info_retry_cv_key");
+
+ multi_operation_lock_key = new toku_instr_key(
+ toku_instr_object_type::rwlock, toku_instr_group_name,
+ "multi_operation_lock");
+ low_priority_multi_operation_lock_key =
+ new toku_instr_key(toku_instr_object_type::rwlock,
+ toku_instr_group_name,
+ "low_priority_multi_operation_lock");
+ cachetable_m_list_lock_key = new toku_instr_key(
+ toku_instr_object_type::rwlock, toku_instr_group_name,
+ "cachetable_m_list_lock");
+ cachetable_m_pending_lock_expensive_key =
+ new toku_instr_key(toku_instr_object_type::rwlock,
+ toku_instr_group_name,
+ "cachetable_m_pending_lock_expensive");
+ cachetable_m_pending_lock_cheap_key =
+ new toku_instr_key(toku_instr_object_type::rwlock,
+ toku_instr_group_name,
+ "cachetable_m_pending_lock_cheap");
+ cachetable_m_lock_key = new toku_instr_key(
+ toku_instr_object_type::rwlock, toku_instr_group_name,
+ "cachetable_m_lock");
+ result_i_open_dbs_rwlock_key = new toku_instr_key(
+ toku_instr_object_type::rwlock, toku_instr_group_name,
+ "result_i_open_dbs_rwlock");
+ checkpoint_safe_rwlock_key = new toku_instr_key(
+ toku_instr_object_type::rwlock, toku_instr_group_name,
+ "checkpoint_safe_rwlock");
+ cachetable_value_key = new toku_instr_key(
+ toku_instr_object_type::rwlock, toku_instr_group_name,
+ "cachetable_value");
+ safe_file_size_lock_rwlock_key = new toku_instr_key(
+ toku_instr_object_type::rwlock, toku_instr_group_name,
+ "safe_file_size_lock_rwlock");
+ cachetable_disk_nb_rwlock_key = new toku_instr_key(
+ toku_instr_object_type::rwlock, toku_instr_group_name,
+ "cachetable_disk_nb_rwlock");
+
+ toku_instr_probe_1 = new toku_instr_probe(*fti_probe_1_key);
+}
+
int toku_ft_layer_init(void) {
int r = 0;
- //Portability must be initialized first
+
+ // Portability must be initialized first
r = toku_portability_init();
- if (r) { goto exit; }
+ if (r) {
+ goto exit;
+ }
+
+ toku_pfs_keys_init("fti");
+
r = db_env_set_toku_product_name("tokudb");
- if (r) { goto exit; }
+ if (r) {
+ goto exit;
+ }
partitioned_counters_init();
toku_status_init();
toku_context_status_init();
toku_checkpoint_init();
toku_ft_serialize_layer_init();
- toku_mutex_init(&ft_open_close_lock, NULL);
+ toku_mutex_init(
+ *ft_open_close_lock_mutex_key, &ft_open_close_lock, nullptr);
toku_scoped_malloc_init();
exit:
return r;
@@ -4642,7 +4917,10 @@ void toku_ft_layer_destroy(void) {
toku_status_destroy();
partitioned_counters_destroy();
toku_scoped_malloc_destroy();
- //Portability must be cleaned up last
+
+ delete toku_instr_probe_1;
+
+ // Portability must be cleaned up last
toku_portability_destroy();
}
diff --git a/storage/tokudb/PerconaFT/ft/ft.cc b/storage/tokudb/PerconaFT/ft/ft.cc
index abc9d295eae..c7c2ea33c9e 100644
--- a/storage/tokudb/PerconaFT/ft/ft.cc
+++ b/storage/tokudb/PerconaFT/ft/ft.cc
@@ -51,9 +51,10 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include <toku_assert.h>
#include <portability/toku_atomic.h>
-void
-toku_reset_root_xid_that_created(FT ft, TXNID new_root_xid_that_created) {
- // Reset the root_xid_that_created field to the given value.
+toku_instr_key *ft_ref_lock_mutex_key;
+
+void toku_reset_root_xid_that_created(FT ft, TXNID new_root_xid_that_created) {
+ // Reset the root_xid_that_created field to the given value.
// This redefines which xid created the dictionary.
// hold lock around setting and clearing of dirty bit
@@ -101,15 +102,11 @@ toku_ft_free (FT ft) {
toku_free(ft);
}
-void
-toku_ft_init_reflock(FT ft) {
- toku_mutex_init(&ft->ft_ref_lock, NULL);
+void toku_ft_init_reflock(FT ft) {
+ toku_mutex_init(*ft_ref_lock_mutex_key, &ft->ft_ref_lock, nullptr);
}
-void
-toku_ft_destroy_reflock(FT ft) {
- toku_mutex_destroy(&ft->ft_ref_lock);
-}
+void toku_ft_destroy_reflock(FT ft) { toku_mutex_destroy(&ft->ft_ref_lock); }
void
toku_ft_grab_reflock(FT ft) {
diff --git a/storage/tokudb/PerconaFT/ft/loader/callbacks.cc b/storage/tokudb/PerconaFT/ft/loader/callbacks.cc
index 6a520dba3a3..ac69fb7e789 100644
--- a/storage/tokudb/PerconaFT/ft/loader/callbacks.cc
+++ b/storage/tokudb/PerconaFT/ft/loader/callbacks.cc
@@ -45,6 +45,8 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "loader/loader-internal.h"
#include "util/dbt.h"
+toku_instr_key *loader_error_mutex_key;
+
static void error_callback_lock(ft_loader_error_callback loader_error) {
toku_mutex_lock(&loader_error->mutex);
}
@@ -57,10 +59,10 @@ void ft_loader_init_error_callback(ft_loader_error_callback loader_error) {
memset(loader_error, 0, sizeof *loader_error);
toku_init_dbt(&loader_error->key);
toku_init_dbt(&loader_error->val);
- toku_mutex_init(&loader_error->mutex, NULL);
+ toku_mutex_init(*loader_error_mutex_key, &loader_error->mutex, nullptr);
}
-void ft_loader_destroy_error_callback(ft_loader_error_callback loader_error) {
+void ft_loader_destroy_error_callback(ft_loader_error_callback loader_error) {
toku_mutex_destroy(&loader_error->mutex);
toku_destroy_dbt(&loader_error->key);
toku_destroy_dbt(&loader_error->val);
diff --git a/storage/tokudb/PerconaFT/ft/loader/dbufio.cc b/storage/tokudb/PerconaFT/ft/loader/dbufio.cc
index ad084a4fbdc..90f76cecf90 100644
--- a/storage/tokudb/PerconaFT/ft/loader/dbufio.cc
+++ b/storage/tokudb/PerconaFT/ft/loader/dbufio.cc
@@ -49,6 +49,10 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "loader/dbufio.h"
#include "loader/loader-internal.h"
+toku_instr_key *bfs_mutex_key;
+toku_instr_key *bfs_cond_key;
+toku_instr_key *io_thread_key;
+
struct dbufio_file {
// i/o thread owns these
int fd;
@@ -276,39 +280,44 @@ static void* io_thread (void *v)
toku_mutex_lock(&bfs->mutex);
//printf("%s:%d Locked\n", __FILE__, __LINE__);
while (1) {
+ if (paniced(bfs)) {
+ toku_mutex_unlock(&bfs->mutex); // ignore any error
+ toku_instr_delete_current_thread();
+ return toku_pthread_done(nullptr);
+ }
+ // printf("n_not_done=%d\n", bfs->n_not_done);
+ if (bfs->n_not_done == 0) {
+ // all done (meaning we stored EOF (or another error) in
+ // error_code[0] for the file.
+ // printf("unlocked\n");
+ toku_mutex_unlock(&bfs->mutex);
+ toku_instr_delete_current_thread();
+ return toku_pthread_done(nullptr);
+ }
- if (paniced(bfs)) {
- toku_mutex_unlock(&bfs->mutex); // ignore any error
- return 0;
- }
- //printf("n_not_done=%d\n", bfs->n_not_done);
- if (bfs->n_not_done==0) {
- // all done (meaning we stored EOF (or another error) in error_code[0] for the file.
- //printf("unlocked\n");
- toku_mutex_unlock(&bfs->mutex);
- return 0;
- }
-
- struct dbufio_file *dbf = bfs->head;
- if (dbf==NULL) {
- // No I/O needs to be done yet.
- // Wait until something happens that will wake us up.
- toku_cond_wait(&bfs->cond, &bfs->mutex);
- if (paniced(bfs)) {
- toku_mutex_unlock(&bfs->mutex); // ignore any error
- return 0;
- }
- // Have the lock so go around.
- } else {
- // Some I/O needs to be done.
- //printf("%s:%d Need I/O\n", __FILE__, __LINE__);
- assert(dbf->second_buf_ready == false);
- assert(!dbf->io_done);
- bfs->head = dbf->next;
- if (bfs->head==NULL) bfs->tail=NULL;
-
- // Unlock the mutex now that we have ownership of dbf to allow consumers to get the mutex and perform swaps. They won't swap
- // this buffer because second_buf_ready is false.
+ struct dbufio_file *dbf = bfs->head;
+ if (dbf == NULL) {
+ // No I/O needs to be done yet.
+ // Wait until something happens that will wake us up.
+ toku_cond_wait(&bfs->cond, &bfs->mutex);
+ if (paniced(bfs)) {
+ toku_mutex_unlock(&bfs->mutex); // ignore any error
+ toku_instr_delete_current_thread();
+ return toku_pthread_done(nullptr);
+ }
+ // Have the lock so go around.
+ } else {
+ // Some I/O needs to be done.
+ // printf("%s:%d Need I/O\n", __FILE__, __LINE__);
+ assert(dbf->second_buf_ready == false);
+ assert(!dbf->io_done);
+ bfs->head = dbf->next;
+ if (bfs->head == NULL)
+ bfs->tail = NULL;
+
+ // Unlock the mutex now that we have ownership of dbf to allow
+ // consumers to get the mutex and perform swaps. They won't swap
+ // this buffer because second_buf_ready is false.
toku_mutex_unlock(&bfs->mutex);
//printf("%s:%d Doing read fd=%d\n", __FILE__, __LINE__, dbf->fd);
{
@@ -339,14 +348,16 @@ static void* io_thread (void *v)
//printf("%s:%d locking mutex again=%ld\n", __FILE__, __LINE__, readcode);
{
- toku_mutex_lock(&bfs->mutex);
- if (paniced(bfs)) {
- toku_mutex_unlock(&bfs->mutex); // ignore any error
- return 0;
- }
- }
- // Now that we have the mutex, we can decrement n_not_done (if applicable) and set second_buf_ready
- if (readcode<=0) {
+ toku_mutex_lock(&bfs->mutex);
+ if (paniced(bfs)) {
+ toku_mutex_unlock(&bfs->mutex); // ignore any error
+ toku_instr_delete_current_thread();
+ return toku_pthread_done(nullptr);
+ }
+ }
+ // Now that we have the mutex, we can decrement n_not_done (if
+ // applicable) and set second_buf_ready
+ if (readcode<=0) {
bfs->n_not_done--;
}
//printf("%s:%d n_not_done=%d\n", __FILE__, __LINE__, bfs->n_not_done);
@@ -377,34 +388,36 @@ int create_dbufio_fileset (DBUFIO_FILESET *bfsp, int N, int fds[/*N*/], size_t b
}
}
}
- //printf("%s:%d here\n", __FILE__, __LINE__);
- if (result==0) {
- toku_mutex_init(&bfs->mutex, NULL);
- mutex_inited = true;
+ // printf("%s:%d here\n", __FILE__, __LINE__);
+ if (result == 0) {
+ toku_mutex_init(*bfs_mutex_key, &bfs->mutex, nullptr);
+ mutex_inited = true;
}
- if (result==0) {
- toku_cond_init(&bfs->cond, NULL);
- cond_inited = true;
+ if (result == 0) {
+ toku_cond_init(*bfs_cond_key, &bfs->cond, nullptr);
+ cond_inited = true;
}
- if (result==0) {
- bfs->N = N;
- bfs->n_not_done = N;
- bfs->head = bfs->tail = NULL;
- for (int i=0; i<N; i++) {
- bfs->files[i].fd = fds[i];
- bfs->files[i].offset_in_buf = 0;
- bfs->files[i].offset_in_uncompressed_file = 0;
- bfs->files[i].next = NULL;
- bfs->files[i].second_buf_ready = false;
- for (int j=0; j<2; j++) {
- if (result==0) {
- MALLOC_N(bufsize, bfs->files[i].buf[j]);
- if (bfs->files[i].buf[j]==NULL) { result=get_error_errno(); }
- }
- bfs->files[i].n_in_buf[j] = 0;
- bfs->files[i].error_code[j] = 0;
- }
- bfs->files[i].io_done = false;
+ if (result == 0) {
+ bfs->N = N;
+ bfs->n_not_done = N;
+ bfs->head = bfs->tail = NULL;
+ for (int i = 0; i < N; i++) {
+ bfs->files[i].fd = fds[i];
+ bfs->files[i].offset_in_buf = 0;
+ bfs->files[i].offset_in_uncompressed_file = 0;
+ bfs->files[i].next = NULL;
+ bfs->files[i].second_buf_ready = false;
+ for (int j = 0; j < 2; j++) {
+ if (result == 0) {
+ MALLOC_N(bufsize, bfs->files[i].buf[j]);
+ if (bfs->files[i].buf[j] == NULL) {
+ result = get_error_errno();
+ }
+ }
+ bfs->files[i].n_in_buf[j] = 0;
+ bfs->files[i].error_code[j] = 0;
+ }
+ bfs->files[i].io_done = false;
ssize_t r;
if (bfs->compressed) {
r = dbf_read_compressed(&bfs->files[i], bfs->files[i].buf[0], bufsize);
@@ -431,13 +444,21 @@ int create_dbufio_fileset (DBUFIO_FILESET *bfsp, int N, int fds[/*N*/], size_t b
bfs->panic = false;
bfs->panic_errno = 0;
}
- //printf("Creating IO thread\n");
- if (result==0) {
- result = toku_pthread_create(&bfs->iothread, NULL, io_thread, (void*)bfs);
+ // printf("Creating IO thread\n");
+ if (result == 0) {
+ result = toku_pthread_create(*io_thread_key,
+ &bfs->iothread,
+ nullptr,
+ io_thread,
+ static_cast<void *>(bfs));
+ }
+ if (result == 0) {
+ *bfsp = bfs;
+ return 0;
}
- if (result==0) { *bfsp = bfs; return 0; }
// Now undo everything.
- // If we got here, there is no thread (either result was zero before the thread was created, or else the thread creation itself failed.
+ // If we got here, there is no thread (either result was zero before the
+ // thread was created, or else the thread creation itself failed.
if (bfs) {
if (bfs->files) {
// the files were allocated, so we have to free all the bufs.
diff --git a/storage/tokudb/PerconaFT/ft/loader/loader-internal.h b/storage/tokudb/PerconaFT/ft/loader/loader-internal.h
index 1aa2c203831..6f7b0147b21 100644
--- a/storage/tokudb/PerconaFT/ft/loader/loader-internal.h
+++ b/storage/tokudb/PerconaFT/ft/loader/loader-internal.h
@@ -64,10 +64,10 @@ enum {
/* These structures maintain a collection of all the open temporary files used by the loader. */
struct file_info {
bool is_open;
- bool is_extant; // if true, the file must be unlinked.
+ bool is_extant; // if true, the file must be unlinked.
char *fname;
- FILE *file;
- uint64_t n_rows; // how many rows were written into that file
+ TOKU_FILE *file;
+ uint64_t n_rows; // how many rows were written into that file
size_t buffer_size;
void *buffer;
};
@@ -80,11 +80,11 @@ struct file_infos {
};
typedef struct fidx { int idx; } FIDX;
static const FIDX FIDX_NULL __attribute__((__unused__)) = {-1};
-static int fidx_is_null (const FIDX f) __attribute__((__unused__));
-static int fidx_is_null (const FIDX f) { return f.idx==-1; }
-FILE *toku_bl_fidx2file (FTLOADER bl, FIDX i);
+static int fidx_is_null(const FIDX f) __attribute__((__unused__));
+static int fidx_is_null(const FIDX f) { return f.idx == -1; }
+TOKU_FILE *toku_bl_fidx2file(FTLOADER bl, FIDX i);
-int ft_loader_open_temp_file (FTLOADER bl, FIDX*file_idx);
+int ft_loader_open_temp_file(FTLOADER bl, FIDX *file_idx);
/* These data structures are used for manipulating a collection of rows in main memory. */
struct row {
@@ -100,11 +100,17 @@ struct rowset {
};
int init_rowset (struct rowset *rows, uint64_t memory_budget);
-void destroy_rowset (struct rowset *rows);
-int add_row (struct rowset *rows, DBT *key, DBT *val);
-
-int loader_write_row(DBT *key, DBT *val, FIDX data, FILE*, uint64_t *dataoff, struct wbuf *wb, FTLOADER bl);
-int loader_read_row (FILE *f, DBT *key, DBT *val);
+void destroy_rowset(struct rowset *rows);
+int add_row(struct rowset *rows, DBT *key, DBT *val);
+
+int loader_write_row(DBT *key,
+ DBT *val,
+ FIDX data,
+ TOKU_FILE *,
+ uint64_t *dataoff,
+ struct wbuf *wb,
+ FTLOADER bl);
+int loader_read_row(TOKU_FILE *f, DBT *key, DBT *val);
struct merge_fileset {
bool have_sorted_output; // Is there an previous key?
@@ -195,12 +201,13 @@ struct ft_loader_s {
bool did_reserve_memory;
bool compress_intermediates;
bool allow_puts;
- uint64_t reserved_memory; // how much memory are we allowed to use?
+ uint64_t reserved_memory; // how much memory are we allowed to use?
- /* To make it easier to recover from errors, we don't use FILE*, instead we use an index into the file_infos. */
+ /* To make it easier to recover from errors, we don't use TOKU_FILE*,
+ * instead we use an index into the file_infos. */
struct file_infos file_infos;
-#define PROGRESS_MAX (1<<16)
+#define PROGRESS_MAX (1 << 16)
int progress; // Progress runs from 0 to PROGRESS_MAX. When we call the poll function we convert to a float from 0.0 to 1.0
// We use an integer so that we can add to the progress using a fetch-and-add instruction.
diff --git a/storage/tokudb/PerconaFT/ft/loader/loader.cc b/storage/tokudb/PerconaFT/ft/loader/loader.cc
index f867639b953..5f57b473bc5 100644
--- a/storage/tokudb/PerconaFT/ft/loader/loader.cc
+++ b/storage/tokudb/PerconaFT/ft/loader/loader.cc
@@ -63,21 +63,17 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "util/x1764.h"
-static size_t (*os_fwrite_fun)(const void *,size_t,size_t,FILE*)=NULL;
-void ft_loader_set_os_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*)) {
- os_fwrite_fun=fwrite_fun;
-}
+toku_instr_key *loader_bl_mutex_key;
+toku_instr_key *loader_fi_lock_mutex_key;
+toku_instr_key *loader_out_mutex_key;
-static size_t do_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream) {
- if (os_fwrite_fun) {
- return os_fwrite_fun(ptr, size, nmemb, stream);
- } else {
- return fwrite(ptr, size, nmemb, stream);
- }
-}
+toku_instr_key *extractor_thread_key;
+toku_instr_key *fractal_thread_key;
+toku_instr_key *tokudb_file_tmp_key;
+toku_instr_key *tokudb_file_load_key;
-// 1024 is the right size_factor for production.
+// 1024 is the right size_factor for production.
// Different values for these sizes may be used for testing.
static uint32_t size_factor = 1024;
static uint32_t default_loader_nodesize = FT_DEFAULT_NODE_SIZE;
@@ -99,7 +95,7 @@ toku_ft_loader_get_rowset_budget_for_testing (void)
void ft_loader_lock_init(FTLOADER bl) {
invariant(!bl->mutex_init);
- toku_mutex_init(&bl->mutex, NULL);
+ toku_mutex_init(*loader_bl_mutex_key, &bl->mutex, nullptr);
bl->mutex_init = true;
}
@@ -131,7 +127,10 @@ static int add_big_buffer(struct file_info *file) {
newbuffer = true;
}
if (result == 0) {
- int r = setvbuf(file->file, (char *) file->buffer, _IOFBF, file->buffer_size);
+ int r = setvbuf(file->file->file,
+ static_cast<char *>(file->buffer),
+ _IOFBF,
+ file->buffer_size);
if (r != 0) {
result = get_error_errno();
if (newbuffer) {
@@ -150,9 +149,9 @@ static void cleanup_big_buffer(struct file_info *file) {
}
}
-int ft_loader_init_file_infos (struct file_infos *fi) {
+int ft_loader_init_file_infos(struct file_infos *fi) {
int result = 0;
- toku_mutex_init(&fi->lock, NULL);
+ toku_mutex_init(*loader_fi_lock_mutex_key, &fi->lock, nullptr);
fi->n_files = 0;
fi->n_files_limit = 1;
fi->n_files_open = 0;
@@ -196,11 +195,10 @@ void ft_loader_fi_destroy (struct file_infos *fi, bool is_error)
fi->file_infos = NULL;
}
-static int open_file_add (struct file_infos *fi,
- FILE *file,
- char *fname,
- /* out */ FIDX *idx)
-{
+static int open_file_add(struct file_infos *fi,
+ TOKU_FILE *file,
+ char *fname,
+ /* out */ FIDX *idx) {
int result = 0;
toku_mutex_lock(&fi->lock);
if (fi->n_files >= fi->n_files_limit) {
@@ -230,11 +228,12 @@ int ft_loader_fi_reopen (struct file_infos *fi, FIDX idx, const char *mode) {
int result = 0;
toku_mutex_lock(&fi->lock);
int i = idx.idx;
- invariant(i>=0 && i<fi->n_files);
+ invariant(i >= 0 && i < fi->n_files);
invariant(!fi->file_infos[i].is_open);
invariant(fi->file_infos[i].is_extant);
- fi->file_infos[i].file = toku_os_fopen(fi->file_infos[i].fname, mode);
- if (fi->file_infos[i].file == NULL) {
+ fi->file_infos[i].file =
+ toku_os_fopen(fi->file_infos[i].fname, mode, *tokudb_file_load_key);
+ if (fi->file_infos[i].file == NULL) {
result = get_error_errno();
} else {
fi->file_infos[i].is_open = true;
@@ -307,20 +306,20 @@ int ft_loader_open_temp_file (FTLOADER bl, FIDX *file_idx)
*/
{
int result = 0;
- if (result) // debug hack
+ if (result) // debug hack
return result;
- FILE *f = NULL;
+ TOKU_FILE *f = NULL;
int fd = -1;
- char *fname = toku_strdup(bl->temp_file_template);
+ char *fname = toku_strdup(bl->temp_file_template);
if (fname == NULL)
result = get_error_errno();
else {
fd = mkstemp(fname);
- if (fd < 0) {
+ if (fd < 0) {
result = get_error_errno();
} else {
- f = toku_os_fdopen(fd, "r+");
- if (f == NULL)
+ f = toku_os_fdopen(fd, "r+", fname, *tokudb_file_tmp_key);
+ if (f->file == nullptr)
result = get_error_errno();
else
result = open_file_add(&bl->file_infos, f, fname, file_idx);
@@ -339,7 +338,7 @@ int ft_loader_open_temp_file (FTLOADER bl, FIDX *file_idx)
return result;
}
-void toku_ft_loader_internal_destroy (FTLOADER bl, bool is_error) {
+void toku_ft_loader_internal_destroy(FTLOADER bl, bool is_error) {
ft_loader_lock_destroy(bl);
// These frees rely on the fact that if you free a NULL pointer then nothing bad happens.
@@ -635,12 +634,16 @@ int toku_ft_loader_open (FTLOADER *blp, /* out */
allow_puts);
if (r!=0) result = r;
}
- if (result==0 && allow_puts) {
+ if (result == 0 && allow_puts) {
FTLOADER bl = *blp;
- int r = toku_pthread_create(&bl->extractor_thread, NULL, extractor_thread, (void*)bl);
- if (r==0) {
+ int r = toku_pthread_create(*extractor_thread_key,
+ &bl->extractor_thread,
+ nullptr,
+ extractor_thread,
+ static_cast<void *>(bl));
+ if (r == 0) {
bl->extractor_live = true;
- } else {
+ } else {
result = r;
(void) toku_ft_loader_internal_destroy(bl, true);
}
@@ -659,17 +662,17 @@ static void ft_loader_set_panic(FTLOADER bl, int error, bool callback, int which
}
// One of the tests uses this.
-FILE *toku_bl_fidx2file (FTLOADER bl, FIDX i) {
+TOKU_FILE *toku_bl_fidx2file(FTLOADER bl, FIDX i) {
toku_mutex_lock(&bl->file_infos.lock);
- invariant(i.idx >=0 && i.idx < bl->file_infos.n_files);
+ invariant(i.idx >= 0 && i.idx < bl->file_infos.n_files);
invariant(bl->file_infos.file_infos[i.idx].is_open);
- FILE *result=bl->file_infos.file_infos[i.idx].file;
+ TOKU_FILE *result = bl->file_infos.file_infos[i.idx].file;
toku_mutex_unlock(&bl->file_infos.lock);
return result;
}
-static int bl_finish_compressed_write(FILE *stream, struct wbuf *wb) {
- int r;
+static int bl_finish_compressed_write(TOKU_FILE *stream, struct wbuf *wb) {
+ int r = 0;
char *compressed_buf = NULL;
const size_t data_size = wb->ndone;
invariant(data_size > 0);
@@ -720,31 +723,23 @@ static int bl_finish_compressed_write(FILE *stream, struct wbuf *wb) {
// Mark as written
wb->ndone = 0;
- size_t size_to_write = total_size + 4; // Includes writing total_size
+ size_t size_to_write = total_size + 4; // Includes writing total_size
+
+ r = toku_os_fwrite(compressed_buf, 1, size_to_write, stream);
- {
- size_t written = do_fwrite(compressed_buf, 1, size_to_write, stream);
- if (written!=size_to_write) {
- if (os_fwrite_fun) // if using hook to induce artificial errors (for testing) ...
- r = get_maybe_error_errno(); // ... then there is no error in the stream, but there is one in errno
- else
- r = ferror(stream);
- invariant(r!=0);
- goto exit;
- }
- }
- r = 0;
-exit:
if (compressed_buf) {
toku_free(compressed_buf);
}
return r;
}
-static int bl_compressed_write(void *ptr, size_t nbytes, FILE *stream, struct wbuf *wb) {
+static int bl_compressed_write(void *ptr,
+ size_t nbytes,
+ TOKU_FILE *stream,
+ struct wbuf *wb) {
invariant(wb->size <= MAX_UNCOMPRESSED_BUF);
size_t bytes_left = nbytes;
- char *buf = (char*)ptr;
+ char *buf = (char *)ptr;
while (bytes_left > 0) {
size_t bytes_to_copy = bytes_left;
@@ -767,29 +762,28 @@ static int bl_compressed_write(void *ptr, size_t nbytes, FILE *stream, struct wb
return 0;
}
-static int bl_fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream, struct wbuf *wb, FTLOADER bl)
-/* Effect: this is a wrapper for fwrite that returns 0 on success, otherwise returns an error number.
+static int bl_fwrite(void *ptr,
+ size_t size,
+ size_t nmemb,
+ TOKU_FILE *stream,
+ struct wbuf *wb,
+ FTLOADER bl)
+/* Effect: this is a wrapper for fwrite that returns 0 on success, otherwise
+ * returns an error number.
* Arguments:
* ptr the data to be writen.
* size the amount of data to be written.
* nmemb the number of units of size to be written.
* stream write the data here.
- * wb where to write uncompressed data (if we're compressing) or ignore if NULL
- * bl passed so we can panic the ft_loader if something goes wrong (recording the error number).
+ * wb where to write uncompressed data (if we're compressing) or ignore if
+ * NULL
+ * bl passed so we can panic the ft_loader if something goes wrong
+ * (recording the error number).
* Return value: 0 on success, an error number otherwise.
*/
{
if (!bl->compress_intermediates || !wb) {
- size_t r = do_fwrite(ptr, size, nmemb, stream);
- if (r!=nmemb) {
- int e;
- if (os_fwrite_fun) // if using hook to induce artificial errors (for testing) ...
- e = get_maybe_error_errno(); // ... then there is no error in the stream, but there is one in errno
- else
- e = ferror(stream);
- invariant(e!=0);
- return e;
- }
+ return toku_os_fwrite(ptr, size, nmemb, stream);
} else {
size_t num_bytes = size * nmemb;
int r = bl_compressed_write(ptr, num_bytes, stream, wb);
@@ -800,8 +794,9 @@ static int bl_fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream, struct
return 0;
}
-static int bl_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
-/* Effect: this is a wrapper for fread that returns 0 on success, otherwise returns an error number.
+static int bl_fread(void *ptr, size_t size, size_t nmemb, TOKU_FILE *stream)
+/* Effect: this is a wrapper for fread that returns 0 on success, otherwise
+ * returns an error number.
* Arguments:
* ptr read data into here.
* size size of data element to be read.
@@ -810,24 +805,14 @@ static int bl_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
* Return value: 0 on success, an error number otherwise.
*/
{
- size_t r = fread(ptr, size, nmemb, stream);
- if (r==0) {
- if (feof(stream)) return EOF;
- else {
- do_error: ;
- int e = ferror(stream);
- // r == 0 && !feof && e == 0, how does this happen? invariant(e!=0);
- return e;
- }
- } else if (r<nmemb) {
- goto do_error;
- } else {
- return 0;
- }
+ return toku_os_fread(ptr, size, nmemb, stream);
}
-static int bl_write_dbt (DBT *dbt, FILE* datafile, uint64_t *dataoff, struct wbuf *wb, FTLOADER bl)
-{
+static int bl_write_dbt(DBT *dbt,
+ TOKU_FILE *datafile,
+ uint64_t *dataoff,
+ struct wbuf *wb,
+ FTLOADER bl) {
int r;
int dlen = dbt->size;
if ((r=bl_fwrite(&dlen, sizeof(dlen), 1, datafile, wb, bl))) return r;
@@ -837,8 +822,7 @@ static int bl_write_dbt (DBT *dbt, FILE* datafile, uint64_t *dataoff, struct wbu
return 0;
}
-static int bl_read_dbt (/*in*/DBT *dbt, FILE *stream)
-{
+static int bl_read_dbt(/*in*/ DBT *dbt, TOKU_FILE *stream) {
int len;
{
int r;
@@ -892,13 +876,20 @@ static int bl_read_dbt_from_dbufio (/*in*/DBT *dbt, DBUFIO_FILESET bfs, int file
return result;
}
-
-int loader_write_row(DBT *key, DBT *val, FIDX data, FILE *dataf, uint64_t *dataoff, struct wbuf *wb, FTLOADER bl)
-/* Effect: Given a key and a val (both DBTs), write them to a file. Increment *dataoff so that it's up to date.
+int loader_write_row(DBT *key,
+ DBT *val,
+ FIDX data,
+ TOKU_FILE *dataf,
+ uint64_t *dataoff,
+ struct wbuf *wb,
+ FTLOADER bl)
+/* Effect: Given a key and a val (both DBTs), write them to a file. Increment
+ * *dataoff so that it's up to date.
* Arguments:
* key, val write these.
* data the file to write them to
- * dataoff a pointer to a counter that keeps track of the amount of data written so far.
+ * dataoff a pointer to a counter that keeps track of the amount of data
+ * written so far.
* wb a pointer (possibly NULL) to buffer uncompressed output
* bl the ft_loader (passed so we can panic if needed).
* Return value: 0 on success, an error number otherwise.
@@ -916,8 +907,9 @@ int loader_write_row(DBT *key, DBT *val, FIDX data, FILE *dataf, uint64_t *datao
return 0;
}
-int loader_read_row (FILE *f, DBT *key, DBT *val)
-/* Effect: Read a key value pair from a file. The DBTs must have DB_DBT_REALLOC set.
+int loader_read_row(TOKU_FILE *f, DBT *key, DBT *val)
+/* Effect: Read a key value pair from a file. The DBTs must have DB_DBT_REALLOC
+ * set.
* Arguments:
* f where to read it from.
* key, val read it into these.
@@ -1087,7 +1079,7 @@ static void* extractor_thread (void *blv) {
FTLOADER bl = (FTLOADER)blv;
int r = 0;
while (1) {
- void *item;
+ void *item = nullptr;
{
int rq = toku_queue_deq(bl->primary_rowset_queue, &item, NULL, NULL);
if (rq==EOF) break;
@@ -1108,14 +1100,14 @@ static void* extractor_thread (void *blv) {
//printf("%s:%d extractor finishing\n", __FILE__, __LINE__);
if (r == 0) {
r = finish_primary_rows(bl);
- if (r)
+ if (r)
ft_loader_set_panic(bl, r, false, 0, nullptr, nullptr);
-
}
- return NULL;
+ toku_instr_delete_current_thread();
+ return nullptr;
}
-static void enqueue_for_extraction (FTLOADER bl) {
+static void enqueue_for_extraction(FTLOADER bl) {
//printf("%s:%d enqueing %ld items\n", __FILE__, __LINE__, bl->primary_rowset.n_rows);
struct rowset *XMALLOC(enqueue_me);
*enqueue_me = bl->primary_rowset;
@@ -1626,11 +1618,12 @@ static int write_rowset_to_file (FTLOADER bl, FIDX sfile, const struct rowset ro
struct wbuf wb;
wbuf_init(&wb, uncompressed_buffer, MAX_UNCOMPRESSED_BUF);
- FILE *sstream = toku_bl_fidx2file(bl, sfile);
- for (size_t i=0; i<rows.n_rows; i++) {
- DBT skey = make_dbt(rows.data + rows.rows[i].off, rows.rows[i].klen);
- DBT sval = make_dbt(rows.data + rows.rows[i].off + rows.rows[i].klen, rows.rows[i].vlen);
-
+ TOKU_FILE *sstream = toku_bl_fidx2file(bl, sfile);
+ for (size_t i = 0; i < rows.n_rows; i++) {
+ DBT skey = make_dbt(rows.data + rows.rows[i].off, rows.rows[i].klen);
+ DBT sval = make_dbt(rows.data + rows.rows[i].off + rows.rows[i].klen,
+ rows.rows[i].vlen);
+
uint64_t soffset=0; // don't really need this.
r = loader_write_row(&skey, &sval, sfile, sstream, &soffset, &wb, bl);
if (r != 0) {
@@ -1727,14 +1720,30 @@ int ft_loader_sort_and_write_rows (struct rowset *rows, struct merge_fileset *fs
return sort_and_write_rows (*rows, fs, bl, which_db, dest_db, compare);
}
-int toku_merge_some_files_using_dbufio (const bool to_q, FIDX dest_data, QUEUE q, int n_sources, DBUFIO_FILESET bfs, FIDX srcs_fidxs[/*n_sources*/], FTLOADER bl, int which_db, DB *dest_db, ft_compare_func compare, int progress_allocation)
-/* Effect: Given an array of FILE*'s each containing sorted, merge the data and write it to an output. All the files remain open after the merge.
- * This merge is performed in one pass, so don't pass too many files in. If you need a tree of merges do it elsewhere.
- * If TO_Q is true then we write rowsets into queue Q. Otherwise we write into dest_data.
- * Modifies: May modify the arrays of files (but if modified, it must be a permutation so the caller can use that array to close everything.)
- * Requires: The number of sources is at least one, and each of the input files must have at least one row in it.
+int toku_merge_some_files_using_dbufio(const bool to_q,
+ FIDX dest_data,
+ QUEUE q,
+ int n_sources,
+ DBUFIO_FILESET bfs,
+ FIDX srcs_fidxs[/*n_sources*/],
+ FTLOADER bl,
+ int which_db,
+ DB *dest_db,
+ ft_compare_func compare,
+ int progress_allocation)
+/* Effect: Given an array of FILE*'s each containing sorted, merge the data and
+ * write it to an output. All the files remain open after the merge.
+ * This merge is performed in one pass, so don't pass too many files in. If
+ * you need a tree of merges do it elsewhere.
+ * If TO_Q is true then we write rowsets into queue Q. Otherwise we write
+ * into dest_data.
+ * Modifies: May modify the arrays of files (but if modified, it must be a
+ * permutation so the caller can use that array to close everything.)
+ * Requires: The number of sources is at least one, and each of the input files
+ * must have at least one row in it.
* Arguments:
- * to_q boolean indicating that output is queue (true) or a file (false)
+ * to_q boolean indicating that output is queue (true) or a file
+ * (false)
* dest_data where to write the sorted data
* q where to write the sorted data
* n_sources how many source files.
@@ -1747,9 +1756,10 @@ int toku_merge_some_files_using_dbufio (const bool to_q, FIDX dest_data, QUEUE q
{
int result = 0;
- FILE *dest_stream = to_q ? NULL : toku_bl_fidx2file(bl, dest_data);
+ TOKU_FILE *dest_stream = to_q ? nullptr : toku_bl_fidx2file(bl, dest_data);
- //printf(" merge_some_files progress=%d fin at %d\n", bl->progress, bl->progress+progress_allocation);
+ // printf(" merge_some_files progress=%d fin at %d\n", bl->progress,
+ // bl->progress+progress_allocation);
DBT keys[n_sources];
DBT vals[n_sources];
uint64_t dataoff[n_sources];
@@ -1943,12 +1953,18 @@ static int merge_some_files (const bool to_q, FIDX dest_data, QUEUE q, int n_sou
int result = 0;
DBUFIO_FILESET bfs = NULL;
int *MALLOC_N(n_sources, fds);
- if (fds==NULL) result=get_error_errno();
- if (result==0) {
- for (int i=0; i<n_sources; i++) {
- int r = fileno(toku_bl_fidx2file(bl, srcs_fidxs[i])); // we rely on the fact that when the files are closed, the fd is also closed.
- if (r==-1) {
- result=get_error_errno();
+ if (fds == NULL)
+ result = get_error_errno();
+ if (result == 0) {
+ for (int i = 0; i < n_sources; i++) {
+ int r = fileno(
+ toku_bl_fidx2file(bl, srcs_fidxs[i])->file); // we rely on the
+ // fact that when
+ // the files are
+ // closed, the fd
+ // is also closed.
+ if (r == -1) {
+ result = get_error_errno();
break;
}
fds[i] = r;
@@ -2178,7 +2194,7 @@ static inline void dbout_init(struct dbout *out, FT ft) {
out->current_off = 0;
out->n_translations = out->n_translations_limit = 0;
out->translation = NULL;
- toku_mutex_init(&out->mutex, NULL);
+ toku_mutex_init(*loader_out_mutex_key, &out->mutex, nullptr);
out->ft = ft;
}
@@ -2418,7 +2434,7 @@ static int toku_loader_write_ft_from_q (FTLOADER bl,
assert_zero(r);
return result;
}
- FILE *pivots_stream = toku_bl_fidx2file(bl, pivots_file);
+ TOKU_FILE *pivots_stream = toku_bl_fidx2file(bl, pivots_file);
TXNID root_xid_that_created = TXNID_NONE;
if (bl->root_xids_that_created)
@@ -2705,21 +2721,35 @@ int toku_loader_write_ft_from_q_in_C (FTLOADER bl,
static void* fractal_thread (void *ftav) {
struct fractal_thread_args *fta = (struct fractal_thread_args *)ftav;
- int r = toku_loader_write_ft_from_q (fta->bl, fta->descriptor, fta->fd, fta->progress_allocation, fta->q, fta->total_disksize_estimate, fta->which_db, fta->target_nodesize, fta->target_basementnodesize, fta->target_compression_method, fta->target_fanout);
+ int r = toku_loader_write_ft_from_q(fta->bl,
+ fta->descriptor,
+ fta->fd,
+ fta->progress_allocation,
+ fta->q,
+ fta->total_disksize_estimate,
+ fta->which_db,
+ fta->target_nodesize,
+ fta->target_basementnodesize,
+ fta->target_compression_method,
+ fta->target_fanout);
fta->errno_result = r;
- return NULL;
-}
-
-static int loader_do_i (FTLOADER bl,
- int which_db,
- DB *dest_db,
- ft_compare_func compare,
- const DESCRIPTOR descriptor,
- const char *new_fname,
- int progress_allocation // how much progress do I need to add into bl->progress by the end..
- )
+ toku_instr_delete_current_thread();
+ return toku_pthread_done(nullptr);
+}
+
+static int loader_do_i(FTLOADER bl,
+ int which_db,
+ DB *dest_db,
+ ft_compare_func compare,
+ const DESCRIPTOR descriptor,
+ const char *new_fname,
+ int progress_allocation // how much progress do I need
+ // to add into bl->progress by
+ // the end..
+ )
/* Effect: Handle the file creating for one particular DB in the bulk loader. */
-/* Requires: The data is fully extracted, so we can do merges out of files and write the ft file. */
+/* Requires: The data is fully extracted, so we can do merges out of files and
+ write the ft file. */
{
//printf("doing i use %d progress=%d fin at %d\n", progress_allocation, bl->progress, bl->progress+progress_allocation);
struct merge_fileset *fs = &(bl->fs[which_db]);
@@ -2730,10 +2760,14 @@ static int loader_do_i (FTLOADER bl,
if (r) goto error;
{
- mode_t mode = S_IRUSR+S_IWUSR + S_IRGRP+S_IWGRP;
- int fd = toku_os_open(new_fname, O_RDWR| O_CREAT | O_BINARY, mode); // #2621
+ mode_t mode = S_IRUSR + S_IWUSR + S_IRGRP + S_IWGRP;
+ int fd = toku_os_open(new_fname,
+ O_RDWR | O_CREAT | O_BINARY,
+ mode,
+ *tokudb_file_load_key); // #2621
if (fd < 0) {
- r = get_error_errno(); goto error;
+ r = get_error_errno();
+ goto error;
}
uint32_t target_nodesize, target_basementnodesize, target_fanout;
@@ -2753,24 +2787,27 @@ static int loader_do_i (FTLOADER bl,
progress_allocation -= allocation_for_merge;
// This structure must stay live until the join below.
- struct fractal_thread_args fta = {
- bl,
- descriptor,
- fd,
- progress_allocation,
- bl->fractal_queues[which_db],
- bl->extracted_datasizes[which_db],
- 0,
- which_db,
- target_nodesize,
- target_basementnodesize,
- target_compression_method,
- target_fanout
- };
-
- r = toku_pthread_create(bl->fractal_threads+which_db, NULL, fractal_thread, (void*)&fta);
+ struct fractal_thread_args fta = {bl,
+ descriptor,
+ fd,
+ progress_allocation,
+ bl->fractal_queues[which_db],
+ bl->extracted_datasizes[which_db],
+ 0,
+ which_db,
+ target_nodesize,
+ target_basementnodesize,
+ target_compression_method,
+ target_fanout};
+
+ r = toku_pthread_create(*fractal_thread_key,
+ bl->fractal_threads + which_db,
+ nullptr,
+ fractal_thread,
+ static_cast<void *>(&fta));
if (r) {
- int r2 __attribute__((__unused__)) = toku_queue_destroy(bl->fractal_queues[which_db]);
+ int r2 __attribute__((__unused__)) =
+ toku_queue_destroy(bl->fractal_queues[which_db]);
// ignore r2, since we already have an error
bl->fractal_queues[which_db] = nullptr;
goto error;
@@ -3107,7 +3144,7 @@ static int read_some_pivots (FIDX pivots_file, int n_to_read, FTLOADER bl,
for (int i = 0; i < n_to_read; i++)
pivots[i] = zero_dbt;
- FILE *pivots_stream = toku_bl_fidx2file(bl, pivots_file);
+ TOKU_FILE *pivots_stream = toku_bl_fidx2file(bl, pivots_file);
int result = 0;
for (int i = 0; i < n_to_read; i++) {
@@ -3159,8 +3196,9 @@ static int setup_nonleaf_block (int n_children,
}
if (result == 0) {
- FILE *next_pivots_stream = toku_bl_fidx2file(bl, next_pivots_file);
- int r = bl_write_dbt(&pivots[n_children-1], next_pivots_stream, NULL, nullptr, bl);
+ TOKU_FILE *next_pivots_stream = toku_bl_fidx2file(bl, next_pivots_file);
+ int r = bl_write_dbt(
+ &pivots[n_children - 1], next_pivots_stream, NULL, nullptr, bl);
if (r)
result = r;
}
@@ -3275,8 +3313,11 @@ static int write_nonleaves (FTLOADER bl, FIDX pivots_fidx, struct dbout *out, st
// 2) We put the 15 pivots and 16 blocks into an non-leaf node.
// 3) We put the 16th pivot into the next pivots file.
{
- int r = fseek(toku_bl_fidx2file(bl, pivots_fidx), 0, SEEK_SET);
- if (r!=0) { return get_error_errno(); }
+ int r =
+ fseek(toku_bl_fidx2file(bl, pivots_fidx)->file, 0, SEEK_SET);
+ if (r != 0) {
+ return get_error_errno();
+ }
}
FIDX next_pivots_file;
@@ -3296,7 +3337,7 @@ static int write_nonleaves (FTLOADER bl, FIDX pivots_fidx, struct dbout *out, st
while (sts->n_subtrees - n_subtrees_used >= n_per_block*2) {
// grab the first N_PER_BLOCK and build a node.
DBT *pivots;
- int64_t blocknum_of_new_node;
+ int64_t blocknum_of_new_node = 0;
struct subtree_info *subtree_info;
int r = setup_nonleaf_block (n_per_block,
sts, pivots_fidx, n_subtrees_used,
diff --git a/storage/tokudb/PerconaFT/ft/loader/loader.h b/storage/tokudb/PerconaFT/ft/loader/loader.h
index 9c1bdab1ee2..cea2e8dfda2 100644
--- a/storage/tokudb/PerconaFT/ft/loader/loader.h
+++ b/storage/tokudb/PerconaFT/ft/loader/loader.h
@@ -38,6 +38,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#pragma once
+#include "toku_portability.h"
#include "ft/txn/txn.h"
#include "ft/cachetable/cachetable.h"
#include "ft/comparator.h"
@@ -77,8 +78,6 @@ int toku_ft_loader_abort(FTLOADER bl,
bool is_error);
// For test purposes only
-void toku_ft_loader_set_size_factor (uint32_t factor);
-
-void ft_loader_set_os_fwrite (size_t (*fwrite_fun)(const void*,size_t,size_t,FILE*));
+void toku_ft_loader_set_size_factor(uint32_t factor);
size_t ft_loader_leafentry_size(size_t key_size, size_t val_size, TXNID xid);
diff --git a/storage/tokudb/PerconaFT/ft/logger/log-internal.h b/storage/tokudb/PerconaFT/ft/logger/log-internal.h
index bee74fac346..be19e1342cd 100644
--- a/storage/tokudb/PerconaFT/ft/logger/log-internal.h
+++ b/storage/tokudb/PerconaFT/ft/logger/log-internal.h
@@ -70,11 +70,11 @@ struct mylock {
};
static inline void ml_init(struct mylock *l) {
- toku_mutex_init(&l->lock, 0);
-}
-static inline void ml_lock(struct mylock *l) {
- toku_mutex_lock(&l->lock);
+ toku_mutex_init(*log_internal_lock_mutex_key, &l->lock, nullptr);
}
+// TODO: source location info might have be to be pulled up one caller
+// to be useful
+static inline void ml_lock(struct mylock *l) { toku_mutex_lock(&l->lock); }
static inline void ml_unlock(struct mylock *l) {
toku_mutex_unlock(&l->lock);
}
diff --git a/storage/tokudb/PerconaFT/ft/logger/logcursor.cc b/storage/tokudb/PerconaFT/ft/logger/logcursor.cc
index 910a608cef9..07f57220bf0 100644
--- a/storage/tokudb/PerconaFT/ft/logger/logcursor.cc
+++ b/storage/tokudb/PerconaFT/ft/logger/logcursor.cc
@@ -86,10 +86,10 @@ static int lc_close_cur_logfile(TOKULOGCURSOR lc) {
}
static toku_off_t lc_file_len(const char *name) {
- toku_struct_stat buf;
- int r = toku_stat(name, &buf);
- assert(r == 0);
- return buf.st_size;
+ toku_struct_stat buf;
+ int r = toku_stat(name, &buf, *tokudb_file_data_key);
+ assert(r == 0);
+ return buf.st_size;
}
// Cat the file and throw away the contents. This brings the file into the file system cache
diff --git a/storage/tokudb/PerconaFT/ft/logger/logger.cc b/storage/tokudb/PerconaFT/ft/logger/logger.cc
index d6d1673b5e3..0e1e5a276b7 100644
--- a/storage/tokudb/PerconaFT/ft/logger/logger.cc
+++ b/storage/tokudb/PerconaFT/ft/logger/logger.cc
@@ -50,11 +50,17 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "util/status.h"
-static const int log_format_version=TOKU_LOG_VERSION;
+static const int log_format_version = TOKU_LOG_VERSION;
-static int open_logfile (TOKULOGGER logger);
-static void logger_write_buffer (TOKULOGGER logger, LSN *fsynced_lsn);
-static void delete_logfile(TOKULOGGER logger, long long index, uint32_t version);
+toku_instr_key *result_output_condition_lock_mutex_key;
+toku_instr_key *result_output_condition_key;
+toku_instr_key *tokudb_file_log_key;
+
+static int open_logfile(TOKULOGGER logger);
+static void logger_write_buffer(TOKULOGGER logger, LSN *fsynced_lsn);
+static void delete_logfile(TOKULOGGER logger,
+ long long index,
+ uint32_t version);
static void grab_output(TOKULOGGER logger, LSN *fsynced_lsn);
static void release_output(TOKULOGGER logger, LSN fsynced_lsn);
@@ -132,10 +138,13 @@ int toku_logger_create (TOKULOGGER *resultp) {
// n_in_file is uninitialized
result->write_block_size = FT_DEFAULT_NODE_SIZE; // default logging size is the same as the default ft block size
toku_logfilemgr_create(&result->logfilemgr);
- *resultp=result;
+ *resultp = result;
ml_init(&result->input_lock);
- toku_mutex_init(&result->output_condition_lock, NULL);
- toku_cond_init(&result->output_condition, NULL);
+ toku_mutex_init(*result_output_condition_lock_mutex_key,
+ &result->output_condition_lock,
+ nullptr);
+ toku_cond_init(
+ *result_output_condition_key, &result->output_condition, nullptr);
result->rollback_cachefile = NULL;
result->output_is_available = true;
toku_txn_manager_init(&result->txn_manager);
@@ -301,10 +310,10 @@ int toku_logger_close(TOKULOGGER *loggerp) {
grab_output(logger, &fsynced_lsn);
logger_write_buffer(logger, &fsynced_lsn);
if (logger->fd!=-1) {
- if ( logger->write_log_files ) {
+ if (logger->write_log_files) {
toku_file_fsync_without_accounting(logger->fd);
}
- r = close(logger->fd);
+ r = toku_os_close(logger->fd);
assert(r == 0);
}
r = close_logdir(logger);
@@ -346,9 +355,13 @@ static int close_and_open_logfile (TOKULOGGER logger, LSN *fsynced_lsn)
if (logger->write_log_files) {
toku_file_fsync_without_accounting(logger->fd);
*fsynced_lsn = logger->written_lsn;
- toku_logfilemgr_update_last_lsn(logger->logfilemgr, logger->written_lsn); // fixes t:2294
+ toku_logfilemgr_update_last_lsn(logger->logfilemgr,
+ logger->written_lsn); // fixes t:2294
}
- r = close(logger->fd); if (r!=0) return get_error_errno();
+ r = toku_os_close(logger->fd);
+
+ if (r != 0)
+ return get_error_errno();
return open_logfile(logger);
}
@@ -678,18 +691,28 @@ static int open_logfile (TOKULOGGER logger)
{
int fnamelen = strlen(logger->directory)+50;
char fname[fnamelen];
- snprintf(fname, fnamelen, "%s/log%012lld.tokulog%d", logger->directory, logger->next_log_file_number, TOKU_LOG_VERSION);
+ snprintf(fname,
+ fnamelen,
+ "%s/log%012lld.tokulog%d",
+ logger->directory,
+ logger->next_log_file_number,
+ TOKU_LOG_VERSION);
long long index = logger->next_log_file_number;
if (logger->write_log_files) {
- logger->fd = open(fname, O_CREAT+O_WRONLY+O_TRUNC+O_EXCL+O_BINARY, S_IRUSR+S_IWUSR);
- if (logger->fd==-1) {
+ logger->fd =
+ toku_os_open(fname,
+ O_CREAT + O_WRONLY + O_TRUNC + O_EXCL + O_BINARY,
+ S_IRUSR + S_IWUSR,
+ *tokudb_file_log_key);
+ if (logger->fd == -1) {
return get_error_errno();
}
fsync_logdir(logger);
logger->next_log_file_number++;
} else {
- logger->fd = open(DEV_NULL_FILE, O_WRONLY+O_BINARY);
- if (logger->fd==-1) {
+ logger->fd = toku_os_open(
+ DEV_NULL_FILE, O_WRONLY + O_BINARY, S_IWUSR, *tokudb_file_log_key);
+ if (logger->fd == -1) {
return get_error_errno();
}
}
@@ -835,10 +858,11 @@ int toku_logger_restart(TOKULOGGER logger, LSN lastlsn)
logger_write_buffer(logger, &fsynced_lsn);
// close the log file
- if ( logger->write_log_files) { // fsyncs don't work to /dev/null
+ if (logger->write_log_files) { // fsyncs don't work to /dev/null
toku_file_fsync_without_accounting(logger->fd);
}
- r = close(logger->fd); assert(r == 0);
+ r = toku_os_close(logger->fd);
+ assert(r == 0);
logger->fd = -1;
// reset the LSN's to the lastlsn when the logger was opened
@@ -1238,11 +1262,13 @@ void toku_txnid2txn(TOKULOGGER logger, TXNID_PAIR txnid, TOKUTXN *result) {
}
// Find the earliest LSN in a log. No locks are needed.
-static int peek_at_log (TOKULOGGER logger, char* filename, LSN *first_lsn) {
- int fd = open(filename, O_RDONLY+O_BINARY);
- if (fd<0) {
+static int peek_at_log(TOKULOGGER logger, char *filename, LSN *first_lsn) {
+ int fd = toku_os_open(
+ filename, O_RDONLY + O_BINARY, S_IRUSR, *tokudb_file_log_key);
+ if (fd < 0) {
int er = get_error_errno();
- if (logger->write_log_files) printf("couldn't open: %s\n", strerror(er));
+ if (logger->write_log_files)
+ printf("couldn't open: %s\n", strerror(er));
return er;
}
enum { SKIP = 12+1+4 }; // read the 12 byte header, the first message, and the first len
@@ -1259,10 +1285,13 @@ static int peek_at_log (TOKULOGGER logger, char* filename, LSN *first_lsn) {
lsn = rbuf_ulonglong(&rb);
}
- r=close(fd);
- if (r!=0) { return 0; }
+ r = toku_os_close(fd);
+
+ if (r != 0) {
+ return 0;
+ }
- first_lsn->lsn=lsn;
+ first_lsn->lsn = lsn;
return 0;
}
diff --git a/storage/tokudb/PerconaFT/ft/logger/recover.cc b/storage/tokudb/PerconaFT/ft/logger/recover.cc
index 9eaa56bdc53..9a9a1214ecb 100644
--- a/storage/tokudb/PerconaFT/ft/logger/recover.cc
+++ b/storage/tokudb/PerconaFT/ft/logger/recover.cc
@@ -954,14 +954,14 @@ static int toku_recover_frename(struct logtype_frename *l, RECOVER_ENV renv) {
std::unique_ptr<char[], decltype(&toku_free)> new_iname_full(
toku_construct_full_name(2, data_dir, l->new_iname.data), &toku_free);
- if (toku_stat(old_iname_full.get(), &stat) == -1) {
+ if (toku_stat(old_iname_full.get(), &stat, toku_uninstrumented) == -1) {
if (ENOENT == errno)
old_exist = false;
else
return 1;
}
- if (toku_stat(new_iname_full.get(), &stat) == -1) {
+ if (toku_stat(new_iname_full.get(), &stat, toku_uninstrumented) == -1) {
if (ENOENT == errno)
new_exist = false;
else
@@ -980,7 +980,7 @@ static int toku_recover_frename(struct logtype_frename *l, RECOVER_ENV renv) {
// 'stalled cachefiles' container the new file is removed
// and the old file is renamed.
if (old_exist && new_exist &&
- (toku_os_unlink(new_iname_full.get()) == -1 ||
+ (toku_os_delete(new_iname_full.get()) == -1 ||
toku_os_rename(old_iname_full.get(), new_iname_full.get()) == -1 ||
toku_fsync_directory(old_iname_full.get()) == -1 ||
toku_fsync_directory(new_iname_full.get()) == -1))
@@ -1473,9 +1473,13 @@ static int do_recovery(RECOVER_ENV renv, const char *env_dir, const char *log_di
{
toku_struct_stat buf;
- if (toku_stat(env_dir, &buf)!=0) {
+ if (toku_stat(env_dir, &buf, toku_uninstrumented)) {
rr = get_error_errno();
- fprintf(stderr, "%.24s PerconaFT recovery error: directory does not exist: %s\n", ctime(&tnow), env_dir);
+ fprintf(stderr,
+ "%.24s PerconaFT recovery error: directory does not exist: "
+ "%s\n",
+ ctime(&tnow),
+ env_dir);
goto errorexit;
} else if (!S_ISDIR(buf.st_mode)) {
fprintf(stderr, "%.24s PerconaFT recovery error: this file is supposed to be a directory, but is not: %s\n", ctime(&tnow), env_dir);
diff --git a/storage/tokudb/PerconaFT/ft/serialize/block_allocator.cc b/storage/tokudb/PerconaFT/ft/serialize/block_allocator.cc
index 19811373d16..29f6daa293a 100644
--- a/storage/tokudb/PerconaFT/ft/serialize/block_allocator.cc
+++ b/storage/tokudb/PerconaFT/ft/serialize/block_allocator.cc
@@ -40,6 +40,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include <string.h>
+#include "toku_portability.h"
#include "portability/memory.h"
#include "portability/toku_assert.h"
#include "portability/toku_stdint.h"
diff --git a/storage/tokudb/PerconaFT/ft/serialize/block_table.cc b/storage/tokudb/PerconaFT/ft/serialize/block_table.cc
index 12700d9d83e..811f86c30a7 100644
--- a/storage/tokudb/PerconaFT/ft/serialize/block_table.cc
+++ b/storage/tokudb/PerconaFT/ft/serialize/block_table.cc
@@ -55,6 +55,11 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "util/nb_mutex.h"
#include "util/scoped_malloc.h"
+
+toku_instr_key *block_table_mutex_key;
+toku_instr_key *safe_file_size_lock_mutex_key;
+toku_instr_key *safe_file_size_lock_rwlock_key;
+
// indicates the end of a freelist
static const BLOCKNUM freelist_null = {-1};
@@ -100,8 +105,10 @@ void block_table::_create_internal() {
memset(&_checkpointed, 0, sizeof(struct translation));
memset(&_mutex, 0, sizeof(_mutex));
_bt_block_allocator = new BlockAllocator();
- toku_mutex_init(&_mutex, nullptr);
- nb_mutex_init(&_safe_file_size_lock);
+ toku_mutex_init(*block_table_mutex_key, &_mutex, nullptr);
+ nb_mutex_init(*safe_file_size_lock_mutex_key,
+ *safe_file_size_lock_rwlock_key,
+ &_safe_file_size_lock);
}
// Fill in the checkpointed translation from buffer, and copy checkpointed to
@@ -129,7 +136,7 @@ int block_table::create_from_buffer(
_copy_translation(&_current, &_checkpointed, TRANSLATION_CURRENT);
// Determine the file size
- int64_t file_size;
+ int64_t file_size = 0;
r = toku_os_get_file_size(fd, &file_size);
lazy_assert_zero(r);
invariant(file_size >= 0);
diff --git a/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc b/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc
index fcab9fc675e..b24d72a5dff 100644
--- a/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc
+++ b/storage/tokudb/PerconaFT/ft/serialize/ft-serialize.cc
@@ -417,8 +417,10 @@ static size_t serialize_ft_min_size(uint32_t version) {
switch (version) {
case FT_LAYOUT_VERSION_29:
size += sizeof(uint64_t); // logrows in ft
+ // fallthrough
case FT_LAYOUT_VERSION_28:
size += sizeof(uint32_t); // fanout in ft
+ // fallthrough
case FT_LAYOUT_VERSION_27:
case FT_LAYOUT_VERSION_26:
case FT_LAYOUT_VERSION_25:
@@ -427,10 +429,12 @@ static size_t serialize_ft_min_size(uint32_t version) {
case FT_LAYOUT_VERSION_22:
case FT_LAYOUT_VERSION_21:
size += sizeof(MSN); // max_msn_in_ft
+ // fallthrough
case FT_LAYOUT_VERSION_20:
case FT_LAYOUT_VERSION_19:
size += 1; // compression method
size += sizeof(MSN); // highest_unused_msn_for_upgrade
+ // fallthrough
case FT_LAYOUT_VERSION_18:
size += sizeof(uint64_t); // time_of_last_optimize_begin
size += sizeof(uint64_t); // time_of_last_optimize_end
@@ -438,9 +442,11 @@ static size_t serialize_ft_min_size(uint32_t version) {
size += sizeof(MSN); // msn_at_start_of_last_completed_optimize
size -= 8; // removed num_blocks_to_upgrade_14
size -= 8; // removed num_blocks_to_upgrade_13
+ // fallthrough
case FT_LAYOUT_VERSION_17:
size += 16;
invariant(sizeof(STAT64INFO_S) == 16);
+ // fallthrough
case FT_LAYOUT_VERSION_16:
case FT_LAYOUT_VERSION_15:
size += 4; // basement node size
@@ -448,8 +454,10 @@ static size_t serialize_ft_min_size(uint32_t version) {
// num_blocks_to_upgrade, now one int each for upgrade
// from 13, 14
size += 8; // time of last verification
+ // fallthrough
case FT_LAYOUT_VERSION_14:
size += 8; // TXNID that created
+ // fallthrough
case FT_LAYOUT_VERSION_13:
size += (4 // build_id
+
@@ -459,7 +467,7 @@ static size_t serialize_ft_min_size(uint32_t version) {
+
8 // time_of_last_modification
);
- // fall through
+ // fallthrough
case FT_LAYOUT_VERSION_12:
size += (+8 // "tokudata"
+
diff --git a/storage/tokudb/PerconaFT/ft/serialize/sub_block.cc b/storage/tokudb/PerconaFT/ft/serialize/sub_block.cc
index c967d4b4c1c..6dc1f82844a 100644
--- a/storage/tokudb/PerconaFT/ft/serialize/sub_block.cc
+++ b/storage/tokudb/PerconaFT/ft/serialize/sub_block.cc
@@ -51,6 +51,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "util/threadpool.h"
#include "util/x1764.h"
+toku_instr_key *workset_lock_mutex_key;
+toku_instr_key *ws_worker_wait_key;
+
SUB_BLOCK sub_block_creat(void) {
SUB_BLOCK XMALLOC(sb);
sub_block_init(sb);
diff --git a/storage/tokudb/PerconaFT/ft/serialize/workset.h b/storage/tokudb/PerconaFT/ft/serialize/workset.h
index 073741fccb1..295eb73cec9 100644
--- a/storage/tokudb/PerconaFT/ft/serialize/workset.h
+++ b/storage/tokudb/PerconaFT/ft/serialize/workset.h
@@ -41,6 +41,8 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include <toku_list.h>
#include <toku_pthread.h>
+extern toku_instr_key *ws_worker_wait_key;
+
// The work struct is the base class for work to be done by some threads
struct work {
struct toku_list next;
@@ -54,16 +56,14 @@ struct workset {
toku_cond_t worker_wait; // a condition variable used to wait for all of the worker to release their reference on the workset
};
-static inline void
-workset_init(struct workset *ws) {
- toku_mutex_init(&ws->lock, NULL);
+static inline void workset_init(struct workset *ws) {
+ toku_mutex_init(*workset_lock_mutex_key, &ws->lock, nullptr);
toku_list_init(&ws->worklist);
- ws->refs = 1; // the calling thread gets a reference
- toku_cond_init(&ws->worker_wait, NULL);
+ ws->refs = 1; // the calling thread gets a reference
+ toku_cond_init(*ws_worker_wait_key, &ws->worker_wait, nullptr);
}
-static inline void
-workset_destroy(struct workset *ws) {
+static inline void workset_destroy(struct workset *ws) {
invariant(toku_list_empty(&ws->worklist));
toku_cond_destroy(&ws->worker_wait);
toku_mutex_destroy(&ws->lock);
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-4357.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-4357.cc
index 8bbda295462..0af5c8185a9 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-4357.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-4357.cc
@@ -71,21 +71,26 @@ cachetable_test (void) {
void* v1;
long s1;
- r = toku_cachetable_get_and_pin(
- f1,
- make_blocknum(1),
- toku_cachetable_hash(f1, make_blocknum(1)),
- &v1,
- &s1,
- def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback,
- true,
- NULL
- );
+ r = toku_cachetable_get_and_pin(f1,
+ make_blocknum(1),
+ toku_cachetable_hash(f1, make_blocknum(1)),
+ &v1,
+ &s1,
+ def_write_callback(NULL),
+ def_fetch,
+ def_pf_req_callback,
+ def_pf_callback,
+ true,
+ NULL);
toku_pthread_t pin_nonblocking_tid;
- r = toku_pthread_create(&pin_nonblocking_tid, NULL, pin_nonblocking, NULL);
- assert_zero(r);
+ r = toku_pthread_create(toku_uninstrumented,
+ &pin_nonblocking_tid,
+ nullptr,
+ pin_nonblocking,
+ nullptr);
+ assert_zero(r);
// sleep 3 seconds
- usleep(3*1024*1024);
+ usleep(3 * 1024 * 1024);
r = toku_test_cachetable_unpin_and_remove(f1, make_blocknum(1), NULL, NULL);
assert_zero(r);
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-4365.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-4365.cc
index 9c54c086f5b..7bee0b80770 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-4365.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-4365.cc
@@ -71,15 +71,16 @@ static void *put_same_key(void *arg) {
return arg;
}
-
toku_pthread_t put_tid;
-static void test_remove_key(CACHEKEY* UU(cachekey), bool UU(for_checkpoint), void* UU(extra)) {
- int r = toku_pthread_create(&put_tid, NULL, put_same_key, NULL);
- assert_zero(r);
+static void test_remove_key(CACHEKEY *UU(cachekey),
+ bool UU(for_checkpoint),
+ void *UU(extra)) {
+ int r = toku_pthread_create(
+ toku_uninstrumented, &put_tid, nullptr, put_same_key, nullptr);
+ assert_zero(r);
}
-
static void
cachetable_test (void) {
const int test_limit = 12;
@@ -92,21 +93,26 @@ cachetable_test (void) {
void* v1;
long s1;
- r = toku_cachetable_get_and_pin(
- f1,
- make_blocknum(1),
- toku_cachetable_hash(f1, make_blocknum(1)),
- &v1,
- &s1,
- def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback,
- true,
- NULL
- );
+ r = toku_cachetable_get_and_pin(f1,
+ make_blocknum(1),
+ toku_cachetable_hash(f1, make_blocknum(1)),
+ &v1,
+ &s1,
+ def_write_callback(nullptr),
+ def_fetch,
+ def_pf_req_callback,
+ def_pf_callback,
+ true,
+ nullptr);
toku_pthread_t pin_nonblocking_tid;
- r = toku_pthread_create(&pin_nonblocking_tid, NULL, pin_nonblocking, NULL);
- assert_zero(r);
+ r = toku_pthread_create(toku_uninstrumented,
+ &pin_nonblocking_tid,
+ nullptr,
+ pin_nonblocking,
+ nullptr);
+ assert_zero(r);
// sleep 3 seconds
- usleep(3*1024*1024);
+ usleep(3 * 1024 * 1024);
r = toku_test_cachetable_unpin_and_remove(f1, make_blocknum(1), test_remove_key, NULL);
assert_zero(r);
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-5097.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-5097.cc
index c1b6e0a94f2..5ab0df88e08 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-5097.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-5097.cc
@@ -153,13 +153,16 @@ cachetable_test (void) {
assert(r == 0);
}
- // at this point, we have a dirty PAIR in the cachetable associated with cachefile f1
- // launch a thread that will put another PAIR in the cachetable, and get partial eviction started
+ // at this point, we have a dirty PAIR in the cachetable associated with
+ // cachefile f1
+ // launch a thread that will put another PAIR in the cachetable, and get
+ // partial eviction started
toku_pthread_t tid;
- r = toku_pthread_create(&tid, NULL, f2_pin, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &tid, nullptr, f2_pin, nullptr);
assert_zero(r);
- usleep(2*1024*1024);
+ usleep(2 * 1024 * 1024);
check_flush = true;
toku_cachefile_close(&f1, false, ZERO_LSN);
if (enable_partial_eviction)
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-5978-2.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-5978-2.cc
index b462d76eeee..0b5110ddd99 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-5978-2.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-5978-2.cc
@@ -114,14 +114,14 @@ unpin_two (void* UU(v)) {
);
assert_zero(r);
- // at this point, we have p1 pinned, want to start a thread to do an unpin_and_remove
- // on p1
- r = toku_pthread_create(
- &unpin_and_remove_tid,
- NULL,
- unpin_and_remove_one,
- NULL
- );
+ // at this point, we have p1 pinned, want to start a thread to do an
+ // unpin_and_remove
+ // on p1
+ r = toku_pthread_create(toku_uninstrumented,
+ &unpin_and_remove_tid,
+ nullptr,
+ unpin_and_remove_one,
+ nullptr);
assert_zero(r);
// sleep to give a chance for the unpin_and_remove to get going
usleep(512*1024);
@@ -173,9 +173,9 @@ cachetable_test (void) {
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v1, &s1, wc, fetch_two, def_pf_req_callback, def_pf_callback, true, NULL);
assert_zero(r);
-
toku_pthread_t tid1;
- r = toku_pthread_create(&tid1, NULL, repin_one, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &tid1, nullptr, repin_one, nullptr);
assert_zero(r);
void *ret;
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-5978.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-5978.cc
index ee68ab3ef0b..a4ff6c33e6a 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-5978.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-5978.cc
@@ -199,9 +199,11 @@ cachetable_test (void) {
toku_pthread_t tid1;
toku_pthread_t tid2;
- r = toku_pthread_create(&tid1, NULL, repin_one, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &tid1, nullptr, repin_one, nullptr);
assert_zero(r);
- r = toku_pthread_create(&tid2, NULL, repin_two, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &tid2, nullptr, repin_two, nullptr);
assert_zero(r);
// unpin 1 and 2 so tid1 and tid2 can make progress
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-checkpoint-pending.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-checkpoint-pending.cc
index 3dd3a15e2de..5e87fed740d 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-checkpoint-pending.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-checkpoint-pending.cc
@@ -158,14 +158,24 @@ static void checkpoint_pending(void) {
// the checkpoint should cause n writes, but since n <= the cachetable size,
// all items should be kept in the cachetable
- n_flush = n_write_me = n_keep_me = n_fetch = 0; expect_value = 42;
- //printf("E42\n");
+ n_flush = n_write_me = n_keep_me = n_fetch = 0;
+ expect_value = 42;
+ // printf("E42\n");
toku_pthread_t checkpoint_thread, update_thread;
- r = toku_pthread_create(&checkpoint_thread, NULL, do_checkpoint, NULL); assert(r==0);
- r = toku_pthread_create(&update_thread, NULL, do_update, NULL); assert(r==0);
- r = toku_pthread_join(checkpoint_thread, 0); assert(r==0);
- r = toku_pthread_join(update_thread, 0); assert(r==0);
-
+ r = toku_pthread_create(toku_uninstrumented,
+ &checkpoint_thread,
+ nullptr,
+ do_checkpoint,
+ nullptr);
+ assert(r == 0);
+ r = toku_pthread_create(
+ toku_uninstrumented, &update_thread, nullptr, do_update, nullptr);
+ assert(r == 0);
+ r = toku_pthread_join(checkpoint_thread, 0);
+ assert(r == 0);
+ r = toku_pthread_join(update_thread, 0);
+ assert(r == 0);
+
assert(n_flush == N && n_write_me == N && n_keep_me == N);
// after the checkpoint, all of the items should be 43
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-cleaner-thread-attrs-accumulate.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-cleaner-thread-attrs-accumulate.cc
index c1e7b373e83..dd6c674af24 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-cleaner-thread-attrs-accumulate.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-cleaner-thread-attrs-accumulate.cc
@@ -91,7 +91,7 @@ run_test (void) {
const int test_limit = 1000;
int r;
CACHETABLE ct;
- toku_mutex_init(&attr_mutex, NULL);
+ toku_mutex_init(toku_uninstrumented, &attr_mutex, nullptr);
toku_cachetable_create(&ct, test_limit, ZERO_LSN, nullptr);
const char *fname1 = TOKU_TEST_FILENAME;
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-clone-checkpoint.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-clone-checkpoint.cc
index 50bd20f492e..99d595b1ff1 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-clone-checkpoint.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-clone-checkpoint.cc
@@ -112,14 +112,17 @@ cachetable_test (void) {
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
toku_cachetable_begin_checkpoint(cp, NULL);
-
clone_flush_started = false;
clone_flush_completed = false;
toku_pthread_t checkpoint_tid;
- r = toku_pthread_create(&checkpoint_tid, NULL, run_end_checkpoint, NULL);
- assert_zero(r);
+ r = toku_pthread_create(toku_uninstrumented,
+ &checkpoint_tid,
+ nullptr,
+ run_end_checkpoint,
+ nullptr);
+ assert_zero(r);
- usleep(1*1024*1024);
+ usleep(1 * 1024 * 1024);
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
assert_zero(r);
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-pin-checkpoint.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-pin-checkpoint.cc
index 8a270af0566..65b02aebaec 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-pin-checkpoint.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-pin-checkpoint.cc
@@ -386,19 +386,28 @@ cachetable_test (void) {
run_test = true;
for (int i = 0; i < NUM_MOVER_THREADS; i++) {
- r = toku_pthread_create(&read_random_tid[i], NULL, read_random_numbers, NULL);
+ r = toku_pthread_create(toku_uninstrumented,
+ &read_random_tid[i],
+ nullptr,
+ read_random_numbers,
+ nullptr);
assert_zero(r);
}
for (int i = 0; i < NUM_MOVER_THREADS; i++) {
- r = toku_pthread_create(&move_tid[i], NULL, move_numbers, NULL);
+ r = toku_pthread_create(toku_uninstrumented,
+ &move_tid[i],
+ nullptr,
+ move_numbers,
+ nullptr);
assert_zero(r);
}
- r = toku_pthread_create(&checkpoint_tid, NULL, checkpoints, NULL);
- assert_zero(r);
- r = toku_pthread_create(&time_tid, NULL, test_time, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &checkpoint_tid, nullptr, checkpoints, nullptr);
+ assert_zero(r);
+ r = toku_pthread_create(
+ toku_uninstrumented, &time_tid, nullptr, test_time, nullptr);
assert_zero(r);
-
void *ret;
r = toku_pthread_join(time_tid, &ret);
assert_zero(r);
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-put-checkpoint.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-put-checkpoint.cc
index afc95471116..4cf1678449b 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-put-checkpoint.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-put-checkpoint.cc
@@ -518,19 +518,28 @@ cachetable_test (void) {
run_test = true;
for (int i = 0; i < NUM_MOVER_THREADS; i++) {
- r = toku_pthread_create(&move_tid[i], NULL, move_numbers, NULL);
+ r = toku_pthread_create(toku_uninstrumented,
+ &move_tid[i],
+ nullptr,
+ move_numbers,
+ nullptr);
assert_zero(r);
}
for (int i = 0; i < NUM_MOVER_THREADS; i++) {
- r = toku_pthread_create(&merge_and_split_tid[i], NULL, merge_and_split, NULL);
+ r = toku_pthread_create(toku_uninstrumented,
+ &merge_and_split_tid[i],
+ nullptr,
+ merge_and_split,
+ nullptr);
assert_zero(r);
}
- r = toku_pthread_create(&checkpoint_tid, NULL, checkpoints, NULL);
- assert_zero(r);
- r = toku_pthread_create(&time_tid, NULL, test_time, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &checkpoint_tid, nullptr, checkpoints, nullptr);
+ assert_zero(r);
+ r = toku_pthread_create(
+ toku_uninstrumented, &time_tid, nullptr, test_time, nullptr);
assert_zero(r);
-
void *ret;
r = toku_pthread_join(time_tid, &ret);
assert_zero(r);
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-rwlock-test.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-rwlock-test.cc
index 9a62f99e1fa..6d8bc28026c 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-rwlock-test.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-rwlock-test.cc
@@ -40,24 +40,22 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
// test create and destroy
-static void
-test_create_destroy (void) {
- struct rwlock the_rwlock, *rwlock = &the_rwlock;
+static void test_create_destroy(void) {
+ struct st_rwlock the_rwlock, *rwlock = &the_rwlock;
- rwlock_init(rwlock);
+ rwlock_init(toku_uninstrumented, rwlock);
rwlock_destroy(rwlock);
}
// test read lock and unlock with no writers
-static void
-test_simple_read_lock (int n) {
- struct rwlock the_rwlock, *rwlock = &the_rwlock;
+static void test_simple_read_lock(int n) {
+ struct st_rwlock the_rwlock, *rwlock = &the_rwlock;
- rwlock_init(rwlock);
+ rwlock_init(toku_uninstrumented, rwlock);
assert(rwlock_readers(rwlock) == 0);
int i;
- for (i=1; i<=n; i++) {
+ for (i = 1; i <= n; i++) {
rwlock_read_lock(rwlock, 0);
assert(rwlock_readers(rwlock) == i);
assert(rwlock_users(rwlock) == i);
@@ -72,11 +70,10 @@ test_simple_read_lock (int n) {
// test write lock and unlock with no readers
-static void
-test_simple_write_lock (void) {
- struct rwlock the_rwlock, *rwlock = &the_rwlock;
+static void test_simple_write_lock(void) {
+ struct st_rwlock the_rwlock, *rwlock = &the_rwlock;
- rwlock_init(rwlock);
+ rwlock_init(toku_uninstrumented, rwlock);
assert(rwlock_users(rwlock) == 0);
rwlock_write_lock(rwlock, 0);
assert(rwlock_writers(rwlock) == 1);
@@ -88,19 +85,17 @@ test_simple_write_lock (void) {
struct rw_event {
int e;
- struct rwlock the_rwlock;
+ struct st_rwlock the_rwlock;
toku_mutex_t mutex;
};
-static void
-rw_event_init (struct rw_event *rwe) {
+static void rw_event_init(struct rw_event *rwe) {
rwe->e = 0;
- rwlock_init(&rwe->the_rwlock);
- toku_mutex_init(&rwe->mutex, 0);
+ rwlock_init(toku_uninstrumented, &rwe->the_rwlock);
+ toku_mutex_init(toku_uninstrumented, &rwe->mutex, nullptr);
}
-static void
-rw_event_destroy (struct rw_event *rwe) {
+static void rw_event_destroy(struct rw_event *rwe) {
rwlock_destroy(&rwe->the_rwlock);
toku_mutex_destroy(&rwe->mutex);
}
@@ -138,10 +133,12 @@ test_writer_priority (void) {
toku_mutex_unlock(&rwe->mutex);
toku_pthread_t tid;
- r = toku_pthread_create(&tid, 0, test_writer_priority_thread, rwe);
+ r = toku_pthread_create(
+ toku_uninstrumented, &tid, 0, test_writer_priority_thread, rwe);
sleep(1);
toku_mutex_lock(&rwe->mutex);
- rwe->e++; assert(rwe->e == 2);
+ rwe->e++;
+ assert(rwe->e == 2);
toku_mutex_unlock(&rwe->mutex);
sleep(1);
@@ -196,10 +193,12 @@ test_single_writer (void) {
toku_mutex_unlock(&rwe->mutex);
toku_pthread_t tid;
- r = toku_pthread_create(&tid, 0, test_single_writer_thread, rwe);
+ r = toku_pthread_create(
+ toku_uninstrumented, &tid, 0, test_single_writer_thread, rwe);
sleep(1);
toku_mutex_lock(&rwe->mutex);
- rwe->e++; assert(rwe->e == 2);
+ rwe->e++;
+ assert(rwe->e == 2);
assert(rwlock_writers(&rwe->the_rwlock) == 1);
assert(rwlock_users(&rwe->the_rwlock) == 2);
rwlock_write_unlock(&rwe->the_rwlock);
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin-nonblocking.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin-nonblocking.cc
index 8fd8828737a..ebe05e50883 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin-nonblocking.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin-nonblocking.cc
@@ -111,9 +111,20 @@ run_test (void) {
toku_pthread_t fetch_tid;
fetch_called = false;
- r = toku_pthread_create(&fetch_tid, NULL, run_expensive_fetch, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &fetch_tid, nullptr, run_expensive_fetch, nullptr);
sleep(1);
- r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, sleep_fetch, def_pf_req_callback, def_pf_callback, false, NULL);
+ r = toku_cachetable_get_and_pin(f1,
+ make_blocknum(1),
+ 1,
+ &v1,
+ &s1,
+ wc,
+ sleep_fetch,
+ def_pf_req_callback,
+ def_pf_callback,
+ false,
+ NULL);
assert_zero(r);
assert(fetch_called);
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
@@ -133,9 +144,20 @@ run_test (void) {
toku_pthread_t pf_tid;
pf_called = false;
- r = toku_pthread_create(&pf_tid, NULL, run_expensive_pf, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &pf_tid, nullptr, run_expensive_pf, nullptr);
sleep(1);
- r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, sleep_fetch, def_pf_req_callback, def_pf_callback, false, NULL);
+ r = toku_cachetable_get_and_pin(f1,
+ make_blocknum(1),
+ 1,
+ &v1,
+ &s1,
+ wc,
+ sleep_fetch,
+ def_pf_req_callback,
+ def_pf_callback,
+ false,
+ NULL);
assert_zero(r);
assert(pf_called);
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin.cc
index 63ca871a459..dd5d59df002 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-simple-read-pin.cc
@@ -117,9 +117,20 @@ run_test (void) {
toku_pthread_t fetch_tid;
fetch_called = false;
- r = toku_pthread_create(&fetch_tid, NULL, run_expensive_fetch, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &fetch_tid, nullptr, run_expensive_fetch, nullptr);
sleep(1);
- r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, sleep_fetch, def_pf_req_callback, def_pf_callback, false, NULL);
+ r = toku_cachetable_get_and_pin(f1,
+ make_blocknum(1),
+ 1,
+ &v1,
+ &s1,
+ wc,
+ sleep_fetch,
+ def_pf_req_callback,
+ def_pf_callback,
+ false,
+ NULL);
assert_zero(r);
assert(fetch_called);
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
@@ -141,9 +152,20 @@ run_test (void) {
toku_pthread_t pf_tid;
pf_called = false;
- r = toku_pthread_create(&pf_tid, NULL, run_expensive_pf, NULL);
+ r = toku_pthread_create(
+ toku_uninstrumented, &pf_tid, nullptr, run_expensive_pf, nullptr);
sleep(1);
- r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, sleep_fetch, def_pf_req_callback, def_pf_callback, false, NULL);
+ r = toku_cachetable_get_and_pin(f1,
+ make_blocknum(1),
+ 1,
+ &v1,
+ &s1,
+ wc,
+ sleep_fetch,
+ def_pf_req_callback,
+ def_pf_callback,
+ false,
+ NULL);
assert_zero(r);
assert(pf_called);
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-test.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-test.cc
index e4bb5fb0aea..64f688c470d 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-test.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-test.cc
@@ -42,15 +42,13 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
// global data, especially between the test thread and the cachetable
// writeback threads
-toku_mutex_t test_mutex;
+toku_mutex_t test_mutex;
static inline void test_mutex_init(void) {
- toku_mutex_init(&test_mutex, 0);
+ toku_mutex_init(toku_uninstrumented, &test_mutex, nullptr);
}
-static inline void test_mutex_destroy(void) {
- toku_mutex_destroy(&test_mutex);
-}
+static inline void test_mutex_destroy(void) { toku_mutex_destroy(&test_mutex); }
static inline void test_mutex_lock(void) {
toku_mutex_lock(&test_mutex);
diff --git a/storage/tokudb/PerconaFT/ft/tests/cachetable-unpin-remove-and-checkpoint.cc b/storage/tokudb/PerconaFT/ft/tests/cachetable-unpin-remove-and-checkpoint.cc
index 11baa36e51b..0e44bf10349 100644
--- a/storage/tokudb/PerconaFT/ft/tests/cachetable-unpin-remove-and-checkpoint.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/cachetable-unpin-remove-and-checkpoint.cc
@@ -86,11 +86,22 @@ run_test (void) {
// now this should mark the pair for checkpoint
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
toku_cachetable_begin_checkpoint(cp, NULL);
- r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
+ r = toku_cachetable_get_and_pin(f1,
+ make_blocknum(1),
+ toku_cachetable_hash(f1, make_blocknum(1)),
+ &v1,
+ &s1,
+ wc,
+ def_fetch,
+ def_pf_req_callback,
+ def_pf_callback,
+ true,
+ NULL);
toku_pthread_t mytid;
- r = toku_pthread_create(&mytid, NULL, run_end_chkpt, NULL);
- assert(r==0);
+ r = toku_pthread_create(
+ toku_uninstrumented, &mytid, nullptr, run_end_chkpt, nullptr);
+ assert(r == 0);
// give checkpoint thread a chance to start waiting on lock
sleep(1);
diff --git a/storage/tokudb/PerconaFT/ft/tests/ftloader-test-extractor-errors.cc b/storage/tokudb/PerconaFT/ft/tests/ftloader-test-extractor-errors.cc
index 872b674c784..4bff52ceb1b 100644
--- a/storage/tokudb/PerconaFT/ft/tests/ftloader-test-extractor-errors.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/ftloader-test-extractor-errors.cc
@@ -141,7 +141,7 @@ static void test_extractor(int nrows, int nrowsets, bool expect_fail, const char
// setup error injection
toku_set_func_malloc(my_malloc);
toku_set_func_realloc(my_realloc);
- ft_loader_set_os_fwrite(bad_fwrite);
+ toku_set_func_fwrite(bad_fwrite);
toku_set_func_write(bad_write);
toku_set_func_pwrite(bad_pwrite);
ft_loader_set_poll_function(&loader->poll_callback, loader_poll_callback, NULL);
@@ -157,7 +157,7 @@ static void test_extractor(int nrows, int nrowsets, bool expect_fail, const char
toku_set_func_malloc(NULL);
toku_set_func_realloc(NULL);
- ft_loader_set_os_fwrite(NULL);
+ toku_set_func_fwrite(nullptr);
toku_set_func_write(NULL);
toku_set_func_pwrite(NULL);
diff --git a/storage/tokudb/PerconaFT/ft/tests/ftloader-test-merge-files-dbufio.cc b/storage/tokudb/PerconaFT/ft/tests/ftloader-test-merge-files-dbufio.cc
index d1aeff198ff..0b121316738 100644
--- a/storage/tokudb/PerconaFT/ft/tests/ftloader-test-merge-files-dbufio.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/ftloader-test-merge-files-dbufio.cc
@@ -393,13 +393,17 @@ static void test (const char *directory, bool is_error) {
toku_pthread_t consumer;
struct consumer_thunk cthunk = {q, 0};
{
- int r = toku_pthread_create(&consumer, NULL, consumer_thread, (void*)&cthunk);
- assert(r==0);
+ int r = toku_pthread_create(toku_uninstrumented,
+ &consumer,
+ nullptr,
+ consumer_thread,
+ static_cast<void *>(&cthunk));
+ assert(r == 0);
}
toku_set_func_malloc_only(my_malloc);
toku_set_func_realloc_only(my_realloc);
- ft_loader_set_os_fwrite(bad_fwrite);
+ toku_set_func_fwrite(bad_fwrite);
toku_set_func_write(bad_write);
toku_set_func_pwrite(bad_pwrite);
toku_set_func_fdopen(bad_fdopen);
@@ -427,7 +431,7 @@ static void test (const char *directory, bool is_error) {
toku_set_func_malloc(NULL);
toku_set_func_realloc(NULL);
- ft_loader_set_os_fwrite(NULL);
+ toku_set_func_fwrite(nullptr);
toku_set_func_write(NULL);
toku_set_func_pwrite(NULL);
toku_set_func_fdopen(NULL);
diff --git a/storage/tokudb/PerconaFT/ft/tests/ftloader-test-writer-errors.cc b/storage/tokudb/PerconaFT/ft/tests/ftloader-test-writer-errors.cc
index 0784ca87a26..e4423319518 100644
--- a/storage/tokudb/PerconaFT/ft/tests/ftloader-test-writer-errors.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/ftloader-test-writer-errors.cc
@@ -154,7 +154,7 @@ static int write_dbfile (char *tf_template, int n, char *output_name, bool expec
toku_set_func_malloc_only(my_malloc);
toku_set_func_realloc_only(my_realloc);
- ft_loader_set_os_fwrite(bad_fwrite);
+ toku_set_func_fwrite(bad_fwrite);
toku_set_func_write(bad_write);
toku_set_func_pwrite(bad_pwrite);
ft_loader_set_error_function(&bl.error_callback, NULL, NULL);
@@ -164,7 +164,7 @@ static int write_dbfile (char *tf_template, int n, char *output_name, bool expec
toku_set_func_malloc_only(NULL);
toku_set_func_realloc_only(NULL);
- ft_loader_set_os_fwrite(NULL);
+ toku_set_func_fwrite(nullptr);
toku_set_func_write(NULL);
toku_set_func_pwrite(NULL);
diff --git a/storage/tokudb/PerconaFT/ft/tests/log-test4.cc b/storage/tokudb/PerconaFT/ft/tests/log-test4.cc
index a31181deb30..e0bbedb95bf 100644
--- a/storage/tokudb/PerconaFT/ft/tests/log-test4.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/log-test4.cc
@@ -63,11 +63,14 @@ test_main (int argc __attribute__((__unused__)),
r = toku_logger_close(&logger); assert(r == 0);
{
- toku_struct_stat statbuf;
- sprintf(logname, "%s/log000000000000.tokulog%d", TOKU_TEST_FILENAME, TOKU_LOG_VERSION);
- r = toku_stat(logname, &statbuf);
- assert(r==0);
- assert(statbuf.st_size==12+5);
+ toku_struct_stat statbuf;
+ sprintf(logname,
+ "%s/log000000000000.tokulog%d",
+ TOKU_TEST_FILENAME,
+ TOKU_LOG_VERSION);
+ r = toku_stat(logname, &statbuf, toku_uninstrumented);
+ assert(r == 0);
+ assert(statbuf.st_size == 12 + 5);
}
toku_os_recursive_delete(TOKU_TEST_FILENAME);
return 0;
diff --git a/storage/tokudb/PerconaFT/ft/tests/log-test5.cc b/storage/tokudb/PerconaFT/ft/tests/log-test5.cc
index d4e31af22dc..fed9467a4ae 100644
--- a/storage/tokudb/PerconaFT/ft/tests/log-test5.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/log-test5.cc
@@ -81,14 +81,14 @@ test_main (int argc __attribute__((__unused__)),
struct dirent *dirent;
while ((dirent=readdir(dir))) {
if (strncmp(dirent->d_name, "log", 3)!=0) continue;
- char fname[TOKU_PATH_MAX+1];
- toku_path_join(fname, 2, TOKU_TEST_FILENAME, dirent->d_name);
- toku_struct_stat statbuf;
- r = toku_stat(fname, &statbuf);
- assert(r==0);
- assert(statbuf.st_size<=LSIZE+10);
- }
- r = closedir(dir);
+ char fname[TOKU_PATH_MAX + 1];
+ toku_path_join(fname, 2, TOKU_TEST_FILENAME, dirent->d_name);
+ toku_struct_stat statbuf;
+ r = toku_stat(fname, &statbuf, toku_uninstrumented);
+ assert(r == 0);
+ assert(statbuf.st_size <= LSIZE + 10);
+ }
+ r = closedir(dir);
assert(r==0);
}
toku_os_recursive_delete(TOKU_TEST_FILENAME);
diff --git a/storage/tokudb/PerconaFT/ft/tests/log-test6.cc b/storage/tokudb/PerconaFT/ft/tests/log-test6.cc
index 4d17488c57c..0e8b94566df 100644
--- a/storage/tokudb/PerconaFT/ft/tests/log-test6.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/log-test6.cc
@@ -86,11 +86,14 @@ test_main (int argc __attribute__((__unused__)),
{
char logname[PATH_MAX];
- toku_struct_stat statbuf;
- sprintf(logname, "%s/log000000000000.tokulog%d", TOKU_TEST_FILENAME, TOKU_LOG_VERSION);
- r = toku_stat(logname, &statbuf);
- assert(r==0);
- assert(statbuf.st_size<=LSIZE);
+ toku_struct_stat statbuf;
+ sprintf(logname,
+ "%s/log000000000000.tokulog%d",
+ TOKU_TEST_FILENAME,
+ TOKU_LOG_VERSION);
+ r = toku_stat(logname, &statbuf, toku_uninstrumented);
+ assert(r == 0);
+ assert(statbuf.st_size <= LSIZE);
}
toku_os_recursive_delete(TOKU_TEST_FILENAME);
return 0;
diff --git a/storage/tokudb/PerconaFT/ft/tests/recovery-bad-last-entry.cc b/storage/tokudb/PerconaFT/ft/tests/recovery-bad-last-entry.cc
index 431ee4b5e50..a3c934d1f4b 100644
--- a/storage/tokudb/PerconaFT/ft/tests/recovery-bad-last-entry.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/recovery-bad-last-entry.cc
@@ -83,11 +83,16 @@ run_test(void) {
r = toku_dup2(devnul, fileno(stderr)); assert(r==fileno(stderr));
r = close(devnul); assert(r==0);
- char fname[TOKU_PATH_MAX+1];
- sprintf(fname, "%s/%s%d", TOKU_TEST_FILENAME, "log000000000000.tokulog", TOKU_LOG_VERSION);
-
- r = toku_stat(fname, &st); assert(r==0);
- if ( st.st_size - trim > magic_begin_end_checkpoint_sz ) {
+ char fname[TOKU_PATH_MAX + 1];
+ sprintf(fname,
+ "%s/%s%d",
+ TOKU_TEST_FILENAME,
+ "log000000000000.tokulog",
+ TOKU_LOG_VERSION);
+
+ r = toku_stat(fname, &st, toku_uninstrumented);
+ assert(r == 0);
+ if (st.st_size - trim > magic_begin_end_checkpoint_sz) {
r = truncate(fname, st.st_size - trim);
CKERR(r);
}
diff --git a/storage/tokudb/PerconaFT/ft/tests/test-bjm.cc b/storage/tokudb/PerconaFT/ft/tests/test-bjm.cc
index 97e00c42b95..6afe5b9f7c4 100644
--- a/storage/tokudb/PerconaFT/ft/tests/test-bjm.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/test-bjm.cc
@@ -71,12 +71,16 @@ static void bjm_test(void) {
bjm_reset(bjm);
r = bjm_add_background_job(bjm);
- assert_zero(r);
- toku_pthread_t tid;
- r = toku_pthread_create(&tid, NULL, finish_bjm, NULL);
assert_zero(r);
- usleep(2*1024*1024);
- // should return non-zero because tid is waiting
+ toku_pthread_t tid;
+ r = toku_pthread_create(toku_uninstrumented,
+ &tid,
+ nullptr,
+ finish_bjm,
+ nullptr);
+ assert_zero(r);
+ usleep(2 * 1024 * 1024);
+ // should return non-zero because tid is waiting
// for background jobs to finish
r = bjm_add_background_job(bjm);
assert(r != 0);
diff --git a/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-flush.cc b/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-flush.cc
index 3e5d9bba817..06a26614885 100644
--- a/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-flush.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-flush.cc
@@ -113,10 +113,14 @@ static void flusher_callback(int state, void* extra) {
if ((state == flt_flush_before_child_pin && !after_child_pin) ||
(state == ft_flush_aflter_child_pin && after_child_pin)) {
checkpoint_called = true;
- int r = toku_pthread_create(&checkpoint_tid, NULL, do_checkpoint, NULL);
+ int r = toku_pthread_create(toku_uninstrumented,
+ &checkpoint_tid,
+ nullptr,
+ do_checkpoint,
+ nullptr);
assert_zero(r);
while (!checkpoint_callback_called) {
- usleep(1*1024*1024);
+ usleep(1 * 1024 * 1024);
}
}
}
diff --git a/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-merge.cc b/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-merge.cc
index cb316127ef7..1029dfef320 100644
--- a/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-merge.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-merge.cc
@@ -103,10 +103,14 @@ static void flusher_callback(int state, void* extra) {
}
if (state == desired_state) {
checkpoint_called = true;
- int r = toku_pthread_create(&checkpoint_tid, NULL, do_checkpoint, NULL);
+ int r = toku_pthread_create(toku_uninstrumented,
+ &checkpoint_tid,
+ nullptr,
+ do_checkpoint,
+ nullptr);
assert_zero(r);
while (!checkpoint_callback_called) {
- usleep(1*1024*1024);
+ usleep(1 * 1024 * 1024);
}
}
}
diff --git a/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-rebalance.cc b/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-rebalance.cc
index 5f8485ac4ec..208ebe3ca31 100644
--- a/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-rebalance.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-rebalance.cc
@@ -103,10 +103,14 @@ static void flusher_callback(int state, void* extra) {
}
if (state == desired_state) {
checkpoint_called = true;
- int r = toku_pthread_create(&checkpoint_tid, NULL, do_checkpoint, NULL);
+ int r = toku_pthread_create(toku_uninstrumented,
+ &checkpoint_tid,
+ nullptr,
+ do_checkpoint,
+ nullptr);
assert_zero(r);
while (!checkpoint_callback_called) {
- usleep(1*1024*1024);
+ usleep(1 * 1024 * 1024);
}
}
}
diff --git a/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-split.cc b/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-split.cc
index 70c3ba22a0c..2b29de409b1 100644
--- a/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-split.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/test-checkpoint-during-split.cc
@@ -113,10 +113,14 @@ static void flusher_callback(int state, void* extra) {
if ((state == flt_flush_before_split && !after_split) ||
(state == flt_flush_during_split && after_split)) {
checkpoint_called = true;
- int r = toku_pthread_create(&checkpoint_tid, NULL, do_checkpoint, NULL);
+ int r = toku_pthread_create(toku_uninstrumented,
+ &checkpoint_tid,
+ nullptr,
+ do_checkpoint,
+ nullptr);
assert_zero(r);
while (!checkpoint_callback_called) {
- usleep(1*1024*1024);
+ usleep(1 * 1024 * 1024);
}
}
}
diff --git a/storage/tokudb/PerconaFT/ft/tests/test3681.cc b/storage/tokudb/PerconaFT/ft/tests/test3681.cc
index e5e24a88246..9e4a46e8dfe 100644
--- a/storage/tokudb/PerconaFT/ft/tests/test3681.cc
+++ b/storage/tokudb/PerconaFT/ft/tests/test3681.cc
@@ -91,13 +91,35 @@ static void *startb (void *n) {
return NULL;
}
-static void test3681 (void) {
+static void test3681(void) {
setup();
- toku_pthread_t a,b;
- { int r; r = toku_pthread_create(&a, NULL, starta, NULL); assert(r==0); }
- { int r; r = toku_pthread_create(&b, NULL, startb, NULL); assert(r==0); }
- { int r; void *v; r = toku_pthread_join(a, &v); assert(r==0); assert(v==NULL); }
- { int r; void *v; r = toku_pthread_join(b, &v); assert(r==0); assert(v==NULL); }
+ toku_pthread_t a, b;
+ {
+ int r;
+ r = toku_pthread_create(
+ toku_uninstrumented, &a, nullptr, starta, nullptr);
+ assert(r == 0);
+ }
+ {
+ int r;
+ r = toku_pthread_create(
+ toku_uninstrumented, &b, nullptr, startb, nullptr);
+ assert(r == 0);
+ }
+ {
+ int r;
+ void *v;
+ r = toku_pthread_join(a, &v);
+ assert(r == 0);
+ assert(v == NULL);
+ }
+ {
+ int r;
+ void *v;
+ r = toku_pthread_join(b, &v);
+ assert(r == 0);
+ assert(v == NULL);
+ }
finish();
}
diff --git a/storage/tokudb/PerconaFT/ft/txn/roll.cc b/storage/tokudb/PerconaFT/ft/txn/roll.cc
index 97afd2f5bdb..7228de06f34 100644
--- a/storage/tokudb/PerconaFT/ft/txn/roll.cc
+++ b/storage/tokudb/PerconaFT/ft/txn/roll.cc
@@ -195,14 +195,14 @@ int toku_rollback_frename(BYTESTRING old_iname,
toku_cachetable_get_fname_in_cwd(cachetable, new_iname.data),
&toku_free);
- if (toku_stat(old_iname_full.get(), &stat) == -1) {
+ if (toku_stat(old_iname_full.get(), &stat, toku_uninstrumented) == -1) {
if (ENOENT == errno)
old_exist = false;
else
return 1;
}
- if (toku_stat(new_iname_full.get(), &stat) == -1) {
+ if (toku_stat(new_iname_full.get(), &stat, toku_uninstrumented) == -1) {
if (ENOENT == errno || ENAMETOOLONG == errno)
new_exist = false;
else
@@ -220,7 +220,7 @@ int toku_rollback_frename(BYTESTRING old_iname,
// removed
// and the new file is renamed.
if (old_exist && new_exist &&
- (toku_os_unlink(old_iname_full.get()) == -1 ||
+ (toku_os_delete(old_iname_full.get()) == -1 ||
toku_os_rename(new_iname_full.get(), old_iname_full.get()) == -1 ||
toku_fsync_directory(new_iname_full.get()) == -1 ||
toku_fsync_directory(old_iname_full.get()) == -1))
diff --git a/storage/tokudb/PerconaFT/ft/txn/rollback_log_node_cache.cc b/storage/tokudb/PerconaFT/ft/txn/rollback_log_node_cache.cc
index 71b1e79277c..5e1ab746936 100644
--- a/storage/tokudb/PerconaFT/ft/txn/rollback_log_node_cache.cc
+++ b/storage/tokudb/PerconaFT/ft/txn/rollback_log_node_cache.cc
@@ -41,7 +41,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "txn/rollback_log_node_cache.h"
-void rollback_log_node_cache::init (uint32_t max_num_avail_nodes) {
+toku_instr_key* rollback_log_node_cache_mutex_key;
+
+void rollback_log_node_cache::init(uint32_t max_num_avail_nodes) {
XMALLOC_N(max_num_avail_nodes, m_avail_blocknums);
m_max_num_avail = max_num_avail_nodes;
m_first = 0;
@@ -49,7 +51,7 @@ void rollback_log_node_cache::init (uint32_t max_num_avail_nodes) {
toku_pthread_mutexattr_t attr;
toku_mutexattr_init(&attr);
toku_mutexattr_settype(&attr, TOKU_MUTEX_ADAPTIVE);
- toku_mutex_init(&m_mutex, &attr);
+ toku_mutex_init(*rollback_log_node_cache_mutex_key, &m_mutex, &attr);
toku_mutexattr_destroy(&attr);
}
diff --git a/storage/tokudb/PerconaFT/ft/txn/txn.cc b/storage/tokudb/PerconaFT/ft/txn/txn.cc
index a3ce6beb7b0..7327cbd9d24 100644
--- a/storage/tokudb/PerconaFT/ft/txn/txn.cc
+++ b/storage/tokudb/PerconaFT/ft/txn/txn.cc
@@ -45,8 +45,11 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "ft/txn/txn_manager.h"
#include "util/status.h"
-void
-toku_txn_get_status(TXN_STATUS s) {
+toku_instr_key *txn_lock_mutex_key;
+toku_instr_key *txn_state_lock_mutex_key;
+toku_instr_key *result_state_cond_key;
+
+void toku_txn_get_status(TXN_STATUS s) {
txn_status.init();
*s = txn_status;
}
@@ -225,74 +228,74 @@ static void toku_txn_create_txn (
static txn_child_manager tcm;
- struct tokutxn new_txn = {
- .txnid = {.parent_id64 = TXNID_NONE, .child_id64 = TXNID_NONE },
- .snapshot_txnid64 = TXNID_NONE,
- .snapshot_type = for_recovery ? TXN_SNAPSHOT_NONE : snapshot_type,
- .for_recovery = for_recovery,
- .logger = logger,
- .parent = parent_tokutxn,
- .child = NULL,
- .child_manager_s = tcm,
- .child_manager = NULL,
- .container_db_txn = container_db_txn,
- .live_root_txn_list = nullptr,
- .xids = NULL,
- .snapshot_next = NULL,
- .snapshot_prev = NULL,
- .begin_was_logged = false,
- .declared_read_only = read_only,
- .do_fsync = false,
- .force_fsync_on_commit = false,
- .do_fsync_lsn = ZERO_LSN,
- .xa_xid = {0, 0, 0, ""},
- .progress_poll_fun = NULL,
- .progress_poll_fun_extra = NULL,
-
- // You cannot initialize txn_lock a TOKU_MUTEX_INITIALIZER, because we
- // will initialize it in the code below, and it cannot already
- // be initialized at that point. Also, in general, you don't
- // get to use PTHREAD_MUTEX_INITALIZER (which is what is inside
- // TOKU_MUTEX_INITIALIZER) except in static variables, and this
- // is initializing an auto variable.
- //
- // And we cannot simply avoid initializing these fields
- // because, although it avoids -Wmissing-field-initializer
- // errors under gcc, it gets other errors about non-trivial
- // designated initializers not being supported.
-
- .txn_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER
- .open_fts = open_fts,
- .roll_info = roll_info,
- .state_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER
- .state_cond = ZERO_COND_INITIALIZER, // Not TOKU_COND_INITIALIZER
- .state = TOKUTXN_LIVE,
- .num_pin = 0,
- .client_id = 0,
- .client_extra = nullptr,
- .start_time = time(NULL),
- };
+struct tokutxn new_txn = {
+ .txnid = {.parent_id64 = TXNID_NONE, .child_id64 = TXNID_NONE },
+ .snapshot_txnid64 = TXNID_NONE,
+ .snapshot_type = for_recovery ? TXN_SNAPSHOT_NONE : snapshot_type,
+ .for_recovery = for_recovery,
+ .logger = logger,
+ .parent = parent_tokutxn,
+ .child = NULL,
+ .child_manager_s = tcm,
+ .child_manager = NULL,
+ .container_db_txn = container_db_txn,
+ .live_root_txn_list = nullptr,
+ .xids = NULL,
+ .snapshot_next = NULL,
+ .snapshot_prev = NULL,
+ .begin_was_logged = false,
+ .declared_read_only = read_only,
+ .do_fsync = false,
+ .force_fsync_on_commit = false,
+ .do_fsync_lsn = ZERO_LSN,
+ .xa_xid = {0, 0, 0, ""},
+ .progress_poll_fun = NULL,
+ .progress_poll_fun_extra = NULL,
+
+ // You cannot initialize txn_lock a TOKU_MUTEX_INITIALIZER, because we
+ // will initialize it in the code below, and it cannot already
+ // be initialized at that point. Also, in general, you don't
+ // get to use PTHREAD_MUTEX_INITALIZER (which is what is inside
+ // TOKU_MUTEX_INITIALIZER) except in static variables, and this
+ // is initializing an auto variable.
+ //
+ // And we cannot simply avoid initializing these fields
+ // because, although it avoids -Wmissing-field-initializer
+ // errors under gcc, it gets other errors about non-trivial
+ // designated initializers not being supported.
+
+ .txn_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER
+ .open_fts = open_fts,
+ .roll_info = roll_info,
+ .state_lock = ZERO_MUTEX_INITIALIZER, // Not TOKU_MUTEX_INITIALIZER
+ .state_cond = ZERO_COND_INITIALIZER, // Not TOKU_COND_INITIALIZER
+ .state = TOKUTXN_LIVE,
+ .num_pin = 0,
+ .client_id = 0,
+ .client_extra = nullptr,
+ .start_time = time(NULL),
+};
- TOKUTXN result = NULL;
- XMEMDUP(result, &new_txn);
- invalidate_xa_xid(&result->xa_xid);
- if (parent_tokutxn == NULL) {
- result->child_manager = &result->child_manager_s;
- result->child_manager->init(result);
+TOKUTXN result = NULL;
+XMEMDUP(result, &new_txn);
+invalidate_xa_xid(&result->xa_xid);
+if (parent_tokutxn == NULL) {
+ result->child_manager = &result->child_manager_s;
+ result->child_manager->init(result);
}
else {
result->child_manager = parent_tokutxn->child_manager;
}
- toku_mutex_init(&result->txn_lock, nullptr);
+ toku_mutex_init(*txn_lock_mutex_key, &result->txn_lock, nullptr);
toku_pthread_mutexattr_t attr;
toku_mutexattr_init(&attr);
toku_mutexattr_settype(&attr, TOKU_MUTEX_ADAPTIVE);
- toku_mutex_init(&result->state_lock, &attr);
+ toku_mutex_init(*txn_state_lock_mutex_key, &result->state_lock, &attr);
toku_mutexattr_destroy(&attr);
- toku_cond_init(&result->state_cond, nullptr);
+ toku_cond_init(*result_state_cond_key, &result->state_cond, nullptr);
*tokutxn = result;
diff --git a/storage/tokudb/PerconaFT/ft/txn/txn_child_manager.cc b/storage/tokudb/PerconaFT/ft/txn/txn_child_manager.cc
index db110127c55..99a21331b0a 100644
--- a/storage/tokudb/PerconaFT/ft/txn/txn_child_manager.cc
+++ b/storage/tokudb/PerconaFT/ft/txn/txn_child_manager.cc
@@ -39,6 +39,8 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
#include "ft/logger/log-internal.h"
#include "ft/txn/txn_child_manager.h"
+toku_instr_key *txn_child_manager_mutex_key;
+
//
// initialized a txn_child_manager,
// when called, root->txnid.parent_id64 may not yet be set
@@ -53,7 +55,7 @@ void txn_child_manager::init(TOKUTXN root) {
toku_pthread_mutexattr_t attr;
toku_mutexattr_init(&attr);
toku_mutexattr_settype(&attr, TOKU_MUTEX_ADAPTIVE);
- toku_mutex_init(&m_mutex, &attr);
+ toku_mutex_init(*txn_child_manager_mutex_key, &m_mutex, &attr);
toku_mutexattr_destroy(&attr);
}
diff --git a/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc b/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc
index 8fe52b10597..1b55844bc7d 100644
--- a/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc
+++ b/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc
@@ -56,7 +56,10 @@ void set_test_txn_sync_callback(void (*cb) (pthread_t, void *), void *extra) {
}
bool garbage_collection_debug = false;
-static bool txn_records_snapshot(TXN_SNAPSHOT_TYPE snapshot_type, struct tokutxn *parent) {
+toku_instr_key *txn_manager_lock_mutex_key;
+
+static bool txn_records_snapshot(TXN_SNAPSHOT_TYPE snapshot_type,
+ struct tokutxn *parent) {
if (snapshot_type == TXN_COPIES_SNAPSHOT) {
return false;
}
@@ -248,9 +251,10 @@ verify_snapshot_system(TXN_MANAGER txn_manager UU()) {
live_root_txns_omt.destroy();
}
-void toku_txn_manager_init(TXN_MANAGER* txn_managerp) {
+void toku_txn_manager_init(TXN_MANAGER *txn_managerp) {
TXN_MANAGER XCALLOC(txn_manager);
- toku_mutex_init(&txn_manager->txn_manager_lock, NULL);
+ toku_mutex_init(
+ *txn_manager_lock_mutex_key, &txn_manager->txn_manager_lock, nullptr);
txn_manager->live_root_txns.create();
txn_manager->live_root_ids.create();
txn_manager->snapshot_head = NULL;