Skip to content

Conversation

charlesconnell
Copy link
Contributor

@charlesconnell charlesconnell commented Aug 3, 2025

When asked for a QuotaLimiter for a given user, the QuotaCache checks if that user's quota state is cached. If it is, it returns a QuotaLimiter based on the cached information. If not, it inserts default quota state into the cache, and returns a default QuotaLimiter. On the next run of the QuotaRefresherChore, it looks in the hbase:quota table for the quota settings for every user in the cache. The consequence of this is: from when the QuotaCache is first asked about a user, until the next run of QuotaRefresherChore, the QuotaLimiters for that user are wrong.

I think it's unacceptable for QuotaCache to return incorrect information. I can see from a code comment that it was implemented this was as a performance optimization, to avoid doing a Get on the quota table in the query handler path. However, the performance consequences of not enforcing quotas can be a lot worse that a few Gets.

In this ticket I'm adding logic to QuotaCache so it immediately fetches quota information for a user from the quota table any time that user is not in its cache.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

Comment on lines -84 to -87
// No write throttling
configureLenientThrottle(ThrottleType.ATOMIC_WRITE_SIZE);
refreshQuotas();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These lines shouldn't have been here. Seting a per-user quota of any type shadows the default quotas of all types, making the following assertion fail, if QuotaCache is working properly. The updates to QuotaCache in this PR exposed this test as incorrect.

private QuotaRefresherChore refreshChore;
private boolean stopped = true;

private final Fetcher<String, UserQuotaState> userQuotaStateFetcher = new Fetcher<>() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These Fetcher objects have the same logic as before, but are lifted into top-level-class fields so I can access them in new places.

Comment on lines +204 to +210
String user = getQuotaUserName(ugi);
if (!userQuotaCache.containsKey(user)) {
userQuotaCache.put(user,
QuotaUtil.buildDefaultUserQuotaState(rsServices.getConfiguration(), 0L));
fetch("user", userQuotaCache, userQuotaStateFetcher);
}
return userQuotaCache.get(user);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the meat of the change. If a caller asks for a quota for a given user, check if the quota is already saved in the cache. If so, return it from the cache. If not, do a lookup from the hbase:quota table, cache the result, and then return it. This means that users of QuotaCache don't need to wait for its chore to run in order to get correct results.

}

static interface Fetcher<Key, Value> {
Get makeGet(Map.Entry<Key, Value> entry);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of the Fetcher implementations used the entry value, so I've stopped passing the a fully Entry

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 28s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 hbaseanti 0m 0s Patch does not have any anti-patterns.
_ master Compile Tests _
+1 💚 mvninstall 3m 5s master passed
+1 💚 compile 3m 22s master passed
+1 💚 checkstyle 0m 36s master passed
+1 💚 spotbugs 1m 32s master passed
+1 💚 spotless 0m 44s branch has no errors when running spotless:check.
_ Patch Compile Tests _
+1 💚 mvninstall 3m 6s the patch passed
+1 💚 compile 3m 17s the patch passed
+1 💚 javac 3m 17s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 37s the patch passed
+1 💚 spotbugs 1m 40s the patch passed
+1 💚 hadoopcheck 11m 59s Patch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚 spotless 0m 45s patch has no errors when running spotless:check.
_ Other Tests _
+1 💚 asflicense 0m 9s The patch does not generate ASF License warnings.
38m 59s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7188/3/artifact/yetus-general-check/output/Dockerfile
GITHUB PR #7188
JIRA Issue HBASE-29479
Optional Tests dupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
uname Linux dc4ec20531d9 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 47d97e8
Default Java Eclipse Adoptium-17.0.11+9
Max. process+thread count 84 (vs. ulimit of 30000)
modules C: hbase-server U: hbase-server
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7188/3/console
versions git=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 31s Docker mode activated.
-0 ⚠️ yetus 0m 3s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚 mvninstall 4m 52s master passed
+1 💚 compile 1m 28s master passed
+1 💚 javadoc 0m 45s master passed
+1 💚 shadedjars 8m 2s branch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 4m 42s the patch passed
+1 💚 compile 1m 25s the patch passed
+1 💚 javac 1m 25s the patch passed
+1 💚 javadoc 0m 46s the patch passed
+1 💚 shadedjars 8m 2s patch has no errors when building our shaded downstream artifacts.
_ Other Tests _
-1 ❌ unit 359m 46s /patch-unit-hbase-server.txt hbase-server in the patch failed.
394m 41s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7188/3/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR #7188
JIRA Issue HBASE-29479
Optional Tests javac javadoc unit compile shadedjars
uname Linux 85d96775ece3 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 47d97e8
Default Java Eclipse Adoptium-17.0.11+9
Test Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7188/3/testReport/
Max. process+thread count 4414 (vs. ulimit of 30000)
modules C: hbase-server U: hbase-server
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7188/3/console
versions git=2.34.1 maven=3.9.8
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@charlesconnell charlesconnell marked this pull request as ready for review August 28, 2025 11:10
@charlesconnell charlesconnell merged commit 8c6ecf9 into apache:master Sep 3, 2025
1 check failed
@charlesconnell charlesconnell deleted the HBASE-29479/accurate-quota-cache branch September 3, 2025 17:52
charlesconnell added a commit that referenced this pull request Sep 3, 2025
)

Signed-off by: Ray Mattingly <rmattingly@apache.org>
charlesconnell added a commit that referenced this pull request Sep 3, 2025
)

Signed-off by: Ray Mattingly <rmattingly@apache.org>
charlesconnell added a commit that referenced this pull request Sep 3, 2025
)

Signed-off by: Ray Mattingly <rmattingly@apache.org>
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.

3 participants