Skip to content

Commit

Permalink
Merge pull request #402 from iExecBlockchainComputing/feature/5.1.0-rc3
Browse files Browse the repository at this point in the history
Make the couple (chainDealId+taskIndex) unique
  • Loading branch information
zguesmi authored Mar 16, 2021
2 parents f49673e + 7e6f88f commit 4531e30
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/com/iexec/core/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Version;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;

import java.util.ArrayList;
Expand All @@ -39,6 +40,16 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
/**
* We need this index to make sure that we don't
* add two tasks with the same combination:
* (chainDealId + taskIndex).
* This can appear when multiple threads call
* the method {@link TaskService#addTask()}.
*/
@CompoundIndex(name = "unique_deal_idx",
def = "{'chainDealId': 1, 'taskIndex': 1}",
unique = true)
public class Task {

@Id
Expand Down

0 comments on commit 4531e30

Please sign in to comment.