Skip to content

metrics: use atomic type (#27121)#45

Merged
thaarok merged 1 commit intonormafrom
jkalina/backport-metrics
Jan 8, 2024
Merged

metrics: use atomic type (#27121)#45
thaarok merged 1 commit intonormafrom
jkalina/backport-metrics

Conversation

@thaarok
Copy link
Copy Markdown
Collaborator

@thaarok thaarok commented Jan 8, 2024

Backport of metrics improvement removing a race condition.

Upstream commit:
ethereum/go-ethereum@ae93e0b

Race condition being fixed:

==================
WARNING: DATA RACE
Read at 0x00c005cf8c30 by goroutine 3549:
  github.com/ethereum/go-ethereum/metrics.(*StandardMeter).Snapshot()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/go-ethereum-substate@v1.1.1-0.20231003122306-febfe681b4a7/metrics/meter.go:244 +0x73
  github.com/ethereum/go-ethereum/metrics/exp.Exp.Handler.func1()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/go-ethereum-substate@v1.1.1-0.20231003122306-febfe681b4a7/metrics/prometheus/prometheus.go:55 +0x321
  net/http.HandlerFunc.ServeHTTP()
      /usr/local/go/src/net/http/server.go:2136 +0x47
  net/http.(*ServeMux).ServeHTTP()
      /usr/local/go/src/net/http/server.go:2514 +0xbc
  net/http.serverHandler.ServeHTTP()
      /usr/local/go/src/net/http/server.go:2938 +0x2a1
  net/http.(*conn).serve()
      /usr/local/go/src/net/http/server.go:2009 +0xc24
  net/http.(*Server).Serve.func3()
      /usr/local/go/src/net/http/server.go:3086 +0x4f

Previous write at 0x00c005cf8c30 by goroutine 2517:
  sync/atomic.AddInt64()
      /usr/local/go/src/runtime/race_amd64.s:289 +0xb
  sync/atomic.AddInt64()
      <autogenerated>:1 +0x15
  github.com/Fantom-foundation/go-opera/gossip.(*Service).processEvent()
      /home/jand/go-opera-norma/gossip/c_event_callbacks.go:261 +0x5dd
  github.com/Fantom-foundation/go-opera/gossip.newService.func2()
      /home/jand/go-opera-norma/gossip/service.go:259 +0xa4
  github.com/Fantom-foundation/go-opera/gossip.(*handler).makeDagProcessor.func3()
      /home/jand/go-opera-norma/gossip/handler.go:480 +0x16e
  github.com/Fantom-foundation/lachesis-base/gossip/dagordering.(*EventsBuffer).processCompleteEvent()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/lachesis-base@v0.0.0-20230629034932-42bae8eeb426/gossip/dagordering/event_buffer.go:145 +0x128
  github.com/Fantom-foundation/lachesis-base/gossip/dagordering.(*EventsBuffer).pushEvent()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/lachesis-base@v0.0.0-20230629034932-42bae8eeb426/gossip/dagordering/event_buffer.go:88 +0x152
  github.com/Fantom-foundation/lachesis-base/gossip/dagordering.(*EventsBuffer).PushEvent()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/lachesis-base@v0.0.0-20230629034932-42bae8eeb426/gossip/dagordering/event_buffer.go:66 +0x324
  github.com/Fantom-foundation/lachesis-base/gossip/dagprocessor.(*Processor).process()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/lachesis-base@v0.0.0-20230629034932-42bae8eeb426/gossip/dagprocessor/processor.go:181 +0x115
  github.com/Fantom-foundation/lachesis-base/gossip/dagprocessor.(*Processor).Enqueue.func2()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/lachesis-base@v0.0.0-20230629034932-42bae8eeb426/gossip/dagprocessor/processor.go:146 +0x5b4
  github.com/Fantom-foundation/lachesis-base/utils/workers.worker()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/lachesis-base@v0.0.0-20230629034932-42bae8eeb426/utils/workers/workers.go:66 +0xf2
  github.com/Fantom-foundation/lachesis-base/utils/workers.(*Workers).Start.func1()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/lachesis-base@v0.0.0-20230629034932-42bae8eeb426/utils/workers/workers.go:31 +0x90

Goroutine 3549 (running) created at:
  net/http.(*Server).Serve()
      /usr/local/go/src/net/http/server.go:3086 +0x80c
  net/http.(*Server).ListenAndServe()
      /usr/local/go/src/net/http/server.go:2985 +0xbc
  net/http.ListenAndServe()
      /usr/local/go/src/net/http/server.go:3239 +0x114
  github.com/Fantom-foundation/go-opera/debug.StartPProf.func1()
      /home/jand/go-opera-norma/debug/flags.go:262 +0x115

Goroutine 2517 (running) created at:
  github.com/Fantom-foundation/lachesis-base/utils/workers.(*Workers).Start()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/lachesis-base@v0.0.0-20230629034932-42bae8eeb426/utils/workers/workers.go:29 +0x32
  github.com/Fantom-foundation/lachesis-base/gossip/dagprocessor.(*Processor).Start()
      /home/jand/go/pkg/mod/github.com/!fantom-foundation/lachesis-base@v0.0.0-20230629034932-42bae8eeb426/gossip/dagprocessor/processor.go:80 +0x44
  github.com/Fantom-foundation/go-opera/gossip.(*handler).Start()
      /home/jand/go-opera-norma/gossip/handler.go:694 +0x9bc
  github.com/Fantom-foundation/go-opera/gossip.(*Service).Start()
      /home/jand/go-opera-norma/gossip/service.go:451 +0x504
==================

@thaarok thaarok requested a review from jenikd January 8, 2024 10:06
@thaarok thaarok merged commit c0bb0c7 into norma Jan 8, 2024
@thaarok thaarok deleted the jkalina/backport-metrics branch January 8, 2024 15:11
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.

4 participants