Skip to content

HBASE-22142 Space quota: If table inside namespace having space quota is dropped, data size usage is still considered for the drop table. - #598

Closed
shardul-cr7 wants to merge 2 commits into
apache:masterfrom
shardul-cr7:HBASE-22142
Closed

Conversation

@shardul-cr7

@shardul-cr7shardul-cr7 commented Sep 9, 2019

Copy link
Copy Markdown
Contributor

steps to follow:

  1. create a quota at namespace level

  2. create 2 tables t1 and t2 inside namespace and write data.

  3. write 5 mb of data each in both t1 and t2.

  4. data usage will be shown 10 mb for both table, since quota is set at namespace level.

  5. drop t1.

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

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
💙reexec0m 39sDocker mode activated.
_ Prechecks _
💚dupname0m 0sNo case conflicting files found.
💚hbaseanti0m 0sPatch does not have any anti-patterns.
💚@author0m 0sThe patch does not contain any @author tags.
💚test4tests0m 0sThe patch appears to include 1 new or modified test files.
_ master Compile Tests _
💚mvninstall7m 19smaster passed
💚compile1m 11smaster passed
💚checkstyle1m 45smaster passed
💚shadedjars5m 46sbranch has no errors when building our shaded downstream artifacts.
💚javadoc0m 44smaster passed
💙spotbugs5m 31sUsed deprecated FindBugs config; considering switching to SpotBugs.
💚findbugs5m 28smaster passed
_ Patch Compile Tests _
💚mvninstall6m 23sthe patch passed
💚compile1m 7sthe patch passed
💚javac1m 7sthe patch passed
💚checkstyle1m 41sthe patch passed
💚whitespace0m 0sThe patch has no whitespace issues.
💚shadedjars5m 4spatch has no errors when building our shaded downstream artifacts.
💚hadoopcheck20m 19sPatch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
💚javadoc0m 40sthe patch passed
💚findbugs5m 17sthe patch passed
_ Other Tests _
💚unit167m 58shbase-server in the patch passed.
💚asflicense0m 28sThe patch does not generate ASF License warnings.
239m 13s
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-598/1/artifact/out/Dockerfile
GITHUB PR#598
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 4d0f83effd0d 4.15.0-60-generic #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-598/out/precommit/personality/provided.sh
git revisionmaster / ac8fe16
Default Java1.8.0_181
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-598/1/testReport/
Max. process+thread count4753 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-598/1/console
versionsgit=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered byApache Yetus 0.11.0 https://yetus.apache.org

This message was automatically generated.

@shardul-cr7

Copy link
Copy Markdown
ContributorAuthor

Hi @joshelser , can you review this one ?.. I was planning to work on HBASE-20821 after this one gets merged. Thanks again.

@joshelserjoshelser left a comment

Copy link
Copy Markdown
Member

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));

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
ContributorAuthor

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.

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
ContributorAuthor

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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: removeRegionSizesForTable instead?

Copy link
Copy Markdown
ContributorAuthor

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){

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
ContributorAuthor

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());

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
});

boolean beforeDrop = false;

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}

Assert.assertTrue(beforeDrop);

Copy link
Copy Markdown
Member

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 :)

Copy link
Copy Markdown
ContributorAuthor

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");

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
ContributorAuthor

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 {

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
ContributorAuthor

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

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
💙reexec0m 58sDocker mode activated.
_ Prechecks _
💚dupname0m 0sNo case conflicting files found.
💚hbaseanti0m 0sPatch does not have any anti-patterns.
💚@author0m 0sThe patch does not contain any @author tags.
💚test4tests0m 0sThe patch appears to include 1 new or modified test files.
_ master Compile Tests _
💚mvninstall7m 2smaster passed
💚compile1m 8smaster passed
💚checkstyle1m 40smaster passed
💚shadedjars5m 47sbranch has no errors when building our shaded downstream artifacts.
💚javadoc0m 41smaster passed
💙spotbugs5m 2sUsed deprecated FindBugs config; considering switching to SpotBugs.
💚findbugs5m 0smaster passed
_ Patch Compile Tests _
💚mvninstall6m 39sthe patch passed
💚compile1m 9sthe patch passed
💚javac1m 9sthe patch passed
💚checkstyle1m 45sthe patch passed
💚whitespace0m 0sThe patch has no whitespace issues.
💚shadedjars5m 42spatch has no errors when building our shaded downstream artifacts.
💚hadoopcheck19m 21sPatch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
💚javadoc0m 39sthe patch passed
💚findbugs5m 32sthe patch passed
_ Other Tests _
💚unit163m 35shbase-server in the patch passed.
💚asflicense0m 33sThe patch does not generate ASF License warnings.
235m 14s
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-598/2/artifact/out/Dockerfile
GITHUB PR#598
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux d00e8bba00b8 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-598/out/precommit/personality/provided.sh
git revisionmaster / a0e8723
Default Java1.8.0_181
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-598/2/testReport/
Max. process+thread count4834 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-598/2/console
versionsgit=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered byApache Yetus 0.11.0 https://yetus.apache.org

This message was automatically generated.

@joshelser

Copy link
Copy Markdown
Member

Cool. Looks fine to me. Will try to get this merged in.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@shardul-cr7@Apache-HBase@joshelser