Sigma-Ma opened a new pull request, #8555: URL: https://github.com/apache/hbase/pull/8555
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: ```bash mvn -pl hbase-client -am \ -Dtest=TestProtobufUtil \ -Dsurefire.failIfNoSpecifiedTests=false \ test -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
