{"record":{"id":"be1347269cdaab4c","repo":"apache/druid","slug":"unable-to-move-file-s-not-present-in-either-sour","errorCode":null,"errorMessage":"Unable to move file %s, not present in either source or target location","messagePattern":"Unable to move file (.+?), not present in either source or target location","errorType":"exception","errorClass":"SegmentLoadingException","httpStatus":null,"severity":"error","filePath":"extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3DataSegmentMover.java","lineNumber":218,"sourceCode":"    }\n    final ServerSideEncryptingAmazonS3 s3Client = this.s3ClientSupplier.get();\n    final HeadObjectResponse sourceMetadata;\n    try {\n      sourceMetadata = s3Client.getObjectMetadata(s3Bucket, s3Path);\n    }\n    catch (S3Exception e) {\n      if (e.statusCode() == 404) {\n        // Source is gone; succeed silently if it already landed at the target.\n        if (s3Client.doesObjectExist(targetS3Bucket, targetS3Path)) {\n          log.info(\n              \"Not moving file [s3://%s/%s], already present in target location [s3://%s/%s]\",\n              s3Bucket,\n              s3Path,\n              targetS3Bucket,\n              targetS3Path\n          );\n        } else {\n          throw new SegmentLoadingException(\n              \"Unable to move file %s, not present in either source or target location\",\n              copyMsg\n          );\n        }\n        return;\n      }\n      throw e;\n    }\n    final StorageClass sc = sourceMetadata.storageClass();\n    if (StorageClass.GLACIER.equals(sc) || StorageClass.DEEP_ARCHIVE.equals(sc)) {\n      throw S3Exception.builder()\n          .message(StringUtils.format(\n              \"Cannot move file[s3://%s/%s] of storage class [%s], skipping.\",\n              s3Bucket,\n              s3Path,\n              sc\n          ))\n          .build();","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3DataSegmentMover.java#L200-L236","documentation":"safeMove's moveObject retries the copy; if the source object does not exist (or the target already exists from a prior partial move) it logs and returns assuming the move already happened, but if both checks fail it throws this SegmentLoadingException because the file exists in neither location.","triggerScenarios":"moveObject copy fails because the source key is absent, doesNotExist handling triggers, and the target object is also absent — i.e., the segment file was deleted or the key is wrong.","commonSituations":"Segment already killed by another task between listing and move, wrong bucket/baseKey in loadSpec, manually deleted S3 objects, transient eventual-consistency issues with S3-compatible stores.","solutions":["Verify the source loadSpec bucket/key actually contains the file (aws s3 ls).","Check whether another kill/move task already removed or relocated the segment; if so the segment can be marked as dropped.","Correct the segment metadata (druid_segments table) if it points to a stale location.","Check S3-compatible store consistency settings if using MinIO/other providers."],"exampleFix":"// query the segments table to confirm location before moving\n// SELECT load_spec FROM druid_segments WHERE id = '<segmentId>';","handlingStrategy":"try-catch","validationCode":"// check the object exists before attempting a move\ntry { s3Client.headObject(srcBucket, srcKey); }\ncatch (NoSuchKeyException e) { /* already moved/killed — reconcile metadata instead of moving */ }","typeGuard":null,"tryCatchPattern":"try { mover.move(segment, target); } catch (SegmentLoadingException e) {\n  if (e.getMessage().contains(\"not present in either source or target\")) reconcileSegmentMetadata(segment);\n  else throw e;\n}","preventionTips":["Ensure only one kill/move task handles a segment at a time","Reconcile druid_segments metadata with actual S3 state after manual deletions","Verify loadSpec bucket/key values after any deep-storage migration"],"tags":["s3","segment-move","missing-object","deep-storage"],"backgroundTag":"resource-not-found","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}