Skip to content

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

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

Closed
wants to merge 2 commits into from

Conversation

shardul-cr7
Copy link
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

💔 -1 overall

Vote Subsystem Runtime Comment
0 reexec 78 Docker mode activated.
_ Prechecks _
+1 dupname 0 No case conflicting files found.
+1 hbaseanti 0 Patch does not have any anti-patterns.
+1 @author 0 The patch does not contain any @author tags.
+1 test4tests 0 The patch appears to include 2 new or modified test files.
_ master Compile Tests _
+1 mvninstall 323 master passed
+1 compile 54 master passed
+1 checkstyle 84 master passed
+1 shadedjars 276 branch has no errors when building our shaded downstream artifacts.
+1 javadoc 36 master passed
0 spotbugs 251 Used deprecated FindBugs config; considering switching to SpotBugs.
+1 findbugs 249 master passed
_ Patch Compile Tests _
+1 mvninstall 302 the patch passed
+1 compile 55 the patch passed
+1 javac 55 the patch passed
+1 checkstyle 81 the patch passed
+1 whitespace 0 The patch has no whitespace issues.
-1 shadedjars 224 patch has 10 errors when building our shaded downstream artifacts.
+1 hadoopcheck 945 Patch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
+1 javadoc 33 the patch passed
+1 findbugs 253 the patch passed
_ Other Tests _
-1 unit 15574 hbase-server in the patch failed.
-1 asflicense 42 The patch generated 1 ASF License warnings.
18997
Reason Tests
Failed junit tests hadoop.hbase.master.assignment.TestOpenRegionProcedureHang
Subsystem Report/Notes
Docker Client=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 Tests dupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
uname Linux d3d45fd244bb 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 GNU/Linux
Build tool maven
Personality /home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-571/out/precommit/personality/provided.sh
git revision master / b642ee0
Default Java 1.8.0_181
shadedjars https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/artifact/out/patch-shadedjars.txt
unit https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/artifact/out/patch-unit-hbase-server.txt
Test Results https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/testReport/
asflicense https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/artifact/out/patch-asflicense-problems.txt
Max. process+thread count 4558 (vs. ulimit of 10000)
modules C: hbase-server U: hbase-server
Console output https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/1/console
versions git=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered by Apache Yetus 0.10.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

💔 -1 overall

Vote Subsystem Runtime Comment
0 reexec 145 Docker mode activated.
_ Prechecks _
+1 dupname 0 No case conflicting files found.
+1 hbaseanti 0 Patch does not have any anti-patterns.
+1 @author 0 The patch does not contain any @author tags.
+1 test4tests 0 The patch appears to include 2 new or modified test files.
_ master Compile Tests _
+1 mvninstall 466 master passed
+1 compile 71 master passed
+1 checkstyle 98 master passed
+1 shadedjars 347 branch has no errors when building our shaded downstream artifacts.
+1 javadoc 50 master passed
0 spotbugs 331 Used deprecated FindBugs config; considering switching to SpotBugs.
+1 findbugs 328 master passed
_ Patch Compile Tests _
+1 mvninstall 440 the patch passed
+1 compile 78 the patch passed
+1 javac 78 the patch passed
+1 checkstyle 111 the patch passed
+1 whitespace 0 The patch has no whitespace issues.
-1 shadedjars 292 patch has 10 errors when building our shaded downstream artifacts.
+1 hadoopcheck 1360 Patch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
+1 javadoc 46 the patch passed
+1 findbugs 317 the patch passed
_ Other Tests _
-1 unit 14774 hbase-server in the patch failed.
-1 asflicense 38 The patch generated 1 ASF License warnings.
19517
Reason Tests
Failed junit tests hadoop.hbase.util.TestFromClientSide3WoUnsafe
Subsystem Report/Notes
Docker Client=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 Tests dupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
uname Linux 357dbabe37fe 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 GNU/Linux
Build tool maven
Personality /home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-571/out/precommit/personality/provided.sh
git revision master / 345c21d
Default Java 1.8.0_181
shadedjars https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/artifact/out/patch-shadedjars.txt
unit https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/artifact/out/patch-unit-hbase-server.txt
Test Results https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/testReport/
asflicense https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/artifact/out/patch-asflicense-problems.txt
Max. process+thread count 4841 (vs. ulimit of 10000)
modules C: hbase-server U: hbase-server
Console output https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/2/console
versions git=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered by Apache Yetus 0.10.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

💔 -1 overall

Vote Subsystem Runtime Comment
0 reexec 51 Docker mode activated.
_ Prechecks _
+1 dupname 1 No case conflicting files found.
+1 hbaseanti 0 Patch does not have any anti-patterns.
+1 @author 0 The patch does not contain any @author tags.
+1 test4tests 0 The patch appears to include 2 new or modified test files.
_ master Compile Tests _
+1 mvninstall 476 master passed
+1 compile 65 master passed
+1 checkstyle 96 master passed
+1 shadedjars 349 branch has no errors when building our shaded downstream artifacts.
+1 javadoc 42 master passed
0 spotbugs 270 Used deprecated FindBugs config; considering switching to SpotBugs.
+1 findbugs 268 master passed
_ Patch Compile Tests _
+1 mvninstall 369 the patch passed
+1 compile 68 the patch passed
+1 javac 68 the patch passed
+1 checkstyle 105 the patch passed
+1 whitespace 0 The patch has no whitespace issues.
-1 shadedjars 286 patch has 10 errors when building our shaded downstream artifacts.
+1 hadoopcheck 1192 Patch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
+1 javadoc 43 the patch passed
+1 findbugs 298 the patch passed
_ Other Tests _
+1 unit 10191 hbase-server in the patch passed.
-1 asflicense 29 The patch generated 1 ASF License warnings.
14398
Subsystem Report/Notes
Docker Client=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 Tests dupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
uname Linux d68f8f1b44af 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 GNU/Linux
Build tool maven
Personality /home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-571/out/precommit/personality/provided.sh
git revision master / a5ef6b2
Default Java 1.8.0_181
shadedjars https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/3/artifact/out/patch-shadedjars.txt
Test Results https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/3/testReport/
asflicense https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/3/artifact/out/patch-asflicense-problems.txt
Max. process+thread count 4517 (vs. ulimit of 10000)
modules C: hbase-server U: hbase-server
Console output https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/3/console
versions git=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered by Apache Yetus 0.10.0 http://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

💔 -1 overall

Vote Subsystem Runtime Comment
0 reexec 75 Docker mode activated.
_ Prechecks _
+1 dupname 0 No case conflicting files found.
+1 hbaseanti 0 Patch does not have any anti-patterns.
+1 @author 0 The patch does not contain any @author tags.
+1 test4tests 0 The patch appears to include 2 new or modified test files.
_ master Compile Tests _
+1 mvninstall 349 master passed
+1 compile 62 master passed
+1 checkstyle 84 master passed
+1 shadedjars 347 branch has no errors when building our shaded downstream artifacts.
+1 javadoc 41 master passed
0 spotbugs 271 Used deprecated FindBugs config; considering switching to SpotBugs.
+1 findbugs 269 master passed
_ Patch Compile Tests _
+1 mvninstall 333 the patch passed
+1 compile 63 the patch passed
+1 javac 63 the patch passed
+1 checkstyle 92 the patch passed
+1 whitespace 0 The patch has no whitespace issues.
-1 shadedjars 242 patch has 10 errors when building our shaded downstream artifacts.
+1 hadoopcheck 1080 Patch does not cause any errors with Hadoop 2.8.5 2.9.2 or 3.1.2.
+1 javadoc 40 the patch passed
+1 findbugs 284 the patch passed
_ Other Tests _
-1 unit 16791 hbase-server in the patch failed.
-1 asflicense 36 The patch generated 1 ASF License warnings.
20605
Reason Tests
Failed junit tests hadoop.hbase.master.TestSplitWALManager
hadoop.hbase.regionserver.TestHRegionWithInMemoryFlush
hadoop.hbase.client.TestFromClientSideWithCoprocessor
Subsystem Report/Notes
Docker Client=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 Tests dupname asflicense javac javadoc unit spotbugs findbugs shadedjars hadoopcheck hbaseanti checkstyle compile
uname Linux 430d1d2335f6 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 GNU/Linux
Build tool maven
Personality /home/jenkins/jenkins-slave/workspace/HBase-PreCommit-GitHub-PR_PR-571/out/precommit/personality/provided.sh
git revision master / 8e8bd8b
Default Java 1.8.0_181
shadedjars https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/artifact/out/patch-shadedjars.txt
unit https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/artifact/out/patch-unit-hbase-server.txt
Test Results https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/testReport/
asflicense https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/artifact/out/patch-asflicense-problems.txt
Max. process+thread count 4970 (vs. ulimit of 10000)
modules C: hbase-server U: hbase-server
Console output https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-571/4/console
versions git=2.11.0 maven=2018-06-17T18:33:14Z) findbugs=3.1.11
Powered by Apache Yetus 0.10.0 http://yetus.apache.org

This message was automatically generated.

@@ -78,6 +79,20 @@ public void postDeleteTable(
admin.setQuota(settings);
}
}
} else if (quotasAtNamespace != null) {
// If quota present at namespace level remove the table entry from 'hbase:quota'
Copy link
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
Contributor Author

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
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
Contributor Author

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

@@ -117,6 +118,19 @@ public static void addNamespaceQuota(final Connection connection, final String n

public static void deleteNamespaceQuota(final Connection connection, final String namespace)
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
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
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
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
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
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-cr7 shardul-cr7 changed the title HBASE-20821 Re-creating a dropped namespace and contained table inherits previously set space quota settings HBASE-20821 Space Quota: Re-creating a dropped namespace and contained table inherits previously set space quota settings Sep 11, 2019
@saintstack
Copy link
Contributor

What is needed to move this patch forward? Thanks.

@joshelser
Copy link
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
Contributor

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

@saintstack
Copy link
Contributor

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

@saintstack saintstack closed this Jun 5, 2020
Sign up for free to 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