Skip to content

Commit

Permalink
dcache-bulk: fix bug in archiver deletion query
Browse files Browse the repository at this point in the history
Motivation:

The archiver should delete only requests that are
in terminal state.

State is missing as part of the actual delete query!

Also, we should not delete INCOMPLETE requests as
there is the slight possibility the archiver could
be running while an initial insertion is taking
place and could slice it (as the three table
insertions are not in the same transaction).

Modification:

Add the states and remove `INCOMPLETE`.

Result:

Correct behavior which does not risk
deleting ongoing active requests.
(This was in fact observed during
testing.)

Target: master
Request: 9.2
Patch: https://rb.dcache.org/r/14141/
Requires-notes:  yes (potentially could drop requests which have not finished)
Acked-by: Tigran
  • Loading branch information
alrossi committed Oct 17, 2023
1 parent d466c36 commit b3a1bb7
Showing 1 changed file with 3 additions and 4 deletions.
Expand Up @@ -61,7 +61,6 @@ 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 @@ -160,7 +159,7 @@ public void run() {
long threshhold = System.currentTimeMillis() - archiverWindowUnit.toMillis(archiverWindow);

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

/*
Expand All @@ -169,9 +168,9 @@ public void run() {
expiredUids.forEach(this::insert);

/*
* Delete all the out-of-date requests.
* Delete all the out-of-date requests which are terminal.
*/
requestDao.delete(requestDao.where().modifiedBefore(threshhold));
requestDao.delete(requestDao.where().modifiedBefore(threshhold).status(COMPLETED, CANCELLED));
lastRunCompleted = System.currentTimeMillis();
}

Expand Down

0 comments on commit b3a1bb7

Please sign in to comment.