Jenkins deletes the workspace without reason

I think we have experienced it now twice, once in Linux and once in Windows worker node. At some random build, Jenkins suddenly says “Checking out a fresh workspace because there’s no workspace”. Then it moves on to actually delete the workspace, the very same one which he claimed did not exist. The workspace is 24 GB large and takes many hours to restore. We definitely do not want to wipe it randomly.

This is probably related to the subversion plugin, as the folders in the workspace are checked out from svn. So, what’s going on? How to avoid this?

This problem is similar to the dreaded “Workspace appear to be locked, so getting a fresh workspace” issue, but this time the wipe seems to be totally unprovoked. I checked the Java code and it appears this situation is triggered when an exception with SVNErrorCode.WC_NOT_DIRECTORY is encountered. Alas, in this time the svn checkout directory is clearly present as there is a read-only file in it and Jenkins fails to wipe it (this is Windows) and even complains about it later.