KSP-CKAN / CKAN

The Comprehensive Kerbal Archive Network
https://forum.kerbalspaceprogram.com/index.php?/topic/197082-*
Other
1.99k stars 348 forks source link

System.Transactions.TransactionException: Failed to roll back. ---> System.IO.IOException: The process cannot access the file '...' because it is being used by another process #3294

Closed MrChaosBones closed 3 years ago

MrChaosBones commented 3 years ago

Background

Have you made any manual changes to your GameData folder (i.e., not via CKAN)? Nope.

Problem

Describe the bug While performing a Kerbalism/RO and their associated sub-mods install, CKAN throws a file-access error, file in use.

Steps to reproduce This is the 3rd time I reproduce this issue by installing the entire bucket of mods as CKAN deems them right in order, and on the Real Solar System mod, specifically the textures plug-in installing.

Screenshots (if applicable) image

CKAN error code (if applicable):

Unhandled exception:
System.Transactions.TransactionException: Failed to roll back. ---> System.IO.IOException: The process cannot access the file 'D:\Games\Kerbal Space Program\GameData\RSS-Textures\PluginData\TitanColor.dds' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalDelete(String path, Boolean checkHost)
   at ChinhDo.Transactions.FileManager.Operations.SingleFileOperation.Rollback()
   at ChinhDo.Transactions.FileManager.TxEnlistment.Rollback(Enlistment enlistment)
   --- End of inner exception stack trace ---
   at ChinhDo.Transactions.FileManager.TxEnlistment.Rollback(Enlistment enlistment)
   at System.Transactions.VolatileEnlistmentAborting.EnterState(InternalEnlistment enlistment)
   at System.Transactions.TransactionStateAborted.EnterState(InternalTransaction tx)
   at System.Transactions.EnlistableStates.Timeout(InternalTransaction tx)
   at System.Transactions.Bucket.TimeoutTransactions()
   at System.Transactions.BucketSet.TimeoutTransactions()
   at System.Transactions.TransactionTable.ThreadTimer(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers() 
HebaruSan commented 3 years ago

Removing the following speculation from the description because it's distracting and unhelpful to the investigation, there's no evidence for it, and it's probably wrong:

There's no other program on the system trying to access the file (a texture in KSP), so that makes me think it's multi-thread issue.

, it steps on it's own toes and tries to access a file in-use by itself

Expected behavior Honestly, for a minor thing like a texture roll-back fail, I'd expect it to at-least ask me to continue regardless, rather than failing the install in the middle and leaving me with a disjointed instance of quasi-modded KSP I have to delete.

HebaruSan commented 3 years ago

First thing I notice is that "a texture roll-back fail" is not at all a routine event, let alone "a minor thing". The fact that it's attempting to roll back a transaction at all means that something unrecoverable has already happened before that (and whatever that was, it's not reflected in the given exception), and CKAN is trying to cancel the install, and that effort then also fails somehow. Needless to say if this was happening because CKAN "steps on its own toes and tries to access a file in-use by itself," users other than @MrChaosBones would be experiencing this as well.

I would recommend checking your antivirus program's logs. When we see disruptive/intrusive/invasive file system activity like this on Windows, that's often the culprit. If you're comfortable making an exception for CKAN in your antivirus software or temporarily disabling it completely, that would be a worthwhile test to run.

MrChaosBones commented 3 years ago

Sorry, as I said, it was/is my first time using CKAN, and this post was after about 4 hours of head-bashing and trying to make my system hospitable to it, because I run windows very... unix-esque, to say. To the point - there is no anti-virus present on my system, except some vestigial pieces of Windows Defender, which are too hardcoded into the lower windows kernel to scalpel out without extensive OS rewrites. What does CKAN try to do, in order, when downloading/installing mods? Is there anything more needed than a hard-drive wide read/write permission and internet connection?

HebaruSan commented 3 years ago

Interesting. In that case, maybe you should try the command line tools; the --debug flag might give us enough clues to figure out what is initially failing and causing an attempted transaction rollback.

ckan.exe install Kerbalism RealismOverhaul --debug
MrChaosBones commented 3 years ago

It worked! I'm writing this for posterity, rather than any actual use because of the extreme oddity of the case. From your suggestion about the antivirus, I looked into the net-use of CKAN, and it turned out it tries to use ports I've disabled (downside of running a net-bare computer, you do have to sacrifice a bit of time to manage ports semi-manually.) In my case, I let my system do only around 150 active ports for general use. In essence the issue is that probably some sub-mod tries to call a port outside of the allowed scope, which leads to a clandestine security macro to basically quarantine the process that tried to use a disabled port via taking away every permission, down to the CPU I/O (draconic, I know. It isn't the first time it's bit me behind.) I hotpatched it via running CKAN through hamachi and limiting the target ports from there. Went through without a sitch. Thanks for your time and help! :)