From: Xiaoxi Chen Date: Wed, 29 Apr 2015 05:45:52 +0000 (+0800) Subject: os/Newstore: flush_commit return true on STATE_KV_DONE X-Git-Tag: v9.1.0~242^2~31 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=36ed3dd20ad2e7922a2ec300036601ba03841d3f;p=ceph.git os/Newstore: flush_commit return true on STATE_KV_DONE There is a racing condition here, if the flush_commit() call happened after _txc_finish_kv and before next state, the context was pushed to on_commits but no one will handle the context since we already pass _txc_finish_kv. This bug can be easily reproduce by putting a sleep(5) after _txc_finish_kv, and trigger the bug by ceph-osd -i 0 --mkfs. Fix this bug by return true directly when state >= STATE_KV_DONE(instead of > in previous code). We already persist the data in STATE_KV_DONE so it's safe for us to do this. Signed-off-by: Xiaoxi Chen --- diff --git a/src/os/newstore/NewStore.h b/src/os/newstore/NewStore.h index ce6dfac17d04..95122a1c4662 100644 --- a/src/os/newstore/NewStore.h +++ b/src/os/newstore/NewStore.h @@ -304,10 +304,10 @@ public: return true; } TransContext *txc = &q.back(); - if (txc->state > TransContext::STATE_KV_DONE) { + if (txc->state >= TransContext::STATE_KV_DONE) { return true; } - assert(txc->state <= TransContext::STATE_KV_DONE); + assert(txc->state < TransContext::STATE_KV_DONE); txc->oncommits.push_back(c); return false; }