Skip to content
Snippets Groups Projects
Benjamin Bertrand's avatar
Benjamin Bertrand authored
Following exception is raised when trying to update a network from
flask-admin:
sqlalchemy.exc.InvalidRequestError: Can't attach instance <User at 0x7f6f0e39ce10>;
another instance with key (<class 'app.models.User'>, (1,), None) is already present in this session.

1. If we remove the caching of the load_user method, the problem
disappears.
2. When updating a Network, this trigger an inventory update in
before_flush which adds a task to the session. This is when the
current_user is added to the session and the error raised.

So the problem is linked to the user caching and flask-admin.

The workaround is to remove the user object added by flask-admin to the
session.

JIRA INFRA-908 #action In Progress
88f54ded
History
Name Last commit Last update