Skip to content

op-service: ref-metrics safe for concurrent use #16159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025

Conversation

protolambda
Copy link
Contributor

Description

Fix LatencySeen map updates/reading to be safe for concurrent use.

Bug-report:

t=2025-05-28T04:07:41+0000 lvl=info msg="Emitting local safe update because of L2 block" derivedFrom=0xa8bf89602ff0a73fdf6ca99f7fdb6a709841f328548cd7a70b395d087f48a351:8422261 derived=0xa63f6db0a19a65b5556b16cf27c90c87b3097f54e5c5848c65caad93e91fd252:27477
t=2025-05-28T04:07:41+0000 lvl=info msg="generated attributes in payload queue" txs=1 timestamp=1748405099
fatal error: concurrent map read and map write
goroutine 508 [running]:
github.com/ethereum-optimism/optimism/op-service/metrics.recordRefWithLabels(0xc00064a190, {0x1c1298d, 0xa}, 0x808375, 0x68368bf0, {0xa8, 0xbf, 0x89, 0x60, 0x2f, ...}, ...)
    /app/op-service/metrics/ref_metrics.go:126 +0x154
github.com/ethereum-optimism/optimism/op-service/metrics.(*RefMetrics).RecordRef(...)

@protolambda protolambda requested a review from axelKingsley May 28, 2025 21:39
@protolambda protolambda requested a review from a team as a code owner May 28, 2025 21:39
Copy link
Contributor

@axelKingsley axelKingsley left a comment

Choose a reason for hiding this comment

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

I was going to suggest that mu be a RW Lock so that concurrent readers could happen, but seems like the read and write happen at the same time. Maybe that means a CompareAndSwap sort of thing would be possible, but that's just bike shedding.

LGTM.

Copy link

codecov bot commented May 28, 2025

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 44.00%. Comparing base (30b7101) to head (108731a).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
op-service/metrics/ref_metrics.go 0.00% 7 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (30b7101) and HEAD (108731a). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (30b7101) HEAD (108731a)
cannon-go-tests-64 2 0
contracts-bedrock-tests 2 0
Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #16159       +/-   ##
============================================
- Coverage    81.40%   44.00%   -37.40%     
============================================
  Files          161     1209     +1048     
  Lines         8812   101343    +92531     
============================================
+ Hits          7173    44597    +37424     
- Misses        1506    53225    +51719     
- Partials       133     3521     +3388     
Flag Coverage Δ
cannon-go-tests-64 ?
contracts-bedrock-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
op-service/metrics/ref_metrics.go 0.00% <0.00%> (ø)

... and 1369 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@protolambda protolambda added this pull request to the merge queue May 28, 2025
Merged via the queue into develop with commit e6ccd5c May 28, 2025
58 of 59 checks passed
@protolambda protolambda deleted the concurrent-ref-metrics branch May 28, 2025 22:25
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