From ee6d0768d3e70802cafbf35dc85cc31c88dfdad3 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Mon, 26 Apr 2010 04:07:38 +0000 Subject: [PATCH] Fix failing assert by replacing trywritelock with writelock in concurrentBufferManager. Revision -r1380 relaxed an invariant, causing the trylock to sometimes contend with other threads --- src/stasis/bufferManager/concurrentBufferManager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stasis/bufferManager/concurrentBufferManager.c b/src/stasis/bufferManager/concurrentBufferManager.c index 0407273..159a02b 100644 --- a/src/stasis/bufferManager/concurrentBufferManager.c +++ b/src/stasis/bufferManager/concurrentBufferManager.c @@ -201,8 +201,10 @@ static Page * chLoadPageImpl_helper(stasis_buffer_manager_t* bm, int xid, const p = tls->p; tls->p = NULL; - int succ = trywritelock(p->loadlatch, 0); - assert(succ); + // Need to acquire lock because some loadPage (in race with us) could have a + // pointer to the page. However, we must be the only thread + // that has the page in its TLS, or something is seriously wrong. + writelock(p->loadlatch, 0); // this has to happen before the page enters LRU; concurrentWrapper (and perhaps future implementations) hash on pageid. p->id = pageid;