beobal commented on code in PR #3574:
URL: https://github.com/apache/cassandra/pull/3574#discussion_r1778866910


##########
src/java/org/apache/cassandra/tools/NodeTool.java:
##########
@@ -262,7 +262,8 @@ public int execute(String... args)
                .withCommand(CMSAdmin.InitializeCMS.class)
                .withCommand(CMSAdmin.ReconfigureCMS.class)
                .withCommand(CMSAdmin.Snapshot.class)
-               .withCommand(CMSAdmin.Unregister.class);
+               .withCommand(CMSAdmin.Unregister.class)
+               .withCommand(CMSAdmin.ResumeDropAccordTable.class);

Review Comment:
   kk



##########
src/java/org/apache/cassandra/cql3/statements/schema/DropKeyspaceStatement.java:
##########
@@ -45,8 +50,30 @@ public Keyspaces apply(ClusterMetadata metadata)
         Guardrails.dropKeyspaceEnabled.ensureEnabled(state);
 
         Keyspaces schema = metadata.schema.getKeyspaces();
-        if (schema.containsKeyspace(keyspaceName))
+        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
+        if (keyspace != null)
+        {
+            // check that no accord tables in the keyspace are currently in 
the process of being dropped
+            List<TableMetadata> pendingDrop = keyspace.tables.stream()
+                                                             .filter(t -> 
t.params.pendingDrop)
+                                                             
.collect(Collectors.toList());
+            if (!pendingDrop.isEmpty())
+                throw ire("Cannot drop keyspace '%s' as it contains accord 
tables which are currently being dropped. " +
+                          "Please wait for those operations to complete before 
dropping the keyspace. (%s)",
+                          keyspaceName, pendingDrop.stream()
+                                                   .map(Object::toString)
+                                                   
.collect(Collectors.joining(",")));
+
+            List<TableMetadata> accordTables = keyspace.tables.stream()
+                                               
.filter(TableMetadata::isAccordEnabled)
+                                               .collect(Collectors.toList());
+            if (!accordTables.isEmpty())

Review Comment:
   ok



##########
src/java/org/apache/cassandra/tcm/transformations/PrepareDropAccordTable.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.tcm.transformations;
+
+import java.io.IOException;
+import java.util.Objects;
+
+import org.apache.cassandra.exceptions.ExceptionCode;
+import org.apache.cassandra.io.util.DataInputPlus;
+import org.apache.cassandra.io.util.DataOutputPlus;
+import org.apache.cassandra.schema.DistributedSchema;
+import org.apache.cassandra.schema.KeyspaceMetadata;
+import org.apache.cassandra.schema.TableMetadata;
+import org.apache.cassandra.tcm.ClusterMetadata;
+import org.apache.cassandra.tcm.Transformation;
+import org.apache.cassandra.tcm.sequences.DropAccordTable;
+import org.apache.cassandra.tcm.sequences.DropAccordTable.TableReference;
+import org.apache.cassandra.tcm.sequences.LockedRanges;
+import org.apache.cassandra.tcm.serialization.AsymmetricMetadataSerializer;
+import org.apache.cassandra.tcm.serialization.Version;
+
+public class PrepareDropAccordTable implements Transformation
+{
+    public static final Serializer serializer = new Serializer();
+
+    public final TableReference tableRef;
+
+    public PrepareDropAccordTable(TableReference tableRef)
+    {
+        this.tableRef = tableRef;
+    }
+
+    @Override
+    public Kind kind()
+    {
+        return Kind.PREPARE_DROP_ACCORD_TABLE;
+    }
+
+    @Override
+    public Result execute(ClusterMetadata prev)
+    {
+        KeyspaceMetadata ks = 
prev.schema.getKeyspaces().getNullable(tableRef.keyspace);
+        if (ks == null)
+            return new Rejected(ExceptionCode.INVALID, "Unknown keyspace " + 
tableRef.keyspace);
+        TableMetadata metadata = ks.tables.getNullable(tableRef.id);
+        if (metadata == null)
+            return new Rejected(ExceptionCode.INVALID, "Table " + tableRef + " 
is not known");

Review Comment:
   Ok, but the caller already knows which `ks.table` they were trying to drop, 
regardless of how exactly they are submitting the request 
(programmatically/interactively etc).  
   
   Still, I see _some_ value in that, but if we're keeping these fields I think 
we should get rid of `normalize` as that seems like it should be unnecessary.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to