Commit 13dbeb51 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

closes #5387, fix issue, sleep at most once during get_and_pin_with_dep_pairs

git-svn-id: file:///svn/toku/tokudb@46955 c7de825b-a66e-492c-adef-691d508d4ae1
parent d7cbb0f9
...@@ -1410,7 +1410,8 @@ static bool try_pin_pair( ...@@ -1410,7 +1410,8 @@ static bool try_pin_pair(
enum cachetable_dirty* dependent_dirty, enum cachetable_dirty* dependent_dirty,
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback, CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback, CACHETABLE_PARTIAL_FETCH_CALLBACK pf_callback,
void* read_extraargs void* read_extraargs,
bool already_slept
) )
{ {
bool dep_checkpoint_pending[num_dependent_pairs]; bool dep_checkpoint_pending[num_dependent_pairs];
...@@ -1459,7 +1460,7 @@ static bool try_pin_pair( ...@@ -1459,7 +1460,7 @@ static bool try_pin_pair(
try_again = false; try_again = false;
goto exit; goto exit;
} }
if (ct->ev.should_client_thread_sleep()) { if (ct->ev.should_client_thread_sleep() && !already_slept) {
pair_lock(p); pair_lock(p);
nb_mutex_unlock(&p->value_nb_mutex); nb_mutex_unlock(&p->value_nb_mutex);
pair_unlock(p); pair_unlock(p);
...@@ -1514,6 +1515,7 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched ( ...@@ -1514,6 +1515,7 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched (
{ {
CACHETABLE ct = cachefile->cachetable; CACHETABLE ct = cachefile->cachetable;
bool wait = false; bool wait = false;
bool already_slept = false;
PAIR dependent_pairs[num_dependent_pairs]; PAIR dependent_pairs[num_dependent_pairs];
bool dep_checkpoint_pending[num_dependent_pairs]; bool dep_checkpoint_pending[num_dependent_pairs];
...@@ -1528,6 +1530,7 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched ( ...@@ -1528,6 +1530,7 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched (
// We shouldn't be holding the read list lock while // We shouldn't be holding the read list lock while
// waiting for the evictor to remove pairs. // waiting for the evictor to remove pairs.
ct->list.read_list_unlock(); ct->list.read_list_unlock();
already_slept = true;
ct->ev.wait_for_cache_pressure_to_subside(); ct->ev.wait_for_cache_pressure_to_subside();
ct->list.read_list_lock(); ct->list.read_list_lock();
} }
...@@ -1557,7 +1560,8 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched ( ...@@ -1557,7 +1560,8 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched (
dependent_dirty, dependent_dirty,
pf_req_callback, pf_req_callback,
pf_callback, pf_callback,
read_extraargs read_extraargs,
already_slept
); );
if (try_again) { if (try_again) {
wait = true; wait = true;
...@@ -1568,7 +1572,11 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched ( ...@@ -1568,7 +1572,11 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched (
} }
} }
else { else {
if (ct->ev.should_client_thread_sleep()) { // we only want to sleep once per call to get_and_pin. If we have already
// slept and there is still cache pressure, then we might as
// well just complete the call, because the sleep did not help
// This happens in extreme scenarios.
if (ct->ev.should_client_thread_sleep() && !already_slept) {
wait = true; wait = true;
goto beginning; goto beginning;
} }
...@@ -1599,7 +1607,8 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched ( ...@@ -1599,7 +1607,8 @@ int toku_cachetable_get_and_pin_with_dep_pairs_batched (
dependent_dirty, dependent_dirty,
pf_req_callback, pf_req_callback,
pf_callback, pf_callback,
read_extraargs read_extraargs,
already_slept
); );
if (try_again) { if (try_again) {
wait = true; wait = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment