Commit 379bf01c authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:3902], set state of PAIRs before posting them on threads for eviction/fetching

git-svn-id: file:///svn/toku/tokudb@34217 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5e49e706
...@@ -1404,6 +1404,14 @@ static int maybe_flush_some (CACHETABLE ct, long size) { ...@@ -1404,6 +1404,14 @@ static int maybe_flush_some (CACHETABLE ct, long size) {
if (bytes_freed_estimate > 0) { if (bytes_freed_estimate > 0) {
curr_in_clock->size_evicting_estimate = bytes_freed_estimate; curr_in_clock->size_evicting_estimate = bytes_freed_estimate;
ct->size_evicting += bytes_freed_estimate; ct->size_evicting += bytes_freed_estimate;
// set the state before we post on writer thread (and give up cachetable lock)
// if we do not set the state here, any thread that tries
// to access this node in between when this function exits and the
// workitem gets placed on a writer thread will block (because it will think
// that the PAIR's lock will be released soon), and keep blocking
// until the workitem is done. This would be bad, as that thread may
// be holding the ydb lock.
curr_in_clock->state = CTPAIR_WRITING;
WORKITEM wi = &curr_in_clock->asyncwork; WORKITEM wi = &curr_in_clock->asyncwork;
workitem_init(wi, cachetable_partial_eviction, curr_in_clock); workitem_init(wi, cachetable_partial_eviction, curr_in_clock);
workqueue_enq(&ct->wq, wi, 0); workqueue_enq(&ct->wq, wi, 0);
...@@ -2169,6 +2177,7 @@ int toku_cachefile_prefetch(CACHEFILE cf, CACHEKEY key, u_int32_t fullhash, ...@@ -2169,6 +2177,7 @@ int toku_cachefile_prefetch(CACHEFILE cf, CACHEKEY key, u_int32_t fullhash,
if (partial_fetch_required) { if (partial_fetch_required) {
rwlock_write_lock(&p->rwlock, ct->mutex); rwlock_write_lock(&p->rwlock, ct->mutex);
p->state = CTPAIR_READING;
struct cachefile_partial_prefetch_args *MALLOC(cpargs); struct cachefile_partial_prefetch_args *MALLOC(cpargs);
cpargs->p = p; cpargs->p = p;
cpargs->pf_callback = pf_callback; cpargs->pf_callback = pf_callback;
......
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