You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Stu Hood (JIRA)" <ji...@apache.org> on 2011/02/16 01:40:58 UTC
[jira] Issue Comment Edited: (CASSANDRA-1954) Double-check or
replace RRW memtable lock
[ https://issues.apache.org/jira/browse/CASSANDRA-1954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12995091#comment-12995091 ]
Stu Hood edited comment on CASSANDRA-1954 at 2/16/11 12:39 AM:
---------------------------------------------------------------
An idea to replace this lock was proposed in IRC yesterday: if the list of memtables and sstables was stored in a single immutable, cas'able structure, you could atomically swap a memtable from active to flushing, and then from flushing into an sstable. Example structure:
{code:java}class View {
final List<Memtable> active;
final List<Memtable> flushing;
final List<SSTableReader> sstables;
}{code}
So a writing thread noticing an active Memtable past its threshold would attempt to CAS in a new Memtable while moving the current memtable to flushing. A thread finishing a flush would attempt to CAS the memtable it flushed out of flushing and into the sstable list.
EDIT: Bah... this doesn't actually remove the necessity of the write lock, since we need to ensure that writers are not looking at a memtable that has been moved to flushing. We'd need another solution to that problem.
was (Author: stuhood):
An idea to replace this lock was proposed in IRC yesterday: if the list of memtables and sstables was stored in a single immutable, cas'able structure, you could atomically swap a memtable from active to flushing, and then from flushing into an sstable. Example structure:
{code:java}class View {
final List<Memtable> active;
final List<Memtable> flushing;
final List<SSTableReader> sstables;
}{code}
So a writing thread noticing an active Memtable past its threshold would attempt to CAS in a new Memtable while moving the current memtable to flushing. A thread finishing a flush would attempt to CAS the memtable it flushed out of flushing and into the sstable list.
> Double-check or replace RRW memtable lock
> -----------------------------------------
>
> Key: CASSANDRA-1954
> URL: https://issues.apache.org/jira/browse/CASSANDRA-1954
> Project: Cassandra
> Issue Type: Improvement
> Components: Core
> Reporter: Stu Hood
> Priority: Minor
> Attachments: 0001-Double-check-in-maybeSwitchMemtable-to-minimize-writeL.txt
>
>
> {quote}...when a Memtable reaches its threshold, up to (all) N write threads will often notice, and race to acquire the writeLock in order to freeze the memtable. This means that we do way more writeLock acquisitions than we need to...{quote}
> See CASSANDRA-1930 for backstory, but adding double checking inside a read lock before trying to re-entrantly acquire the writelock would eliminate most of these excess writelock acquisitions.
> Alternatively, we should explore removing locking from these structures entirely, and replacing the writeLock acquisition with a per-memtable counter of active threads.
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira