Skip to content

Commit

Permalink
webdav: wait for upload to complete
Browse files Browse the repository at this point in the history
Motivation:
Due to a race condition between file upload and file's checksum
availability a quick client might see no checksum after upload.

Modification:
Update webdav door to retry the request to the namespace if checksum is
not present in files attributes.

Result:

Fixes: #7467
Ticket: #10510
Acked-by: Lea Morschel
Acked-by: Paul Millar
Target: master, 9.2
Require-book: no
Require-notes: yes
(cherry picked from commit b13f6d7)
Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
  • Loading branch information
kofemann authored and lemora committed Dec 19, 2023
1 parent 16d3bb9 commit baa135b
Showing 1 changed file with 21 additions and 2 deletions.
Expand Up @@ -632,8 +632,27 @@ public DcacheResource getResource(FsPath path) {
PnfsHandler pnfs = roleAwarePnfsHandler();
Set<FileAttribute> requestedAttributes =
buildRequestedAttributes();
FileAttributes attributes =
pnfs.getFileAttributes(path.toString(), requestedAttributes);
FileAttributes attributes;

// FIXME: work around race condition between http mover completion and HEAD request by FTS
// See: https://rt.dcache.org/Ticket/Display.html?id=10510
int retry = 10;
do {
attributes = pnfs.getFileAttributes(path.toString(), requestedAttributes);
if (!requestedAttributes.contains(CHECKSUM) ||
(attributes.isDefined(CHECKSUM) && !attributes.getChecksums().isEmpty())) {
break;
}
LOGGER.debug("The checksum attribute is not available yet. Waiting ... ({} attempts left)", retry);
retry--;
try {
MILLISECONDS.sleep(500);
} catch (InterruptedException e) {
// Probably shutdown...
break;
}
} while (retry > 0);

return getResource(path, attributes);
} catch (FileNotFoundCacheException e) {
if (haveRetried) {
Expand Down

0 comments on commit baa135b

Please sign in to comment.