vector-plus icon indicating copy to clipboard operation
vector-plus copied to clipboard

Saving connection configuration violates a unique constraint

Open instantiator opened this issue 3 years ago • 0 comments

On saving RoboConfig from the connection page, a unique constraint is violated in the db.

VectorPlus.Web.Service.VectorPlusBackgroundService.StoreRoboConfig(RoboConfig config) in VectorPlusBackgroundService.cs
+
db.SaveChanges();
VectorPlus.Web.Service.VectorPlusBackgroundService.SetRoboConfigAsync(string robotName, string robotSerial, string email, string password, string ipOverride) in VectorPlusBackgroundService.cs
+
StoreRoboConfig(roboConfig); // store final version with cert and guid
VectorPlus.Web.Controllers.ConnectionController.UpdateAsync(ConnectionViewModel model) in ConnectionController.cs
+
var response = await service.SetRoboConfigAsync(
Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()

118428435_10164622986585019_6646985092555608700_o

NB. The RoboConfig should be a singleton in the database. This should be fixable by first searching for and removing any existing RoboConfig entries before saving the new one.

To be confirmed: I had believed this was already happening.

The issue could relate to a recent change that switches from creating a database context for each operation, to retaining a long-lived singleton database context.

If that's the case, the issue may be that transaction management needs to be implemented, so that operations can be flushed to the database in order.

instantiator avatar Aug 23 '20 16:08 instantiator