You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2013/05/03 16:31:40 UTC

git commit: give CAS a minimum TTL of 3h

Updated Branches:
  refs/heads/trunk bdf08364a -> a7b80d78a


give CAS a minimum TTL of 3h


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a7b80d78
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a7b80d78
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a7b80d78

Branch: refs/heads/trunk
Commit: a7b80d78ab181c3eb1c51b94621a74023bc5d76f
Parents: bdf0836
Author: Jonathan Ellis <jb...@apache.org>
Authored: Fri May 3 09:30:31 2013 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Fri May 3 09:30:31 2013 -0500

----------------------------------------------------------------------
 NEWS.txt                                          |    2 ++
 src/java/org/apache/cassandra/db/SystemTable.java |   14 +++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a7b80d78/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index cb2437a..0ce07e8 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -52,6 +52,8 @@ Operations
     - ALTER TABLE DROP has been reenabled for CQL3 tables and has new semantics now.
       See https://cassandra.apache.org/doc/cql3/CQL.html#alterTableStmt and
       https://issues.apache.org/jira/browse/CASSANDRA-3919 for details.
+    - CAS uses gc_grace_seconds to determine how long to keep unused paxos
+      state around for, or a minimum of three hours.
 
 
 1.2.4

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a7b80d78/src/java/org/apache/cassandra/db/SystemTable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemTable.java b/src/java/org/apache/cassandra/db/SystemTable.java
index dc99bc8..dd818b2 100644
--- a/src/java/org/apache/cassandra/db/SystemTable.java
+++ b/src/java/org/apache/cassandra/db/SystemTable.java
@@ -21,9 +21,7 @@ import java.io.DataInputStream;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
-import java.nio.charset.CharacterCodingException;
 import java.util.*;
-import java.util.concurrent.ExecutionException;
 
 import com.google.common.base.Function;
 import com.google.common.collect.HashMultimap;
@@ -762,7 +760,7 @@ public class SystemTable
         processInternal(String.format(req,
                                       PAXOS_CF,
                                       UUIDGen.microsTimestamp(promise.ballot),
-                                      promise.update.metadata().getGcGraceSeconds(),
+                                      paxosTtl(promise.update.metadata),
                                       promise.ballot,
                                       ByteBufferUtil.bytesToHex(promise.key),
                                       promise.update.id()));
@@ -773,12 +771,18 @@ public class SystemTable
         processInternal(String.format("UPDATE %s USING TIMESTAMP %d AND TTL %d SET proposal = 0x%s WHERE row_key = 0x%s AND cf_id = %s",
                                       PAXOS_CF,
                                       UUIDGen.microsTimestamp(commit.ballot),
-                                      commit.update.metadata().getGcGraceSeconds(),
+                                      paxosTtl(commit.update.metadata),
                                       ByteBufferUtil.bytesToHex(commit.update.toBytes()),
                                       ByteBufferUtil.bytesToHex(commit.key),
                                       commit.update.id()));
     }
 
+    private static int paxosTtl(CFMetaData metadata)
+    {
+        // keep paxos state around for at least 3h
+        return Math.max(3 * 3600, metadata.getGcGraceSeconds());
+    }
+
     public static void savePaxosCommit(Commit commit, boolean eraseInProgressProposal)
     {
         String preserveCql = "UPDATE %s USING TIMESTAMP %d AND TTL %d SET most_recent_commit_at = %s, most_recent_commit = 0x%s WHERE row_key = 0x%s AND cf_id = %s";
@@ -787,7 +791,7 @@ public class SystemTable
         processInternal(String.format(eraseInProgressProposal ? eraseCql : preserveCql,
                                       PAXOS_CF,
                                       UUIDGen.microsTimestamp(commit.ballot),
-                                      commit.update.metadata().getGcGraceSeconds(),
+                                      paxosTtl(commit.update.metadata),
                                       commit.ballot,
                                       ByteBufferUtil.bytesToHex(commit.update.toBytes()),
                                       ByteBufferUtil.bytesToHex(commit.key),