cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [4/5] git commit: fix re-created keyspace disappering after 1.1.5 upgrade patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-4698
Date Thu, 27 Sep 2012 14:30:43 GMT
fix re-created keyspace disappering after 1.1.5 upgrade
patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-4698


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

Branch: refs/heads/trunk
Commit: 988ea81d409968614d84dacb3a022dcb156172c3
Parents: e752de9
Author: Pavel Yaskevich <xedin@apache.org>
Authored: Thu Sep 27 17:16:55 2012 +0300
Committer: Pavel Yaskevich <xedin@apache.org>
Committed: Thu Sep 27 17:16:55 2012 +0300

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../org/apache/cassandra/db/ColumnSerializer.java  |    5 --
 src/java/org/apache/cassandra/db/RowMutation.java  |   46 +++++++++++++++
 .../apache/cassandra/service/MigrationManager.java |    2 +-
 4 files changed, 48 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/988ea81d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 96e266a..eeb59e1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,7 @@
  * Automatic fixing of overlapping leveled sstables (CASSANDRA-4644)
  * fix error when using ORDER BY with extended selections (CASSANDRA-4689)
  * (CQL3) Fix validation for IN queries for non-PK cols (CASSANDRA-4709)
+ * fix re-created keyspace disappering after 1.1.5 upgrade (CASSANDRA-4698)
 Merged from 1.0:
  * Switch from NBHM to CHM in MessagingService's callback map, which
    prevents OOM in long-running instances (CASSANDRA-4708)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/988ea81d/src/java/org/apache/cassandra/db/ColumnSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnSerializer.java b/src/java/org/apache/cassandra/db/ColumnSerializer.java
index d5011aa..b6c71bb 100644
--- a/src/java/org/apache/cassandra/db/ColumnSerializer.java
+++ b/src/java/org/apache/cassandra/db/ColumnSerializer.java
@@ -117,11 +117,6 @@ public class ColumnSerializer implements IColumnSerializer
         else
         {
             long ts = dis.readLong();
-            long now = FBUtilities.timestampMicros();
-
-            if (ts > now) // fixing the timestamp from the future to be 'now' in micros
-                ts = now; // helps with CASSANDRA-4561 as remote nodes can send schema with
wrong nanoTime() timestamps
-
             ByteBuffer value = ByteBufferUtil.readWithLength(dis);
             return (b & COUNTER_UPDATE_MASK) != 0
                    ? new CounterUpdateColumn(name, value, ts)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/988ea81d/src/java/org/apache/cassandra/db/RowMutation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RowMutation.java b/src/java/org/apache/cassandra/db/RowMutation.java
index a48e027..51dac68 100644
--- a/src/java/org/apache/cassandra/db/RowMutation.java
+++ b/src/java/org/apache/cassandra/db/RowMutation.java
@@ -442,6 +442,52 @@ public class RowMutation implements IMutation, MessageProducer
             return new RowMutation(table, key, modifications);
         }
 
+        /**
+         * Used only by o.a.c.service.MigrationManager to fix possibly broken System.nanoTime()
timestamps
+         * of the schema migrations from remote nodes
+         *
+         * @param dis The source of the data
+         * @param version The version of remote node
+         *
+         * @return row mutation with fixed internal timestamps
+         *
+         * @throws IOException If data could not be read
+         */
+        public RowMutation deserializeFixingTimestamps(DataInput dis, int version) throws
IOException
+        {
+            RowMutation mutation = deserialize(dis, version);
+
+            long now = FBUtilities.timestampMicros();
+            Map<Integer, ColumnFamily> fixedModifications = new HashMap<Integer,
ColumnFamily>();
+
+            for (Map.Entry<Integer, ColumnFamily> modification : mutation.modifications_.entrySet())
+            {
+                ColumnFamily cf = ColumnFamily.create(modification.getValue().metadata());
+
+                if (cf.isMarkedForDelete())
+                    cf.delete(cf.getLocalDeletionTime(), cf.getMarkedForDeleteAt() > now
? now : cf.getMarkedForDeleteAt());
+
+                for (IColumn column : modification.getValue().columns)
+                {
+                    // don't clone if column already has a correct timestamp
+                    if (column.timestamp() <= now)
+                    {
+                        cf.addColumn(column);
+                        continue;
+                    }
+
+                    if (column.isMarkedForDelete())
+                        cf.addColumn(new DeletedColumn(column.name(), column.value(), now));
+                    else
+                        cf.addColumn(new Column(column.name(), column.value(), now));
+                }
+
+                fixedModifications.put(modification.getKey(), cf);
+            }
+
+            return new RowMutation(mutation.getTable(), mutation.key(), fixedModifications);
+        }
+
         public RowMutation deserialize(DataInput dis, int version) throws IOException
         {
             return deserialize(dis, version, IColumnSerializer.Flag.FROM_REMOTE);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/988ea81d/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 1d4401a..446bb5c 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -304,7 +304,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
         int count = in.readInt();
 
         for (int i = 0; i < count; i++)
-            schema.add(RowMutation.serializer().deserialize(in, version));
+            schema.add(RowMutation.serializer().deserializeFixingTimestamps(in, version));
 
         return schema;
     }


Mime
View raw message