-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[BUG] Data races when using two services #1560
Comments
Please, provide race log |
It is a bit random, but here are two:
|
This was not designed to run in a single process hence the data race. |
Yes, I can understand that, so there is no way to run a go micro web service together with a micro service client then? I want to make an API gateway for my backend services as well as a few services that run RPC and Web endpoints at the same time (for file upload/download) |
I'll take a look, i think that web api and rpc service is useful combination |
can you try master branch and replay test? ( fix in #1576 ) |
So far it looks very promising, I will do more tests during the day |
Unfortunately I spoke too soon, I had actually failed to update to the latest master version and was still running the old version, I just happened to not get the data race whenever I quickly looked at it. Here is the call stack, it seems the app.RunContext() calls back into the web.service.Init() and tries to lock the lock again before it is released. |
sorry and checks for test, can you check #1585 ? |
Yes, it seems to start correctly now. Thanks!
If I change the s.RLock()/s.RUnlock() to s.Lock()/s.Unlock() it seems to work better. |
A solution to the related issue I found could be to not set the micro service name to the web service name unless it is empty. // pass in own name and version
serviceOpts = append(serviceOpts, micro.Name(s.opts.Name))
serviceOpts = append(serviceOpts, micro.Version(s.opts.Version)) we can do: // pass in own name and version
if s.opts.Service.Name() == "" {
serviceOpts = append(serviceOpts, micro.Name(s.opts.Name))
}
serviceOpts = append(serviceOpts, micro.Version(s.opts.Version)) What do you think about that @vtolstov? |
@PatrLind make sense, can you provide pr ? |
This fixes one of the reported data races and also allows for having a different name on the micro.Service and web.Service. This makes it possible to discover the two service variants separatley.
I am trying to run a micro.Service together with a web.Service. Sometimes I get data race errors in different places inside the code. Usually around the logging or option handling.
Perhaps I am not using the framework correctly, in that case I would like to know an alternative way to have a micro.Service together with a web.Service.
I am using: github.com/micro/go-micro/v2 v2.4.0
This code usually reproduces the issue:
Environment:
go version go1.14 windows/amd64
The text was updated successfully, but these errors were encountered: