-
Notifications
You must be signed in to change notification settings - Fork 0
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
Data race when HTTP server boots #22
Comments
Okay, the first thing I can see is that the code (read: me) is wrapping to call to index data in an unnecessary Go routine: https://github.com/whosonfirst/go-whosonfirst-spatial-www/blob/main/server/app.go#L122-L129 It is unnecessary because the code it is calling invokes its own Go routine: go-whosonfirst-spatial-www/vendor/github.com/whosonfirst/go-whosonfirst-spatial/app/app.go Line 76 in 6364630
So the code starts by saying: Spatial application, go an index these paths in the background. And a little further down it says: Create a data (HTTP) handler using the spatial application's spatial database: https://github.com/whosonfirst/go-whosonfirst-spatial-www/blob/main/server/app.go#L161 If you look carefully at the data handler you'll see it doesn't know anything about "spatial applications" but only about readers; specifically the spatial application implements the go-whosonfirst-spatial-www/http/data.go Line 12 in 6364630
https://github.com/whosonfirst/go-whosonfirst-spatial-rtree/blob/main/database.go#L589 That part is important. The data handler doesn't know anything about the spatial application or the spatial application's iterator which is indexing data in the background, notably the go-whosonfirst-spatial-www/vendor/github.com/whosonfirst/go-whosonfirst-spatial/app/app.go Line 105 in 6364630
So it's very possible for the data handler to start getting requests for records that haven't been indexed yet, for example with a really big repo like GB postalcodes. One bad habit that I've been trying to address going forward is not wrapping other people's errors in something that will help track down errors. Not doing this often leads to getting an error that just says https://github.com/whosonfirst/go-whosonfirst-spatial-rtree/blob/main/database.go#L620-L646 At the end of all of this my immediate hunch is that the data race is being triggered by the nested Go routines and the So, I will create a new branch that does the following:
Hopefully one or both of those things will address the issues you're seeing. |
Can you try the https://github.com/whosonfirst/go-whosonfirst-spatial-www/compare/issue-22 For example:
Note that the go-whosonfirst-spatial-www/vendor/github.com/whosonfirst/go-whosonfirst-spatial-pip/api/http.go Lines 32 to 35 in 6364630
|
I was trying to track down a bug where infrequently connections to the PIP endpoint would return
EOF
in my HTTP Client, so I booted the server up with-race
to see if this might be a server error. I don't think it is, but I did spot this in the logs as the server boots.The text was updated successfully, but these errors were encountered: