Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

synapse_pushers metric overcounts on every /pushers/set request #13295

Closed
squahtx opened this issue Jul 15, 2022 · 1 comment · Fixed by #13296
Closed

synapse_pushers metric overcounts on every /pushers/set request #13295

squahtx opened this issue Jul 15, 2022 · 1 comment · Fixed by #13296
Labels
A-Push Issues related to push/notifications S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@squahtx
Copy link
Contributor

squahtx commented Jul 15, 2022

When handling a /pushers/set request, Synapse removes any matching pushers belonging to a different user, then calls PusherPool.add_pusher:

if not append:
await self.pusher_pool.remove_pushers_by_app_id_and_pushkey_not_user(
app_id=content["app_id"],
pushkey=content["pushkey"],
not_user_id=user.to_string(),
)
try:
await self.pusher_pool.add_pusher(
user_id=user.to_string(),
access_token=requester.access_token_id,
kind=content["kind"],
app_id=content["app_id"],
app_display_name=content["app_display_name"],
device_display_name=content["device_display_name"],
pushkey=content["pushkey"],
lang=content["lang"],
data=content["data"],
profile_tag=content.get("profile_tag", ""),
)

PusherPool.add_pusher eventually creates a new pusher to replace the existing one:

byuser = self.pushers.setdefault(pusher_config.user_name, {})
if appid_pushkey in byuser:
byuser[appid_pushkey].on_stop()
byuser[appid_pushkey] = p
synapse_pushers.labels(type(p).__name__, p.app_id).inc()

Critically, it increments the synapse_pushers metric, regardless of whether it replaced an existing pusher, so stopped pushers can be included in the count.

@squahtx squahtx added A-Push Issues related to push/notifications S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels Jul 15, 2022
@squahtx
Copy link
Contributor Author

squahtx commented Jul 15, 2022

The bug was introduced in #7855

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Push Issues related to push/notifications S-Tolerable Minor significance, cosmetic issues, low or no impact to users. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant