Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 83B48116FC for ; Fri, 25 Apr 2014 00:43:49 +0000 (UTC) Received: (qmail 24291 invoked by uid 500); 25 Apr 2014 00:43:46 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 24216 invoked by uid 500); 25 Apr 2014 00:43:46 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 24205 invoked by uid 99); 25 Apr 2014 00:43:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Apr 2014 00:43:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id AAA009926D9; Fri, 25 Apr 2014 00:43:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aleksey@apache.org To: commits@cassandra.apache.org Date: Fri, 25 Apr 2014 00:43:45 -0000 Message-Id: <61369ef64bb5419b9bb9e033bf78f7fd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/4] git commit: Fix CFMetaData#getColumnDefinitionFromColumnName() Repository: cassandra Updated Branches: refs/heads/trunk 16bb16ed2 -> bd6431323 Fix CFMetaData#getColumnDefinitionFromColumnName() patch by Benedict Elliott Smith; reviewed by Aleksey Yeschenko for CASSANDRA-7074 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/72203c50 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/72203c50 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/72203c50 Branch: refs/heads/trunk Commit: 72203c503767618ba89c6ed03c0ed091dc6e701b Parents: 9359b7a Author: belliottsmith Authored: Fri Apr 25 03:01:41 2014 +0300 Committer: Aleksey Yeschenko Committed: Fri Apr 25 03:14:56 2014 +0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/cache/SerializingCache.java | 52 +++++++++++++++----- 2 files changed, 42 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/72203c50/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 69e9d37..b3470bf 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,7 @@ * Require nodetool rebuild_index to specify index names (CASSANDRA-7038) * Ensure that batchlog and hint timeouts do not produce hints (CASSANDRA-7058) * Don't shut MessagingService down when replacing a node (CASSANDRA-6476) + * Always clean up references in SerializingCache (CASSANDRA-6994) 1.2.16 http://git-wip-us.apache.org/repos/asf/cassandra/blob/72203c50/src/java/org/apache/cassandra/cache/SerializingCache.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cache/SerializingCache.java b/src/java/org/apache/cassandra/cache/SerializingCache.java index c7430d2..58da56b 100644 --- a/src/java/org/apache/cassandra/cache/SerializingCache.java +++ b/src/java/org/apache/cassandra/cache/SerializingCache.java @@ -20,6 +20,7 @@ package org.apache.cassandra.cache; import java.io.IOException; import java.util.Set; +import com.google.common.base.Throwables; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,7 +93,7 @@ public class SerializingCache implements ICache } catch (IOException e) { - logger.debug("Cannot fetch in memory data, we will failback to read from disk ", e); + logger.debug("Cannot fetch in memory data, we will fallback to read from disk ", e); return null; } } @@ -119,6 +120,7 @@ public class SerializingCache implements ICache } catch (IOException e) { + freeableMemory.unreference(); throw new RuntimeException(e); } return freeableMemory; @@ -177,7 +179,17 @@ public class SerializingCache implements ICache if (mem == null) return; // out of memory. never mind. - RefCountedMemory old = map.put(key, mem); + RefCountedMemory old; + try + { + old = map.put(key, mem); + } + catch (Throwable t) + { + mem.unreference(); + throw Throwables.propagate(t); + } + if (old != null) old.unreference(); } @@ -188,7 +200,17 @@ public class SerializingCache implements ICache if (mem == null) return false; // out of memory. never mind. - RefCountedMemory old = map.putIfAbsent(key, mem); + RefCountedMemory old; + try + { + old = map.putIfAbsent(key, mem); + } + catch (Throwable t) + { + mem.unreference(); + throw Throwables.propagate(t); + } + if (old != null) // the new value was not put, we've uselessly allocated some memory, free it mem.unreference(); @@ -202,24 +224,32 @@ public class SerializingCache implements ICache if (old == null) return false; + V oldValue; + // reference old guy before de-serializing + if (!old.reference()) + return false; // we have already freed hence noop. + + oldValue = deserialize(old); + old.unreference(); + + if (!oldValue.equals(oldToReplace)) + return false; + // see if the old value matches the one we want to replace RefCountedMemory mem = serialize(value); if (mem == null) return false; // out of memory. never mind. - V oldValue; - // reference old guy before de-serializing - if (!old.reference()) - return false; // we have already freed hence noop. + boolean success; try { - oldValue = deserialize(old); + success = map.replace(key, old, mem); } - finally + catch (Throwable t) { - old.unreference(); + mem.unreference(); + throw Throwables.propagate(t); } - boolean success = oldValue.equals(oldToReplace) && map.replace(key, old, mem); if (success) old.unreference(); // so it will be eventually be cleaned