You shouldn't put an Apache::Session object in a global. If it fails to go out of scope, it will never release locks. However, the problem you're having does not sound like a locking issue. I suspect you just have some kind of minor bug in your code somewhere. If you try to reduce it to a small failing example, you might find the problem.