Closed yatharthranjan closed 3 months ago
I noticed there is a cyclic dependency between the users
and user_metrics
tables, perhaps that is the reason? They both define a foreign key on each other. Preferably only one of the two holds the main key and the other depends on the second. For example user deletion in SQL is not possible without setting one of the keys to null.
Following https://www.baeldung.com/jpa-one-to-one, In User, it should be
@OneToOne(cascade = CascadeType.ALL)
private UserMetrics usermetrics;
and in UserMetrics
@ToString.Exclude @NonNull @OneToOne(mappedBy = "usermetrics") private User user;
In liquibase one of the constraints should be removed, as well as the user_metrics.user_id
column. If there is any SQL call to fetch the user from the UserMetrics, then probably an index should be added to users.usersmetrics_id
.
ah yes good point about the missing mappedBy, that should be it.
Fixed in #446
Please check if the bug has already been reported in the Issues Tab and mention any related issues here.
Describe the bug Deadlock was detected in a user update in our production env. On image :
radarbase/radar-appserver:2.0.2
Priority 1
Difficulty 5
Additional context Add any other context about the problem here.
Logs