[fix][metadata] Record get op stats on the correct completion branch in AbstractMetadataStore#26201
Open
SongOf wants to merge 1 commit into
Open
[fix][metadata] Record get op stats on the correct completion branch in AbstractMetadataStore#26201SongOf wants to merge 1 commit into
SongOf wants to merge 1 commit into
Conversation
…in AbstractMetadataStore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Since #24580, the
whenCompletecallback inAbstractMetadataStore#gethas itsbranch contents inverted. The failure branch (
t != null) callsv.ifPresent(...), but on exceptional completionvis alwaysnull, so thecallback throws a
NullPointerExceptionthat short-circuitsmetadataStoreStats.recordGetOpsFailed. PerwhenCompletesemantics the NPE isonly attached to the original exception as a suppressed exception, so callers
still see the original failure — which is why this went unnoticed. The actual
damage is to observability:
pulsar_metadata_store_ops_latency{type="get", status="fail"}histogram, sothe metric silently reports zero failures even when the metadata store is
unhealthy (the only path still counted is the synchronous invalid-path check).
nodeSizeStats.recordGetRes— which [fix][broker]Fix never recovered metadata store bad version issue if received a large response from ZK #24580 intended to run on the successpath (cf.
recordGetChildrenResingetChildren) — is never invoked at all,so node-size stats for get responses were never collected.
Modifications
AbstractMetadataStore#get, moverecordGetOpsFailedback to being thesole action of the failure branch, and move
v.ifPresent(... nodeSizeStats.recordGetRes ...)into the success branchwhere it was intended to run.
AbstractMetadataStoreGetStatsTestcovering both halves of the bugagainst a minimal
AbstractMetadataStoretest double.Verifying this change
This change added tests and can be verified as follows:
AbstractMetadataStoreGetStatsTest#testGetFailureRecordsFailedOpAndPropagatesOriginalException:injects a failing
storeGetand asserts the original exception propagateswithout a suppressed NPE and that the
status="fail"histogram countincrements — fails before this fix.
AbstractMetadataStoreGetStatsTest#testGetSuccessRecordsNodeSizeStats:asserts
MetadataNodeSizeStats#recordGetResis invoked with the returnedGetResultand thestatus="success"count increments — fails before thisfix (
recordGetReswas never called).Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
The existing
pulsar_metadata_store_ops_latency{type="get", status="fail"}histogram starts reporting real values (it previously never recorded async get
failures), and node-size stats for get responses are now actually collected. No
metric names, labels, or types change.