Skip to content

Saving connection configuration violates a unique constraint #3

@instantiator

Description

@instantiator

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingshow-stopperThis issue breaks a whole feature (or the whole tool)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions