[ 
https://issues.apache.org/jira/browse/CASSANDRA-6912?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13955313#comment-13955313
 ] 

Benedict commented on CASSANDRA-6912:
-------------------------------------

Sure: basically instead of a boolean isReplaced flag, we build a linked-list 
chain of replacement, which we synchronise using a shared object to make 
maintenance of the list across multiple threads simple. Then on close we check 
if any of the closeable resources differ between any chains either side of us, 
and any that are in neither of the adjacent links (if any) are closed. It's 
worth pointing out that as of this patch only one of those resources can 
possibly differ, but I think it is more correct to test all of them even 
knowing this, since it is not expensive and is future proof. Once we've made 
this decision we remove ourselves from the linked list, so that anybody 
behind/ahead will compare against only other still opened resources.

I've also folded the close() and releaseReferences() tidying up into one tidy() 
method with a boolean flag for the kind of release we're doing, as this seemed 
more explicit to me.

> SSTableReader.isReplaced does not allow for safe resource cleanup
> -----------------------------------------------------------------
>
>                 Key: CASSANDRA-6912
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-6912
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Benedict
>            Assignee: Benedict
>             Fix For: 2.1 beta2
>
>
> There are a number of possible race conditions on resource cleanup from the 
> use of cloneWithNewSummarySamplingLevel, because the replacement sstable can 
> be itself replaced/obsoleted while the prior sstable is still referenced 
> (this is actually quite easy with compaction, but can happen in other 
> circumstances less commonly).



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to