mesg-foundation / engine

Build apps or autonomous workflows with reusable, shareable integrations connecting any service, app, blockchain or decentralized network.
https://mesg.com/
Apache License 2.0
130 stars 13 forks source link

Concurrency issue when starting service #538

Closed antho1404 closed 5 years ago

antho1404 commented 6 years ago

When we start a service multiple times in the same time interval we have an error from the api

Here is the step to reproduce.

mesg-core service start 64568b68332b7e5af7b19663024c54700571d746 & mesg-core service start 64568b68332b7e5af7b19663024c54700571d746

This will generate one of these two errors:

rpc error: code = Unknown desc = Error response from daemon: network with name core-64568b68332b7e5af7b19663024c54700571d746 already exists
rpc error: code = Unknown desc = Error response from daemon: rpc error: code = Unknown desc = name conflicts with an existing object

This behavior is something that the mesg-js library and any script might be doing.

I see different solutions for that:

Manage this concurrency in the API: Best solution but actually quite hard to implement.

Manage this uniqueness in the libraries: Easy but we will still have the problem with custom scripts and stuff like that.

Do not manage the error but display: It might be enough to catch these errors and display a nice error like service already starting.

Of course a mix of all these would be perfect

NicolasMahe commented 5 years ago

Need to check if this issue still exist

antho1404 commented 5 years ago

can't reproduce and the js library is already making sure that this doesn't happen (https://github.com/mesg-foundation/mesg-js/pull/31). Need more investigations but I personally could not reproduce.

antho1404 commented 5 years ago

This is still reproducible and now the lib js doesn't solve that part anymore but services needs to be started manually so it's not a bit issue for now

core git:(feature/log-errors) ✗ ./dev-cli service start 15b2ac8a7f5a6f73d9bf2fd0a463cf0552fb94a7 & ./dev-cli service start 15b2ac8a7f5a6f73d9bf2fd0a463cf0552fb94a7
[1] 96629
rpc error: code = Unknown desc = Error response from daemon: rpc error: code = Unknown desc = name conflicts with an existing object
antho1404 commented 5 years ago

This is solved by the new instance resource. Users will have an error if they create the exact same instance and if instances are different, they will be able to run properly on the same engine