Skip to content

HBASE-29672 Handle runtime comparison failures during filtering gracefully - #7397

Open
droudnitsky wants to merge 8 commits into
apache:masterfrom
droudnitsky:HBASE-29672
Open

HBASE-29672 Handle runtime comparison failures during filtering gracefully#7397
droudnitsky wants to merge 8 commits into
apache:masterfrom
droudnitsky:HBASE-29672

Conversation

@droudnitsky

@droudnitskydroudnitsky commented Oct 19, 2025

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/HBASE-29672

There is a large class of filters:

RowFilter
ValueFilter
QualifierFilter
FamilyFilter
DependentColumnFilter
ColumnValueFilter
SingleColumnValueFilter
SingleColumnValueExcludeFilter

Which take a ByteArrayComparable comparator as an argument (e.g BinaryComparator, RegexStringComparator, BinaryComponentComparator) and apply the given comparator at query runtime on the server. Due to filter misconfiguration/data shape/comparator bugs, a comparator may throw a runtime exception which filters are not currently handling. In this case the runtime exception gets propagated all the way up the call stack, leading to an unexpected throwable at the topmost RpcServer layer and a very unclear remote exception on the client with a very long mysterious server exception trace.

This PR adds runtime exception handling for comparator runtime exceptions and treats them as HBaseIOException, and propagate a clear exception message to the client. This approach will also lets us handle cases where we know that a client retry is guaranteed to fail and let us prevent bad requests from being excessively retried (such as HBASE-29654).

Some context/discussion in #7389

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@droudnitskydroudnitsky changed the title HBASE-29672 Handle comparison failures during filtering gracefullyHBASE-29672 Handle runtime comparison failures during filtering gracefullyOct 19, 2025
@droudnitsky

Copy link
Copy Markdown
ContributorAuthor

Code snippet to identify all filters which take ByteArrayComparable, majority (5/8) filters are an extension of CompareFilter , but there are 3 outlier ColumnValue filters which do not extend CompareFilter -

 String pkg = "org.apache.hadoop.hbase.filter"; // <-- the package to scan
List<Class<?>> hits = new ArrayList<>();
try (ScanResult scan = new ClassGraph()
.acceptPackages(pkg)
.enableClassInfo()
.scan()) {
for (ClassInfo ci : scan.getAllClasses()) {
Class<?> cls = ci.loadClass();
for (Constructor<?> ctor : cls.getDeclaredConstructors()) {
for (Class<?> pt : ctor.getParameterTypes()) {
if (pt.getName().equals("org.apache.hadoop.hbase.filter.ByteArrayComparable") // FQCN safer
|| pt.getSimpleName().equals("ByteArrayComparable")) { // simple name
hits.add(cls);
break;
}
}
}
}
}
System.out.println("matches: " + hits.size());
org.apache.hadoop.hbase.filter.ColumnValueFilter
org.apache.hadoop.hbase.filter.CompareFilter
org.apache.hadoop.hbase.filter.DependentColumnFilter
org.apache.hadoop.hbase.filter.FamilyFilter
org.apache.hadoop.hbase.filter.QualifierFilter
org.apache.hadoop.hbase.filter.RowFilter
org.apache.hadoop.hbase.filter.SingleColumnValueExcludeFilter
org.apache.hadoop.hbase.filter.SingleColumnValueFilter

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@droudnitsky

droudnitsky commented Nov 11, 2025

Copy link
Copy Markdown
ContributorAuthor

Hey @Apache9 this PR is the followup from our discussion in here, if you get the chance could you please take a look, thank you

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds graceful error handling for runtime exceptions that occur during comparator operations in HBase filters. When a ByteArrayComparable comparator throws a RuntimeException during filtering, it now gets wrapped in an HBaseIOException with a clear error message, preventing unclear remote exceptions on the client side.

Key Changes:

  • Added runtime exception handling in CompareFilter's compare methods (compareRow, compareFamily, compareQualifier, compareValue)
  • Updated method signatures to throw IOException for affected filter methods
  • Added comprehensive unit tests to verify exception handling across all filter types

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
FileDescription
CompareFilter.javaAdded wrapInHBaseIOException utility method and try-catch blocks to wrap RuntimeExceptions in all compare methods
ValueFilter.javaUpdated filterCell method signature to throw IOException
SingleColumnValueFilter.javaUpdated filterCell and filterColumnValue signatures and added exception wrapping
RowFilter.javaUpdated filterRowKey method signature to throw IOException
QualifierFilter.javaUpdated filterCell method signature to throw IOException
FamilyFilter.javaUpdated filterCell method signature to throw IOException
DependentColumnFilter.javaUpdated filterCell method signature to throw IOException
ColumnValueFilter.javaUpdated private compareValue method signature and added exception wrapping
TestFiltersWithComparatorException.javaNew comprehensive test suite with BadComparator to verify exception handling across all filter types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Apache9

Copy link
Copy Markdown
Contributor

Please fix the typo?

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

droudnitskyand others added 2 commits November 28, 2025 10:53
…FiltersWithComparatorException.java
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…FiltersWithComparatorException.java
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache9

Copy link
Copy Markdown
Contributor

@droudnitsky Not all the copilot comments need to be addressed...

Let me take a look again.

@Apache9Apache9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall LGTM.

Will be good if we can migrate the test to use junit 5.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 28sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed 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 💚mvninstall3m 37smaster passed
+1 💚compile0m 21smaster passed
+1 💚javadoc0m 18smaster passed
+1 💚shadedjars6m 15sbranch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+1 💚mvninstall3m 12sthe patch passed
+1 💚compile0m 21sthe patch passed
+1 💚javac0m 21sthe patch passed
+1 💚javadoc0m 17sthe patch passed
+1 💚shadedjars6m 13spatch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚unit1m 31shbase-client in the patch passed.
23m 33s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7397/6/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR#7397
Optional Testsjavac javadoc unit compile shadedjars
unameLinux 1f5dc8d5c2bb 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 toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / 23f2311
Default JavaEclipse Adoptium-17.0.11+9
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7397/6/testReport/
Max. process+thread count287 (vs. ulimit of 30000)
modulesC: hbase-client U: hbase-client
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7397/6/console
versionsgit=2.34.1 maven=3.9.8
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 28sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+0 🆗codespell0m 0scodespell was not available.
+0 🆗detsecrets0m 0sdetect-secrets was not available.
+1 💚@author0m 0sThe patch does not contain any @author tags.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
_ master Compile Tests _
+1 💚mvninstall2m 58smaster passed
+1 💚compile0m 50smaster passed
+1 💚checkstyle0m 18smaster passed
+1 💚spotbugs0m 42smaster passed
+1 💚spotless0m 45sbranch has no errors when running spotless:check.
_ Patch Compile Tests _
+1 💚mvninstall2m 58sthe patch passed
+1 💚compile0m 48sthe patch passed
-0 ⚠️javac0m 48s/results-compile-javac-hbase-client.txthbase-client generated 1 new + 127 unchanged - 0 fixed = 128 total (was 127)
+1 💚blanks0m 1sThe patch has no blanks issues.
+1 💚checkstyle0m 18sthe patch passed
+1 💚spotbugs0m 49sthe patch passed
+1 💚hadoopcheck11m 14sPatch does not cause any errors with Hadoop 3.3.6 3.4.1.
+1 💚spotless0m 46spatch has no errors when running spotless:check.
_ Other Tests _
+1 💚asflicense0m 9sThe patch does not generate ASF License warnings.
30m 19s
SubsystemReport/Notes
DockerClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7397/6/artifact/yetus-general-check/output/Dockerfile
GITHUB PR#7397
Optional Testsdupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
unameLinux fecd29a4cbaa 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 toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / 23f2311
Default JavaEclipse Adoptium-17.0.11+9
Max. process+thread count83 (vs. ulimit of 30000)
modulesC: hbase-client U: hbase-client
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7397/6/console
versionsgit=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered byApache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@droudnitsky

Copy link
Copy Markdown
ContributorAuthor

Thank you very much for reviewing @Apache9 ! I have migrated the test to junit 5. I believe this patch is also good to be back-ported to 2.x , in terms of client compatibility we are still throwing IOException, let me know if you have any concerns with backporting, otherwise I can open PRs for 2.5/2.6/2.7

@Apache9

Copy link
Copy Markdown
Contributor

Please open a PR against branch-2, usually the patch for branch-2 can be applied to other 2.x branches cleanly.

And please fix the error prone warning if possible.

Thanks.

@droudnitsky

Copy link
Copy Markdown
ContributorAuthor

Thank you @Apache9 , I will open a PR for branch-2.

The error prone warning was generated for a class I did not modify, I can fix it, should that be done in seperate PR since its unrelated to this ?

@noslowerdna

Copy link
Copy Markdown
Contributor

LGTM

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.

5 participants

@droudnitsky@Apache-HBase@Apache9@noslowerdna