Skip to content

Commit

Permalink
fix(core): Quick fix failing async group-resource assignments
Browse files Browse the repository at this point in the history
- Async group-resource assignments used to fail on
GroupNotDefinedOnResourceException because after inserting the
assignment to DB, the transaction didn't commit before new transaction
for async activation needed the assignment.
- Now, if the assignment is not committed yet, the activation is
repeated 5 times after 5 seconds.
  • Loading branch information
cuadradek authored and Vojtech-Sassmann committed Jul 26, 2021
1 parent b59ffa6 commit 66489a7
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,22 @@ public void activateGroupResourceAssignment(PerunSession sess, Group group, Reso
@Override
public void processGroupResourceActivationAsync(PerunSession sess, Group group, Resource resource) {
try {
processGroupResourceActivation(sess, group, resource);
// try activation for 5 times after 5 seconds because the assignment
// might not be committed in DB yet
boolean successful = false;
for (int i = 0; i < 5; ++i) {
try {
processGroupResourceActivation(sess, group, resource);
successful = true;
break;
} catch (GroupNotDefinedOnResourceException ex) {
Thread.sleep(5000);
}
}

if (!successful) {
processGroupResourceActivation(sess, group, resource);
}
} catch (Exception e) {
log.error("Activation of group-resource assignment failed.", e);
try {
Expand Down

0 comments on commit 66489a7

Please sign in to comment.