[ISSUE] Cancelling svn checkout leaves an open file handle

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[ISSUE] Cancelling svn checkout leaves an open file handle

Uroš Jovanović
Hello,

Recently I came across this behaviour where if I use the Cancel API to cancel a long running checkout operation, the process running the SVN code leaves an open file handle in the .svn\tmp folder inside the working copy.

Initially, I thought it was a SharpSvn (1.9 x64) issue, but I observed the same behaviour using TortoiseSVN with the latest 1.14 client.
It can be easily reproduced, especially when downloading large file, the .svn\tmp folder holds a file named "svn-XYZ123" and when the operation is cancelled, this file still has an open handle on it, which means that the calling process needs to be shutdown before doing anything else with that WC since cleanup and folder deletion aren't possible. In case of TortoiseSVN it simply means the client window needs to be closed to perform the next operation, but when using SharpSvn in context of a larger application, this would mean the user needs to close the entire application because one unmanaged file handle was left alive.

I searched through reported issues on Jira and couldn't find anything similar.

SVN client version: 1.9 and 1.14.
Platform: Windows 10 (x64)

Best regards
Reply | Threaded
Open this post in threaded view
|

Re: [ISSUE] Cancelling svn checkout leaves an open file handle

Daniel Shahaf-2
Uroš Jovanović wrote on Mon, 07 Sep 2020 19:25 +0200:
> when using SharpSvn in context of a larger
> application, this would mean the user needs to close the entire application
> because one unmanaged file handle was left alive.

Have you tried clearing the relevant pools?

Could you help debugging this?  (E.g., write a reproduction recipe or
a test case or track down where in the code the file gets opened.)

Cheers,

Daniel
Reply | Threaded
Open this post in threaded view
|

Re: [ISSUE] Cancelling svn checkout leaves an open file handle

Uroš Jovanović
Hi Daniel,

Not sure what are "relevant pools", I am not really too familiar with SVN :)

Attached below is a minimal reproduction case.
It is a C# winforms app with Check and Cancel button (.NET 4.8 with SharpSvn 1.9 x64 nuget)

You would just need to type in some real svn repo address in Form1.cs in order to start the checkout process.
I advise choosing the repo with large files which take time to download.

Then, mid downloading some of the larger files a temp file will appear in .svn\tmp. Once that happens, hit the Cancel button.
It will signal the cancellation to the svn client and it will throw the SvnOperationCanceledException, the SvnClient gets disposed BUT an open file handle remains on ".svn\tmp\svn-XYZ123" file.
If you try to delete it, Windows will complain that it is used by our test app. :(

Let me know if you need any further assistance.

Best regards,
Uros


On Tue, Sep 8, 2020 at 12:51 AM Daniel Shahaf <[hidden email]> wrote:
Uroš Jovanović wrote on Mon, 07 Sep 2020 19:25 +0200:
> when using SharpSvn in context of a larger
> application, this would mean the user needs to close the entire application
> because one unmanaged file handle was left alive.

Have you tried clearing the relevant pools?

Could you help debugging this?  (E.g., write a reproduction recipe or
a test case or track down where in the code the file gets opened.)

Cheers,

Daniel

SharpSvnTests.zip (15K) Download Attachment