Comments (2)
Hey @bearrito thanks for sharing this.
I would be interested to understand how you reproduce it because this is not something occurring on my side.
from go-feature-flag.
It looks like what is happening is a concurrent write to the webscocket connection
https://github.com/thomaspoignant/go-feature-flag/blob/main/cmd/relayproxy/service/websocket.go#L45
==================
WARNING: DATA RACE
Read at 0x00c0001f0338 by goroutine 32:
github.com/gorilla/websocket.(*Conn).beginMessage()
/home/bstrausser/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:492 +0x6d
github.com/gorilla/websocket.(*Conn).WriteMessage()
/home/bstrausser/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:779 +0x17b
github.com/thomaspoignant/go-feature-flag/cmd/relayproxy/controller.(*wsFlagChange).pingPongLoop()
/home/bstrausser/Git/go-feature-flag/cmd/relayproxy/controller/ws_flag_change.go:87 +0x35e
github.com/thomaspoignant/go-feature-flag/cmd/relayproxy/controller.(*wsFlagChange).Handler.func3()
/home/bstrausser/Git/go-feature-flag/cmd/relayproxy/controller/ws_flag_change.go:58 +0x71
Previous write at 0x00c0001f0338 by goroutine 27:
github.com/gorilla/websocket.(*Conn).NextWriter()
/home/bstrausser/go/pkg/mod/github.com/gorilla/[email protected]/conn.go:538 +0x177
github.com/gorilla/websocket.(*Conn).WriteJSON()
/home/bstrausser/go/pkg/mod/github.com/gorilla/[email protected]/json.go:24 +0x7e
github.com/thomaspoignant/go-feature-flag/cmd/relayproxy/service.(*websocketServiceImpl).BroadcastFlagChanges()
I can force this by doing one of two things
Number 1
Add a tight loop at the https://github.com/thomaspoignant/go-feature-flag/blob/main/cmd/relayproxy/controller/ws_flag_change_test.go#L120
for i := 0; i < 10000; i++ {
websocketService.BroadcastFlagChanges(tt.flagChange)
_, _, err := ws.ReadMessage()
assert.NoError(t, err)
}
Set the ping pong frequency to something high https://github.com/thomaspoignant/go-feature-flag/blob/main/cmd/relayproxy/controller/ws_flag_change.go#L77 I did 100ms
Eventually the Broadcast and ping-pong will race. I takes a lot of loops and fast ping-pong rate so if this is real I bet this is rare in production.
Number 2
A sleep statement or debugger breakpoint before https://github.com/thomaspoignant/go-feature-flag/blob/main/cmd/relayproxy/controller/ws_flag_change_test.go#L121 will also cause it. I assume this stalls the broadcast write and gives time to the ping-ponger.
from go-feature-flag.
Related Issues (20)
- Change the writing file mechanism
- (bug) AwsConfig ignored as of s3Retrieverv2 refactoring HOT 3
- (change) Use slog in the go module
- (feature) <PHP provider> HOT 1
- (feature) Add an option to not retrieve flag values on weekend or dev environment to reduce carbon footprint HOT 9
- 👀 Open pull request on open feature contrib repositories HOT 19
- (bug) OFREP error should contain flag key
- Did 1.26.0 release get re-tagged? HOT 2
- Default value when there is no feature flags in the cache HOT 2
- K8S Relay proxy config templating
- (bug) [relay-proxy] Override configuration via env variables in `retrievers` does not work HOT 5
- (change) Allow templating in relaxyproxy.config helm chart values HOT 1
- (feature) Force call to the retrievers
- (feature) Integration with Datadog RUM
- (bug) targetingKey does not work in the query of targeting rule using OFREP HOT 6
- (doc) Describe evaluation context HOT 2
- (change) Propose updating the base image of relay proxy to Debian 12 (bookworm) HOT 2
- (feature) Github Retriever check rate limiting
- (change) Github retriever add Github response header in the error.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-feature-flag.