- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.4k
HBASE-22142 Space quota: If table inside namespace having space quota is dropped, data size usage is still considered for the drop table. #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9ef5c3f    to
    6208055      
    Compare
  
    | 🎊 +1 overall 
 
 This message was automatically generated. | 
| Hi @joshelser , can you review this one ?.. I was planning to work on HBASE-20821 after this one gets merged. Thanks again. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice little fix. A few requests on changes, but good work overall!
| * @param tableName tableName. | ||
| */ | ||
| public void removeTableRegions(TableName tableName) { | ||
| regionSizes.entrySet().removeIf(regionInfo -> regionInfo.getKey().getTable().equals(tableName)); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: entry instead of regionInfo, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looks like you could also do regionSizes.keySet().removeIf(regionInfo -> regionInfo.getTable().equals(tableName)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
| } | ||
|  | ||
| /** | ||
| * Remove regionInfo entry for the table which is going to get dropped. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to: "Removes each region size entry where the RegionInfo references the provided TableName". A little more clear about what this method does (instead of the context in which you are calling it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| * | ||
| * @param tableName tableName. | ||
| */ | ||
| public void removeTableRegions(TableName tableName) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: removeRegionSizesForTable instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| final Connection conn = ctx.getEnvironment().getConnection(); | ||
| Quotas quotas = QuotaUtil.getTableQuota(conn, tableName); | ||
| Quotas quotasAtNamespace = QuotaUtil.getNamespaceQuota(conn, tableName.getNamespaceAsString()); | ||
| if (quotas != null){ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could consolidate these two branches, right?
Make this if (quotas != null || quotasAtNamespace != null) and then only call removeTableSpaceLimit when it is quotas != null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
| final Connection conn = ctx.getEnvironment().getConnection(); | ||
| Quotas quotas = QuotaUtil.getTableQuota(conn, tableName); | ||
| Quotas quotasAtNamespace = QuotaUtil.getNamespaceQuota(conn, tableName.getNamespaceAsString()); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename these to be tableQuotas and namespaceQuotas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
| }); | ||
|  | ||
| boolean beforeDrop = false; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about hasRegionSize instead of beforeDrop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
| } | ||
|  | ||
| Assert.assertTrue(beforeDrop); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a description to this assertion so that we can get a better human-readable cause of the test failure :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| // check if deleted table region report still present in the map. | ||
| for (Map.Entry<RegionInfo, Long> entry : quotaManager.snapshotRegionSizes().entrySet()) { | ||
| if (entry.getKey().getTable().equals(tn)) { | ||
| Assert.fail("Not deleted during the drop command"); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "Dropped table's RegionSizes were not .."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
|  | ||
| @Test | ||
| public void testSetQuotaAndThenDropTableWithRegionReport() throws Exception { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job at capturing this in a concise test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @joshelser . Did all the changes and pushed. :)
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| Cool. Looks fine to me. Will try to get this merged in. | 
steps to follow:
create a quota at namespace level
create 2 tables t1 and t2 inside namespace and write data.
write 5 mb of data each in both t1 and t2.
data usage will be shown 10 mb for both table, since quota is set at namespace level.
drop t1.
data usage for t2 will be shown 10 mb for 10 minutes. And will come back to 5 mb after 10 minutes.
If table is dropped inside namespace, data size usage is still shown for 10 minutes because of the configuration "hbase.master.quotas.region.report.retention.millis". This conf maintains the region report in cache(regionSizes) and old entry is used for 10 minutes. We can remove the entry from cache during the drop command as part of MasterCP hook only, so that correct usage is show instantaneously after the drop command.