joshelser commented on a change in pull request #1935:
URL: https://github.com/apache/hbase/pull/1935#discussion_r455881727
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java
##########
@@ -628,6 +628,34 @@ static Put createPutForNamespaceSnapshotSize(String
namespace, long size) {
}
}
+ /**
+ * Remove table usage snapshots (u:p columns) for the namespace passed
+ * @param connection connection to re-use
+ * @param namespace the namespace to fetch the list of table usage snapshots
+ */
+ static void deleteTableUsageSnapshotsForNamespace(Connection connection,
String namespace)
+ throws IOException {
+ Scan s = new Scan();
+ //Get rows for all tables in namespace
+ s.setRowPrefixFilter(Bytes.toBytes("t." + namespace));
Review comment:
need the namespace delimiter at the end of your prefix filter, otherwise
you'll over-match
e.g. deleting usage for the namespace 'foo' would also end up matching and
deleting for the namespace 'foobar'. Making it 't.foo:' should be good enough.
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaTableUtil.java
##########
@@ -628,6 +628,34 @@ static Put createPutForNamespaceSnapshotSize(String
namespace, long size) {
}
}
+ /**
+ * Remove table usage snapshots (u:p columns) for the namespace passed
+ * @param connection connection to re-use
+ * @param namespace the namespace to fetch the list of table usage snapshots
+ */
+ static void deleteTableUsageSnapshotsForNamespace(Connection connection,
String namespace)
+ throws IOException {
+ Scan s = new Scan();
+ //Get rows for all tables in namespace
+ s.setRowPrefixFilter(Bytes.toBytes("t." + namespace));
Review comment:
Bonus points if you write a test which demonstrates the bug before you
fix it :)
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaUtil.java
##########
@@ -266,6 +266,13 @@ private static void deleteQuotas(final Connection
connection, final byte[] rowKe
if (qualifier != null) {
delete.addColumns(QUOTA_FAMILY_INFO, qualifier);
}
+ if (isNamespaceRowKey(rowKey)) {
+ String ns = getNamespaceFromRowKey(rowKey);
+ Quotas namespaceQuota = getNamespaceQuota(connection,ns);
+ if (namespaceQuota != null && namespaceQuota.hasSpace()) {
+ deleteTableUsageSnapshotsForNamespace(connection, ns);
Review comment:
Please add a comment here as to why we need to delete the table usage
rows (to prevent the next person from having to come back and do the same
investigation we did :)
----------------------------------------------------------------
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]