cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1087402 - in /cassandra/branches/cassandra-0.7: src/java/org/apache/cassandra/db/migration/DropColumnFamily.java src/java/org/apache/cassandra/db/migration/DropKeyspace.java test/unit/org/apache/cassandra/db/DefsTest.java
Date Thu, 31 Mar 2011 18:34:57 GMT
Author: jbellis
Date: Thu Mar 31 18:34:56 2011
New Revision: 1087402

URL: http://svn.apache.org/viewvc?rev=1087402&view=rev
Log:
snapshot must be performed before flushlock must be acquired, or we deadlock.  See #2381
patch by jbellis

Modified:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropKeyspace.java
    cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java?rev=1087402&r1=1087401&r2=1087402&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java
Thu Mar 31 18:34:56 2011
@@ -80,11 +80,12 @@ public class DropColumnFamily extends Mi
 
         if (!clientMode)
         {
+            cfs.snapshot(Table.getTimestampedSnapshotName(null));
+
             CompactionManager.instance.getCompactionLock().lock();
             cfs.flushLock.lock();
             try
             {
-                cfs.snapshot(Table.getTimestampedSnapshotName(null));
                 Table.open(ksm.name).dropCf(cfm.cfId);
             }
             finally

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropKeyspace.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropKeyspace.java?rev=1087402&r1=1087401&r2=1087402&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropKeyspace.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/DropKeyspace.java
Thu Mar 31 18:34:56 2011
@@ -63,10 +63,10 @@ public class DropKeyspace extends Migrat
                 CFMetaData.purge(cfm);
                 if (!clientMode)
                 {
+                    cfs.snapshot(snapshotName);
                     cfs.flushLock.lock();
                     try
                     {
-                        cfs.snapshot(snapshotName);
                         Table.open(ksm.name).dropCf(cfm.cfId);
                     }
                     finally

Modified: cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java?rev=1087402&r1=1087401&r2=1087402&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java (original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/db/DefsTest.java Thu Mar
31 18:34:56 2011
@@ -411,7 +411,7 @@ public class DefsTest extends CleanupHel
         assert ks != null;
         final CFMetaData cfm = ks.cfMetaData().get("Standard2");
         assert cfm != null;
-        
+
         // write some data, force a flush, then verify that files exist on disk.
         RowMutation rm = new RowMutation(ks.name, dk.key);
         for (int i = 0; i < 100; i++)
@@ -451,7 +451,28 @@ public class DefsTest extends CleanupHel
             assert th instanceof NullPointerException;
         }
     }
-    
+
+    @Test
+    public void dropKSUnflushed() throws ConfigurationException, IOException, ExecutionException,
InterruptedException
+    {
+        DecoratedKey dk = Util.dk("dropKs");
+        // sanity
+        final KSMetaData ks = DatabaseDescriptor.getTableDefinition("Keyspace3");
+        assert ks != null;
+        final CFMetaData cfm = ks.cfMetaData().get("Standard1");
+        assert cfm != null;
+
+        // write some data
+        RowMutation rm = new RowMutation(ks.name, dk.key);
+        for (int i = 0; i < 100; i++)
+            rm.add(new QueryPath(cfm.cfName, null, ByteBufferUtil.bytes(("col" + i))), ByteBufferUtil.bytes("anyvalue"),
1L);
+        rm.apply();
+
+        new DropKeyspace(ks.name).apply();
+
+        assert DatabaseDescriptor.getTableDefinition(ks.name) == null;
+    }
+
     @Test
     public void renameKs() throws ConfigurationException, IOException, ExecutionException,
InterruptedException
     {



Mime
View raw message