Skip to content

Commit

Permalink
dcache-bulk: add neglected backport of duplicate path check to 8.2
Browse files Browse the repository at this point in the history
Motivation:

see #7064
TAPE API: Executing stage request with duplicate file paths
ends up with SQL exception in the client output

The in-memory collapsing of duplicate paths
done in master was not back-ported to 8.2, but
is also necessary there.

Modification:

Add the missing code.

Result:

Duplicate paths are collapsed and no SQL error is
generated.

Target: 8.2
Pull-request: 8.2
Requires-notes: yes
Patch: https://rb.dcache.org/r/13931/
Closes: #7064
Acked-by: Dmitry
  • Loading branch information
alrossi authored and mksahakyan committed Mar 27, 2023
1 parent ce23555 commit 36fab3f
Showing 1 changed file with 7 additions and 0 deletions.
Expand Up @@ -71,9 +71,11 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import java.sql.Timestamp;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.dcache.namespace.FileAttribute;
import org.dcache.namespace.FileType;
import org.dcache.services.bulk.BulkRequest;
Expand Down Expand Up @@ -146,6 +148,7 @@ public Optional<KeyHolder> insert(JdbcRequestTargetUpdate update) {

public void insertInitialTargets(BulkRequest request) {
List<TargetPlaceholder> targets = new ArrayList<>();
Set<String> seen = new HashSet<>();
for (String target : request.getTarget()) {
TargetPlaceholder t = new TargetPlaceholder();
t.rid = request.getId();
Expand All @@ -158,6 +161,10 @@ public void insertInitialTargets(BulkRequest request) {
t.path = target;
t.state = CREATED.name();
}
if (seen.contains(t.path)) {
continue;
}
seen.add(t.path);
targets.add(t);
}
utils.insertBatch(targets, BATCH_INSERT, SETTER, this);
Expand Down

0 comments on commit 36fab3f

Please sign in to comment.