Skip to content

HBASE-30332 Preserve QueryMetrics for empty results - #8555

Open
Sigma-Ma wants to merge 1 commit into
apache:masterfrom
Sigma-Ma:HBASE-30332-query-metrics-empty-result
Open

HBASE-30332 Preserve QueryMetrics for empty results#8555
Sigma-Ma wants to merge 1 commit into
apache:masterfrom
Sigma-Ma:HBASE-30332-query-metrics-empty-result

Conversation

@Sigma-Ma

Copy link
Copy Markdown
Contributor

JIRA: https://issues.apache.org/jira/browse/HBASE-30332

What changes were proposed in this pull request?

This pull request preserves QueryMetrics when an empty Result is converted to and from protobuf.

The changes:

  • Preserve metrics in both ProtobufUtil.toResult and ProtobufUtil.toResultNoData when the result contains no cells.
  • Continue reusing the cached empty protobuf instances when metrics are not present.
  • Create a per-response empty Result when deserializing a protobuf containing metrics, instead of attaching metrics to the shared cached EMPTY_RESULT.
  • Add a focused regression test covering both serialization and both deserialization paths.

No protobuf schema change is required.

Why are the changes needed?

When a Get with query metrics enabled requests a row that does not exist, the RegionServer still computes and attaches QueryMetrics, including blockBytesScanned, to the empty Result.

However, the protobuf conversion methods returned cached empty protobuf instances before copying the metrics. As a result, the client received result.getMetrics() == null.

Simply preserving the metrics during serialization would also expose a second problem: the deserialization path could attach metrics to a shared cached empty Result, potentially leaking those metrics into later requests where metrics were not enabled.

These changes preserve the metrics while ensuring that metrics-bearing empty results are not shared between requests.

How was this patch tested?

The following focused test was run:

mvn -pl hbase-client -am \
  -Dtest=TestProtobufUtil \
  -Dsurefire.failIfNoSpecifiedTests=false \
  test

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.

2 participants