jenkinsci / last-changes-plugin

https://plugins.jenkins.io/last-changes
https://plugins.jenkins.io/last-changes/
31 stars 31 forks source link

Files Not Closed When Running On Windows Agent #75

Open toneill818 opened 4 years ago

toneill818 commented 4 years ago

After the latest update, windows agents are keeping open files in GIT. This caused our cleanup script to fail.

java.nio.file.FileSystemException: .git\objects\pack\pack-ff7235b9cf2d97db97bb512980d712b7afcafda9.pack

rmpestano commented 4 years ago

I'll try to reproduce on unix and then come with a fix over this weekend.

Also if you can have a look @david-mntl, it would be nice ;)

gbwey9 commented 4 years ago

I am also seeing the issue on windows. The problem only occurs when setting to "Last Successful Build". However, "Previous Revision" works without any problems.

rmdir /q/s .git .git\objects\pack\pack-1cb6826f35b0ce6ebdff26aefaff70f71e25c0e3.pack - The process cannot access the file because it is being used by another process.

Bajotumn commented 3 years ago

@rmpestano Any update on this?

rmpestano commented 3 years ago

Hey guys, can you share the steps to reproduce?

does it need to be an agent or it also happens on master/main node? also, is it true that it only happens with Last Successful Build option?

This caused our cleanup script to fail.

What do you do to check the file is being held by Jenkins?

If I set Jenkins to keep only one build history, I'll see the issue on the second build?

Bajotumn commented 3 years ago

@rmpestano

I don't have any pipelines that run on the main node, but using a Windows Server 2019 agent and OpenJDK 11 (I believe I also verified this behavior with OpenJDK 8 thinking the cause might have been updating from 8 to 11), with Last Successful Build causes a lock on a .pack file if the build fails or is aborted.

This issue is not apparent until the cleanWs() method is called, or a new build attempts to pull changes.

Using Lock Hunter I was able to verify that java.exe was maintaining an exclusive handle on the file in question.

The issue does not present itself when using Previous Revision as mentioned by @gbwey9.

Here is the invocation I use from a global library.

lastChanges format: 'SIDE', matching: 'LINE', showFiles: true, since: 'LAST_SUCCESSFUL_BUILD'

I can try to create a generic repro later this week if it helps.

rmpestano commented 3 years ago

Thank you very much Jakob!

The main issue is to reproduce this on a dev machine, with your information I'll try to get the java.nio.file.FileSystemException on Ubuntu or MacOS.

barefootcaveman commented 2 years ago

This appears to still cause a lock on a .pack file with Last Successful Build.

barefootcaveman commented 1 year ago

This appears to still be an issue since the last time I posted on Jan 17, 2022, which is over a year later. Just wondering what the status was. In the meantime, I scripted a less-than-ideal hack to search for the java handle of the .pack file and then kill the process.