Skip to content

Commit

Permalink
Merge pull request #7356 from alrossi/fix/9.2/bulk-request-insert-perm
Browse files Browse the repository at this point in the history
dcache-bulk:  only set request status to QUEUED when permissions and …
  • Loading branch information
svemeyer authored Oct 4, 2023
2 parents 28b0beb + a29351a commit d34029c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

import static org.dcache.services.bulk.BulkRequestStatus.CANCELLED;
import static org.dcache.services.bulk.BulkRequestStatus.COMPLETED;
import static org.dcache.services.bulk.BulkRequestStatus.INCOMPLETE;

import dmg.cells.nucleus.CellInfoProvider;
import java.io.PrintWriter;
Expand Down Expand Up @@ -137,7 +138,7 @@ public void run() {
long threshhold = System.currentTimeMillis() - archiverWindowUnit.toMillis(archiverWindow);

List<String> expiredUids = requestDao.getUids(
requestDao.where().modifiedBefore(threshhold).status(COMPLETED, CANCELLED),
requestDao.where().modifiedBefore(threshhold).status(INCOMPLETE, COMPLETED, CANCELLED),
Integer.MAX_VALUE);

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ public JdbcBulkRequestCriterion id(Long id) {
return this;
}

public JdbcBulkRequestCriterion unique(Long id) {
if (id != null) {
addClause("bulk_request.id = ?", id);
}
return this;
}

public JdbcBulkRequestCriterion pnfsId(String pnfsid) {
if (pnfsid != null) {
addClause("request_target.pnfsid = ?", pnfsid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public JdbcBulkRequestUpdate updateFrom(BulkRequest request, String user)
.clearOnSuccess(request.isClearOnSuccess()).clearOnFailure(request.isClearOnFailure())
.depth(request.getExpandDirectories())
.targetPrefix(request.getTargetPrefix()).urlPrefix(request.getUrlPrefix()).user(user)
.status(BulkRequestStatus.QUEUED).arrivedAt(System.currentTimeMillis());
.status(BulkRequestStatus.INCOMPLETE).arrivedAt(System.currentTimeMillis());
}

public JdbcBulkRequestCriterion where() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ public void store(Subject subject, Restriction restriction, BulkRequest request)
try {
/*
* Insertion order: request, permissions, must be maintained.
* Initial insertion status is INCOMPLETE. This is immediately changed to QUEUED
* after insertion is complete.
*/
requestDao.insert(
requestDao.updateFrom(request, BulkRequestStore.uidGidKey(subject)))
Expand All @@ -623,6 +625,8 @@ public void store(Subject subject, Restriction restriction, BulkRequest request)
requestDao.insertArguments(request);

requestTargetDao.insertInitialTargets(request);

requestDao.update(requestDao.where().unique(request.getId()), requestDao.set().status(QUEUED));
} catch (BulkStorageException e) {
throw new BulkStorageException("store failed for " + request.getUid(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
package org.dcache.services.bulk;

public enum BulkRequestStatus {
INCOMPLETE("Request has been created but insertion is not yet complete."),
QUEUED("Request has been submitted to the service and awaits processing."),
STARTED("Request has been set to active and has begun processing."),
COMPLETED("All targets of the request have reached terminal state."),
Expand Down

0 comments on commit d34029c

Please sign in to comment.