We were having a specific issue in our Dev and QA environments where K2 was consuming over 16GB of disk space, and subsequently causing our server to run out of disk space. We had an interim workaround of restarting the K2 service, but within a day of testing, it was possible that K2 would eat it all up again.
This was happening because workflow instances (cases in our example) are tied to specific versions of the workflow. Similar to .NET websites, in order for you to use a specific version it has to do a lot of pre-compiling. Now, I’m not sure why it was using so much disk space per version, but that is essentially what was causing all our issues.
There are a few things that could’ve made this better:
- Testers and Developers not using old cases which are tied to older versions
- Building our K2 workflows in Release instead of Debug
Turns out option #2 reduces the space an individual version uses by orders of magnitude. Sadly, there is no way to retrofit the processes that are actually already in K2.
The actual solution is to use some of the new APIs, specifically the Live Instance Management APIs (oh and that took awhile to find via searching). The downside is that these APIs were added in 4.5, so anyone on a version prior to that is screwed. Thankfully we were on 4.5.1!
Anyways, if you’re lazy, there is actually an already created utility on K2 Underground, and you can find out some additional info about it too.
Just be prepared for it not to work all that great. We received a ton of Null Reference errors while running the utility against our large database. It seemed to work fine in our POC, but not against the real thing. Some cases were changed, but not all, and we still had the same issue.
In the end, we had to manually go and delete the old cases in K2, which is definitely not supported. However, our app handles it gracefully, so it wasn’t a huge deal.