Skip to content

HBASE-20821 Space Quota: Re-creating a dropped namespace and contained table inherits previously set space quota settings - #571

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

HBASE-20821 Space Quota: Re-creating a dropped namespace and contained table inherits previously set space quota settings#571
shardul-cr7 wants to merge 2 commits into
apache:masterfrom
shardul-cr7:HBASE-20821

Conversation

@shardul-cr7

Copy link
Copy Markdown
Contributor

As demonstarted in HBASE-20662.master.002.patch re-creating a dropped namespace and contained table inherits previously set space quota settings.

Steps:
Create a namespace and a table in it
Set space quota on namespace
Violate namespace quota
Drop table and then namespace
Re create same namespace and same table
Put data into the table (more than the previosuly set namespace quota limit)

Expected: SpaceQuota settings should not exist on the newly re-created table and we should be able to put limit less data into the table

Actual: We fail to put data into newly created table as SpaceQuota settings (systematically created due to previously added namespace space quota) exist on table

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec78Docker mode activated.
_ Prechecks _
+1dupname0No case conflicting files found.
+1hbaseanti0Patch does not have any anti-patterns.
+1@author0The patch does not contain any @author tags.
+1test4tests0The patch appears to include 2 new or modified test files.
_ master Compile Tests _
+1mvninstall323master passed
+1compile54master passed
+1checkstyle84master passed
+1shadedjars276branch has no errors when building our shaded downstream artifacts.
+1javadoc36master passed
0spotbugs251Used deprecated FindBugs config; considering switching to SpotBugs.
+1findbugs249master passed
_ Patch Compile Tests _
+1mvninstall302the patch passed
+1compile55the patch passed
+1javac55the patch passed
+1checkstyle81the patch passed
+1whitespace0The patch has no whitespace issues.
-1shadedjars224patch has 10 errors when building our shaded downstream artifacts.
+1hadoopcheck945Patch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
+1javadoc33the patch passed
+1findbugs253the patch passed
_ Other Tests _
-1unit15574hbase-server in the patch failed.
-1asflicense42The patch generated 1 ASF License warnings.
18997
ReasonTests
Failed junit testshadoop.hbase.master.assignment.TestOpenRegionProcedureHang
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/artifact/out/Dockerfile
GITHUB PR#571
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux d3d45fd244bb 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 GNU/Linux
Build toolmaven
Personality/home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-571/out/precommit/personality/provided.sh
git revisionmaster / b642ee0
Default Java1.8.0_181
shadedjarshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/artifact/out/patch-shadedjars.txt
unithttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/artifact/out/patch-unit-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/testReport/
asflicensehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/artifact/out/patch-asflicense-problems.txt
Max. process+thread count4558 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/console
versionsgit=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered byApache Yetus 0.10.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec145Docker mode activated.
_ Prechecks _
+1dupname0No case conflicting files found.
+1hbaseanti0Patch does not have any anti-patterns.
+1@author0The patch does not contain any @author tags.
+1test4tests0The patch appears to include 2 new or modified test files.
_ master Compile Tests _
+1mvninstall466master passed
+1compile71master passed
+1checkstyle98master passed
+1shadedjars347branch has no errors when building our shaded downstream artifacts.
+1javadoc50master passed
0spotbugs331Used deprecated FindBugs config; considering switching to SpotBugs.
+1findbugs328master passed
_ Patch Compile Tests _
+1mvninstall440the patch passed
+1compile78the patch passed
+1javac78the patch passed
+1checkstyle111the patch passed
+1whitespace0The patch has no whitespace issues.
-1shadedjars292patch has 10 errors when building our shaded downstream artifacts.
+1hadoopcheck1360Patch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
+1javadoc46the patch passed
+1findbugs317the patch passed
_ Other Tests _
-1unit14774hbase-server in the patch failed.
-1asflicense38The patch generated 1 ASF License warnings.
19517
ReasonTests
Failed junit testshadoop.hbase.util.TestFromClientSide3WoUnsafe
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/artifact/out/Dockerfile
GITHUB PR#571
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 357dbabe37fe 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-571/out/precommit/personality/provided.sh
git revisionmaster / 345c21d
Default Java1.8.0_181
shadedjarshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/artifact/out/patch-shadedjars.txt
unithttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/artifact/out/patch-unit-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/testReport/
asflicensehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/artifact/out/patch-asflicense-problems.txt
Max. process+thread count4841 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/console
versionsgit=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered byApache Yetus 0.10.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec51Docker mode activated.
_ Prechecks _
+1dupname1No case conflicting files found.
+1hbaseanti0Patch does not have any anti-patterns.
+1@author0The patch does not contain any @author tags.
+1test4tests0The patch appears to include 2 new or modified test files.
_ master Compile Tests _
+1mvninstall476master passed
+1compile65master passed
+1checkstyle96master passed
+1shadedjars349branch has no errors when building our shaded downstream artifacts.
+1javadoc42master passed
0spotbugs270Used deprecated FindBugs config; considering switching to SpotBugs.
+1findbugs268master passed
_ Patch Compile Tests _
+1mvninstall369the patch passed
+1compile68the patch passed
+1javac68the patch passed
+1checkstyle105the patch passed
+1whitespace0The patch has no whitespace issues.
-1shadedjars286patch has 10 errors when building our shaded downstream artifacts.
+1hadoopcheck1192Patch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
+1javadoc43the patch passed
+1findbugs298the patch passed
_ Other Tests _
+1unit10191hbase-server in the patch passed.
-1asflicense29The patch generated 1 ASF License warnings.
14398
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/3/artifact/out/Dockerfile
GITHUB PR#571
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux d68f8f1b44af 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-571/out/precommit/personality/provided.sh
git revisionmaster / a5ef6b2
Default Java1.8.0_181
shadedjarshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/3/artifact/out/patch-shadedjars.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/3/testReport/
asflicensehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/3/artifact/out/patch-asflicense-problems.txt
Max. process+thread count4517 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/3/console
versionsgit=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered byApache Yetus 0.10.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
0reexec75Docker mode activated.
_ Prechecks _
+1dupname0No case conflicting files found.
+1hbaseanti0Patch does not have any anti-patterns.
+1@author0The patch does not contain any @author tags.
+1test4tests0The patch appears to include 2 new or modified test files.
_ master Compile Tests _
+1mvninstall349master passed
+1compile62master passed
+1checkstyle84master passed
+1shadedjars347branch has no errors when building our shaded downstream artifacts.
+1javadoc41master passed
0spotbugs271Used deprecated FindBugs config; considering switching to SpotBugs.
+1findbugs269master passed
_ Patch Compile Tests _
+1mvninstall333the patch passed
+1compile63the patch passed
+1javac63the patch passed
+1checkstyle92the patch passed
+1whitespace0The patch has no whitespace issues.
-1shadedjars242patch has 10 errors when building our shaded downstream artifacts.
+1hadoopcheck1080Patch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
+1javadoc40the patch passed
+1findbugs284the patch passed
_ Other Tests _
-1unit16791hbase-server in the patch failed.
-1asflicense36The patch generated 1 ASF License warnings.
20605
ReasonTests
Failed junit testshadoop.hbase.master.TestSplitWALManager
hadoop.hbase.regionserver.TestHRegionWithInMemoryFlush
hadoop.hbase.client.TestFromClientSideWithCoprocessor
SubsystemReport/Notes
DockerClient=19.03.1 Server=19.03.1 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/artifact/out/Dockerfile
GITHUB PR#571
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
unameLinux 430d1d2335f6 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-571/out/precommit/personality/provided.sh
git revisionmaster / 8e8bd8b
Default Java1.8.0_181
shadedjarshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/artifact/out/patch-shadedjars.txt
unithttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/artifact/out/patch-unit-hbase-server.txt
Test Resultshttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/testReport/
asflicensehttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/artifact/out/patch-asflicense-problems.txt
Max. process+thread count4970 (vs. ulimit of 10000)
modulesC: hbase-server U: hbase-server
Console outputhttps://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/console
versionsgit=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered byApache Yetus 0.10.0 http://yetus.apache.org

This message was automatically generated.

}
}
} else if (quotasAtNamespace != null) {
// If quota present at namespace level remove the table entry from 'hbase:quota'

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.

Why is this in postDeleteTable? The quota should be dropped if the namespace is dropped, which should happen in postDeleteNamespace, right?

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.

Because even though table is dropped it's entry is still present in the 'hbase:quota' table because of the namespace quota. If we create another table with same name inside that namespace it inherits the earlier quota settings. So during dropping the table we need to remove that entry/setting from the hbase:quota for our table even though quota was present at namespace level.

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.

Because even though table is dropped it's entry is still present in the 'hbase:quota' table because of the namespace quota. If we create another table with same name inside that namespace it inherits the earlier quota settings.

That's by design, not a bug. If you set a quota on a namespace (as opposed to a quota on the table), you would automatically get that quota for all tables in that namespace.

This allows an organization to be given free-rule over some namespace while still enforcing an upper-bound on the allowed resources in HBase. e.g. a namespace space quota of 200G would allow 200G of data in any number of tables in that namespace, not mattering which table uses that quota.

Now, if you drop a namespace and the quota still remains, that's a bug, but I don't think that's what you're trying to solve.

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.

Hi Josh, thanks for the review , I have one doubt.

  1. create namespace with quota.
  2. create table.
  3. violate quota on the namespace by puting data into the table.
  4. delete the table.
  5. create another table with same name inside namespace.
  6. Currently , table will be in violation even though it doesn't have any data in it since it's entry was not deleted from 'hbase:quota'.

Is this the intended behaviour?

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.

Currently , table will be in violation even though it doesn't have any data in it since it's entry was not deleted from 'hbase:quota'.

So let's say you have t1 and t1' which are the two instances of the tables as you describe.

If I had to guess, when you create t1', the system would still see the t1's region size reports for a period of time (until t1' reports its for the first time).

If this is indeed what's happening, the fix would be to purge the region size reports for a table when it's deleted, not try to alter the state of hbase:quota. Region size reports are held in memory inside of the active HBase Master inside of the class MasterQuotaManager. There is no quota defined at the table level, so, again, I'm not sure what you expect this change to be doing directly. If your test works, I can only imagine that it's by circumstance.

* @return list of tables present inside the namespace otherwise returns null.
* @throws IOException throws IOException
*/
public static TableName[] listTableNamesByNamepsace(final Connection connection, String namespace)

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.

Seems unnecessary to break this out into its own method if the only consumer is deleteNamespaceQuota.

try (QuotaRetriever scanner = QuotaRetriever
.open(conn.getConfiguration(), new QuotaFilter().setTableFilter(tn.getNameAsString()))) {
for (QuotaSettings setting : scanner) {
if (setting.getTableName().equals(tn) && setting.getQuotaType() == QuotaType.SPACE) {

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.

Checking the table name is unnecessary if you set the table filter above.

throws IOException {
// Before removing namespace quota , remove quota from the tables inside the namespace
// which does not have explicit space quotas defined on them.
TableName[] tableNames = QuotaUtil.listTableNamesByNamepsace(connection, namespace);

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.

This case should never happen. You can't delete a namespace which has tables in it. If we're cleaning up a namespace, we shouldn't have any table-level quotas hanging around.

Please log a WARN stating that we found a quota entry that shouldn't exist and that we're going to remove it.

/**
* Sets the given quota (policy & limit) on the passed namespace.
*/
void setQuotaLimitNamespace(final String namespace, SpaceViolationPolicy policy, long sizeInMBs)

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 please fix setQuotaLimit() and removeQuotaFromtable to be consistent with these new methods?

e.g. setQuotaLimitTable() and removeQuotaFromTable()

helper.setQuotaLimitNamespace(nd.getName(), SpaceViolationPolicy.NO_WRITES, 2L);

// Sufficient time for all the chores to run
Thread.sleep(5000);

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 change this to explicitly poll the state that you expect to see. There are lots of other quota test examples which show how to wait on the state to change (e.g. fgrep -R waitFor hbase-server/src/test/java/org/apache/hadoop/hbase/quotas).

QuotaTableUtil.getSnapshots(TEST_UTIL.getConnection());

// Table before drop should have entry in 'hbase:quota'
Assert.assertTrue(snapshotMap.containsKey(table));

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 validate that the SpaceQuotaSnapshot is sane (e.g. is a space quota, is the limit you set)

import org.slf4j.LoggerFactory;

@Category(MediumTests.class)
public class TestSpaceQuotasAtNamespaceLevel {

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.

I don't feel like this is testing the bug you originally described.

I would expect to see a test:

  • Create a namespace
  • Set a space quota
  • Validate that the space quota is set
  • any extra validation that space quota is taking effect
  • Drop the namespace
  • Create namespace with same name
  • Validate that space quota does not exist for the namespace

@shardul-cr7shardul-cr7 changed the title HBASE-20821 Re-creating a dropped namespace and contained table inherits previously set space quota settingsHBASE-20821 Space Quota: Re-creating a dropped namespace and contained table inherits previously set space quota settingsSep 11, 2019
@saintstack

Copy link
Copy Markdown
Contributor

What is needed to move this patch forward? Thanks.

@joshelser

Copy link
Copy Markdown
Member

What is needed to move this patch forward?

I think Shardul is going to work on my feedback in #571 (comment)

@saintstack

Copy link
Copy Markdown
Contributor

@shardul-cr7 Any luck sir w/ progress? Thanks.

@saintstack

Copy link
Copy Markdown
Contributor

Closing. No progress. Make a new PR if I have this wrong. Thanks.

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.

4 participants

@shardul-cr7@Apache-HBase@saintstack@joshelser