Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artifactory download fails on removing temp file, but the lock seems to come from its own threads #2830

Open
DeDixs opened this issue Jan 15, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@DeDixs
Copy link

DeDixs commented Jan 15, 2025

Describe the bug

When using jf.exe on a Jenkins build server to download artifacts using a spec file as input every now and then a failing download occurs, with a message:

03:00:37 [Error] Failed to close reader: remove C:\Users\userA\AppData\Local\Temp\jfrog.cli.temp.-1736906327-1915232773: The process cannot access the file because it is being used by another process.
03:00:37 [Info] Trace ID for JFrog Platform logs: ff38bc27579ea9b3
03:00:37 [Error] download finished with errors, please review the logs

Due to this the download fails. The failing download can more or less happen for any artifact that is being downloaded.

Current behavior

The error message seems to come from the jfrog-client-go repo, contentreader.go:

// Cleanup the reader data.
func (cr *ContentReader) Close() error {
	for _, filePath := range cr.filesPaths {
		if filePath == "" {
			continue
		}
		if err := errorutils.CheckError(os.Remove(filePath)); err != nil {
			return errors.New("Failed to close reader: " + err.Error())
		}
	}
	cr.filesPaths = nil
	return nil
}

In order to make sure this is not interference of another tool (e.g. virus scanner) ProcessMonitor was executed until the issue occurred. This showed that only jf.exe was accessing the file when it happens - the contentreader tries to remove the file but some other thread still seems to have it open. It seems to be a race condition that only happens on rare occasions, most of the times no issue occurs. It also only seems to occur on Windows, it cannot be reproduced using jf on Linux.

The temp file itself that is reported in the error is still available on the machine that ran the command (since it could not be deleted), its contents do not look suspicious:

{
"results" : [ {
  "repo" : "artifactory-build-info",
  "path" : "BuildName",
  "name" : "219-1732718248695.json",
  "type" : "file",
  "size" : 9053,
  "created" : "2024-11-27T15:38:34.726+01:00",
  "created_by" : "userA",
  "modified" : "2024-11-27T15:38:34.600+01:00",
  "modified_by" : "userA",
  "updated" : "2024-11-27T15:38:34.727+01:00"
} ],
"range" : {
  "start_pos" : 0,
  "end_pos" : 1,
  "total" : 1,
  "limit" : 1
}
}

Reproduction steps

Unfortunately there is no easy way to reproduce it. It simply happens on a Jenkins build server every now and then, breaking the build pipeline. In order to investigate builds were triggered manually until the issue occurred. Just using
jf.exe rt dl --spec <spec>.json
should also reproduce it, but the occurrence is low.

Expected behavior

The download does not fail on trying to remove a temp file that jfrog-cli (jf.exe) has created by itself.

JFrog CLI version

2.73.0

Operating system type and version

Windows 11 23H2

JFrog Artifactory version

7.77.14

JFrog Xray version

N.A.

@DeDixs DeDixs added the bug Something isn't working label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant