esteban commented on a change in pull request #1935:
URL: https://github.com/apache/hbase/pull/1935#discussion_r447305414



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaUtil.java
##########
@@ -264,17 +265,33 @@ private static void deleteQuotas(final Connection 
connection, final byte[] rowKe
       final byte[] qualifier) throws IOException {
     Delete delete = new Delete(rowKey);
     if (qualifier != null) {
-      delete.addColumns(QUOTA_FAMILY_INFO, qualifier);
+      if (Arrays.equals(qualifier,QUOTA_QUALIFIER_POLICY)) {
+        delete.addColumns(QUOTA_FAMILY_USAGE, qualifier);
+      } else
+        delete.addColumns(QUOTA_FAMILY_INFO, qualifier);
     }
-    doDelete(connection, delete);
     if (isNamespaceRowKey(rowKey)) {
-      TableName[] tableArray = 
connection.getAdmin().listTableNamesByNamespace(getNamespaceFromRowKey(rowKey));
-      for (TableName tableName: tableArray) {
-        if (QuotaUtil.getTableQuota(connection, tableName) == null) {
-          deleteTableQuota(connection,tableName);
+      //Check namespace is not deleted before you get info about quota and 
list of tables in namespace
+      NamespaceDescriptor[] descs = 
connection.getAdmin().listNamespaceDescriptors();
+      String ns = getNamespaceFromRowKey(rowKey);
+      int index = 0;
+      while (index < descs.length) {
+        if (ns.equals(descs[index].getName())) {
+          Quotas namespaceQuota = getNamespaceQuota(connection,ns);
+          if (namespaceQuota != null && namespaceQuota.hasSpace()) {
+            TableName[] tableArray = 
connection.getAdmin().listTableNamesByNamespace(ns);
+            for (TableName tableName : tableArray) {
+              deleteQuotas(connection, getTableRowKey(tableName), 
QUOTA_QUALIFIER_POLICY);
+            }
+          }
+          //Exit the while loop by moving to last index
+          index = descs.length;
+        } else {
+          index++;
         }
       }
     }
+    doDelete(connection, delete);

Review comment:
       What would happen if we get an exception trying to delete a quota? Would 
it be necessary to retry the operation again?




----------------------------------------------------------------
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.

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


Reply via email to