DHBWMannheim / ml-server

University project which aims to provide different ML models to predict ETH prices
https://pkg.go.dev/github.com/DHBWMannheim/ml-server
GNU General Public License v3.0
1 stars 1 forks source link

Prevent race condition for concurrent requests #4

Open aaronschweig opened 3 years ago

aaronschweig commented 3 years ago

Describe the bug If two concurrent requests to the /technical endpoint should be served, a race condition occurs. Due to storing the model, as well as the currentModel as a struct field, it may be overwritten by loading new models into memory. This causes at least one error to one of the requests, which cannot process the model correctly. Therefore a threadsafe method should be implemented, which handles the loaded models respectively.

To Reproduce Steps to reproduce the behavior:

  1. Start two concurrent requests to /technical/<shareID A> and /techical/<shareID B>
  2. At least one of the requests will fail due to memory corruption

Expected behavior The server should be able to process concurrent requests which require two different models.

Desktop (please complete the following information):

Additional context

--